diff --git a/.gitignore b/.gitignore index 42b4424..5b14a42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ **/.vagrant/ **/*.retry *-console.log +**/all.yaml diff --git a/ch2-inventory/student-trungdc/02-nonFQDN.yml b/ch2-inventory/student-trungdc/02-nonFQDN.yml new file mode 100644 index 0000000..10940d9 --- /dev/null +++ b/ch2-inventory/student-trungdc/02-nonFQDN.yml @@ -0,0 +1,12 @@ +all: + children: + ungrouped: + hosts: + centos21: + ansible_host: 192.168.100.21 + centos22: + ansible_host: 192.168.100.22 + ubuntu11: + ansible_host: 192.168.100.11 + ubuntu12: + ansible_host: 192.168.100.12 diff --git a/ch2-inventory/student-trungdc/03-hostgroups-children.yml b/ch2-inventory/student-trungdc/03-hostgroups-children.yml new file mode 100644 index 0000000..982052e --- /dev/null +++ b/ch2-inventory/student-trungdc/03-hostgroups-children.yml @@ -0,0 +1,19 @@ +all: + children: + linux: + children: + centos: + hosts: + centos21: + ansible_host: 192.168.100.21 + centos22: + ansible_host: 192.168.100.22 + ubuntu: + hosts: + ubuntu11: + ansible_host: 192.168.100.11 + ubuntu12: + ansible_host: 192.168.100.12 + ungrouped: + hosts: + fakehost.local: {} diff --git a/ch2-inventory/student-trungdc/04-hostvars.yml b/ch2-inventory/student-trungdc/04-hostvars.yml new file mode 100644 index 0000000..f122bc8 --- /dev/null +++ b/ch2-inventory/student-trungdc/04-hostvars.yml @@ -0,0 +1,24 @@ +all: + children: + linux: + children: + centos: + hosts: + centos21: + ansible_host: 192.168.100.21 + foo: bar1 + centos22: + ansible_host: 192.168.100.22 + foo: bar1 + ubuntu: + hosts: + ubuntu11: + ansible_host: 192.168.100.11 + foo: bar + ubuntu12: + ansible_host: 192.168.100.12 + foo: bar2 + ungrouped: + hosts: + fakehost.local: + foo: bar3 diff --git a/ch3-playbook/student-trungdc/07-install-apache-not-work.yaml b/ch3-playbook/student-trungdc/07-install-apache-not-work.yaml new file mode 100644 index 0000000..b1ea56b --- /dev/null +++ b/ch3-playbook/student-trungdc/07-install-apache-not-work.yaml @@ -0,0 +1,33 @@ +# Playbook for automated apache installation +--- +- name: The demo playbook + hosts: all + gather_facts: yes + become: yes + + tasks: + - name: Install Apache package Centos + yum: + name: httpd + state: latest + when: ansible_os_family == 'RedHat' + + - name: Install Apache package Ubuntu + apt: + name: apache2 + state: latest + when: ansible_os_family == 'Debian' + + - name: Restart and enable on Centos + service: + name: httpd + state: restarted + enabled: yes + when: ansible_os_family == 'RedHat' + + - name: Restart and enable on Ubuntu + service: + name: apache2 + state: restarted + enabled: yes + when: ansible_os_family == 'Debian' \ No newline at end of file