From 964e72dbf8f359f2a37ebc1053729b5938cb20b3 Mon Sep 17 00:00:00 2001 From: harryhack Date: Sat, 29 May 2021 14:56:48 +0000 Subject: [PATCH 1/4] exercise inventory --- ch2-inventory/student-quanpt/01-ipOnly.yaml | 6 ++++++ ch2-inventory/student-quanpt/02-nonFQDN.yaml | 12 ++++++++++++ .../03-hostgroups-children-copy.yaml | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 ch2-inventory/student-quanpt/01-ipOnly.yaml create mode 100644 ch2-inventory/student-quanpt/02-nonFQDN.yaml create mode 100644 ch2-inventory/student-quanpt/03-hostgroups-children-copy.yaml 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 From 59a4734078abbb97a6aba39ef2f30d00a75db397 Mon Sep 17 00:00:00 2001 From: harryhack Date: Mon, 31 May 2021 15:42:52 +0000 Subject: [PATCH 2/4] 08-quanpt-apache-helloworld.yaml --- ch3-playbook/08-quanpt-apache-helloworld.yaml | 23 +++++++++++++++++++ ch3-playbook/08-quanpt-apache.yaml | 23 +++++++++++++++++++ ch3-playbook/files/index.html | 1 + ch3-playbook/inventory/hosts | 16 ++++++------- 4 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 ch3-playbook/08-quanpt-apache-helloworld.yaml create mode 100644 ch3-playbook/08-quanpt-apache.yaml create mode 100644 ch3-playbook/files/index.html diff --git a/ch3-playbook/08-quanpt-apache-helloworld.yaml b/ch3-playbook/08-quanpt-apache-helloworld.yaml new file mode 100644 index 0000000..9f0d6e6 --- /dev/null +++ b/ch3-playbook/08-quanpt-apache-helloworld.yaml @@ -0,0 +1,23 @@ +# Playbook for automated apache installation +--- +- name: The demo playbook + hosts: all + gather_facts: yes + become: yes + + tasks: + - name: Install Apache package + apt: + name: apache2 + state: latest + + - name: Copy index.html + copy: + src: 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/08-quanpt-apache.yaml b/ch3-playbook/08-quanpt-apache.yaml new file mode 100644 index 0000000..9f0d6e6 --- /dev/null +++ b/ch3-playbook/08-quanpt-apache.yaml @@ -0,0 +1,23 @@ +# Playbook for automated apache installation +--- +- name: The demo playbook + hosts: all + gather_facts: yes + become: yes + + tasks: + - name: Install Apache package + apt: + name: apache2 + state: latest + + - name: Copy index.html + copy: + src: 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..6a46c7d --- /dev/null +++ b/ch3-playbook/files/index.html @@ -0,0 +1 @@ +Hello QuanPT 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 From 444ae6a19ecb75a38b661ddf5f02e2764faf4433 Mon Sep 17 00:00:00 2001 From: harryhack Date: Tue, 1 Jun 2021 09:09:22 +0000 Subject: [PATCH 3/4] 08-quanpt-apache-helloworld.yaml --- ch3-playbook/07-install-apache-not-work.yaml | 10 ++++----- ch3-playbook/08-quanpt-apache.yaml | 23 -------------------- 2 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 ch3-playbook/08-quanpt-apache.yaml 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.yaml b/ch3-playbook/08-quanpt-apache.yaml deleted file mode 100644 index 9f0d6e6..0000000 --- a/ch3-playbook/08-quanpt-apache.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Playbook for automated apache installation ---- -- name: The demo playbook - hosts: all - gather_facts: yes - become: yes - - tasks: - - name: Install Apache package - apt: - name: apache2 - state: latest - - - name: Copy index.html - copy: - src: index.html - dest: /var/www/html/ - mode: 0755 - - name: Restart and enable the service - systemd: - name: apache2 - state: restarted - enabled: yes From fedc8e5b8cbb59c4cefe8a1fb96abfab3705a842 Mon Sep 17 00:00:00 2001 From: harryhack Date: Fri, 4 Jun 2021 04:12:08 +0000 Subject: [PATCH 4/4] update 08-quanpt-apache-helloworld.yaml --- ch3-playbook/08-quanpt-apache-helloworld.yaml | 8 +++++--- ch3-playbook/files/index.html | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ch3-playbook/08-quanpt-apache-helloworld.yaml b/ch3-playbook/08-quanpt-apache-helloworld.yaml index 9f0d6e6..65825a9 100644 --- a/ch3-playbook/08-quanpt-apache-helloworld.yaml +++ b/ch3-playbook/08-quanpt-apache-helloworld.yaml @@ -4,6 +4,8 @@ hosts: all gather_facts: yes become: yes + vars: + my_name: 'QuanPT' tasks: - name: Install Apache package @@ -11,9 +13,9 @@ name: apache2 state: latest - - name: Copy index.html - copy: - src: index.html + - name: template index.html + template: + src: ./files/index.html dest: /var/www/html/ mode: 0755 - name: Restart and enable the service diff --git a/ch3-playbook/files/index.html b/ch3-playbook/files/index.html index 6a46c7d..427385a 100644 --- a/ch3-playbook/files/index.html +++ b/ch3-playbook/files/index.html @@ -1 +1 @@ -Hello QuanPT +{{my_name}}