diff --git a/ch2-inventory/student-quanpt/01-ipOnly.yaml b/ch2-inventory/student-quanpt/01-ipOnly.yaml new file mode 100644 index 0000000..be39e19 --- /dev/null +++ b/ch2-inventory/student-quanpt/01-ipOnly.yaml @@ -0,0 +1,6 @@ +all: + hosts: + 192.168.100.11: + 192.168.100.12: + 192.168.100.21: + 192.168.100.22: diff --git a/ch2-inventory/student-quanpt/02-nonFQDN.yaml b/ch2-inventory/student-quanpt/02-nonFQDN.yaml new file mode 100644 index 0000000..46d5ee3 --- /dev/null +++ b/ch2-inventory/student-quanpt/02-nonFQDN.yaml @@ -0,0 +1,12 @@ +all: + hosts: + ubuntu11: + ansible_host: 192.168.100.11 + ubuntu12: + ansible_host: 192.168.100.12 + centos21: + ansible_host: 192.168.100.21 + centos22: + ansible_host: 192.168.100.22 + ubuntu-2: + ansible_host: 192.168.94.242 diff --git a/ch2-inventory/student-quanpt/03-hostgroups-children-copy.yaml b/ch2-inventory/student-quanpt/03-hostgroups-children-copy.yaml new file mode 100644 index 0000000..fd83e66 --- /dev/null +++ b/ch2-inventory/student-quanpt/03-hostgroups-children-copy.yaml @@ -0,0 +1,18 @@ +all: + hosts: + fakehost.local: + children: + linux: + children: + ubuntu: + hosts: + ubuntu11: + ansible_host: 192.168.100.11 + ubuntu12: + ansible_host: 192.168.100.12 + centos: + hosts: + centos21: + ansible_host: 192.168.100.21 + centos22: + ansible_host: 192.168.100.22 diff --git a/ch3-playbook/07-install-apache-not-work.yaml b/ch3-playbook/07-install-apache-not-work.yaml index 8a09eb2..67257af 100644 --- a/ch3-playbook/07-install-apache-not-work.yaml +++ b/ch3-playbook/07-install-apache-not-work.yaml @@ -6,12 +6,12 @@ tasks: - name: Install Apache package - yum: - name: httpd + apt: + name: apache2 state: latest - name: Restart and enable the service - service: - name: httpd + systemd: + name: apache2 state: restarted - enabled: yes \ No newline at end of file + enabled: yes diff --git a/ch3-playbook/08-quanpt-apache-helloworld.yaml b/ch3-playbook/08-quanpt-apache-helloworld.yaml new file mode 100644 index 0000000..65825a9 --- /dev/null +++ b/ch3-playbook/08-quanpt-apache-helloworld.yaml @@ -0,0 +1,25 @@ +# Playbook for automated apache installation +--- +- name: The demo playbook + hosts: all + gather_facts: yes + become: yes + vars: + my_name: 'QuanPT' + + tasks: + - name: Install Apache package + apt: + name: apache2 + state: latest + + - name: template index.html + template: + src: ./files/index.html + dest: /var/www/html/ + mode: 0755 + - name: Restart and enable the service + systemd: + name: apache2 + state: restarted + enabled: yes diff --git a/ch3-playbook/files/index.html b/ch3-playbook/files/index.html new file mode 100644 index 0000000..427385a --- /dev/null +++ b/ch3-playbook/files/index.html @@ -0,0 +1 @@ +{{my_name}} diff --git a/ch3-playbook/inventory/hosts b/ch3-playbook/inventory/hosts index e02db0e..8ee972c 100644 --- a/ch3-playbook/inventory/hosts +++ b/ch3-playbook/inventory/hosts @@ -1,13 +1,13 @@ [ubuntu] -ubuntu11 ansible_host=192.168.100.11 -ubuntu12 ansible_host=192.168.100.12 +ubuntu-2 ansible_host=192.168.94.242 +ubuntu-3 ansible_host=192.168.94.243 -[centos] -centos21 ansible_host=192.168.100.21 -centos22 ansible_host=192.168.100.22 +#[centos] +#centos21 ansible_host=192.168.100.21 +#centos22 ansible_host=192.168.100.22 -[linux:children] -ubuntu -centos +#[linux:children] +#ubuntu +#centos