вводное
!!! Пробелы ОЧЕНЬ ВАЖНЫ !!! НЕ ИСПОЛЬЗУЙТЕ "TAB" будут ошибки на ровном месте ansible-playbook NAMEPLAYBOOK.yml - запуск плейбука
playbook0.yml ping
---
- name: Test connection to my servers
hosts: all
become: yes
tasks:
- name: Ping my servers
ping:
...
playbook1.yml install httpd CentOS
---
- 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
---
- 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
---
- 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
...