вводное
1 2 3 4 |
!!! Пробелы ОЧЕНЬ ВАЖНЫ !!! НЕ ИСПОЛЬЗУЙТЕ "TAB" будут ошибки на ровном месте ansible-playbook NAMEPLAYBOOK.yml - запуск плейбука |
playbook0.yml ping
1 2 3 4 5 6 7 8 9 |
--- - name: Test connection to my servers hosts: all become: yes tasks: - name: Ping my servers ping: ... |
playbook1.yml install httpd CentOS
1 2 3 4 5 6 7 8 9 10 11 12 13 |
--- - name: Install default Apache Web Servers hosts: all become: yes tasks: - name: Install Apache Web Server yum: name=httpd state=latest - name: Start Apache and Enable it on every boot service: name=httpd state=started enabled=yes ... |
playbook2.yml install apache2 Debian
1 2 3 4 5 6 7 8 9 10 11 12 |
--- - name: Install default Apache Web Servers hosts: all become: yes tasks: - name: Install Apache Web Server yum: name=apache2 state=present - name: Start Apache and Enable it on every boot service: name=apache2 state=started enabled=yes ... |
playbook3.yml install apache2 Debian and copy index.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
--- - name: Install Apache and Upload my Web Page hosts: all become: yes vars: source_file: ./website/index.html destin_file: /var/www/html tasks: - name: Install Apache Web Server yum: name=apache2 state=present - name: Copy index html to Servers copy: src={{ source_file }} dest={{ destin_file }} mode=0555 notify: Restart Apache - name: Start Apache and Enable it on every boot service: name=apache2 state=started enabled=yes handlers: - name: Restart Apache service: name=apache2 state=restarted ... |