From 00c2b81966dc766016cdaf0b1ade3fc562b21bc1 Mon Sep 17 00:00:00 2001 From: tinnguyennct Date: Fri, 28 May 2021 15:48:10 +0000 Subject: [PATCH 1/6] Tin exercise 01 --- ch1-lab-setup/sample/hosts.ini | 7 ++++++- ch2-inventory/inventory/01-ipOnly.ini | 7 +++---- ch2-inventory/nctin/02-nonFQDN.yml | 9 +++++++++ .../nctin/03-hostgroups-children.yml | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 ch2-inventory/nctin/02-nonFQDN.yml create mode 100644 ch2-inventory/nctin/03-hostgroups-children.yml diff --git a/ch1-lab-setup/sample/hosts.ini b/ch1-lab-setup/sample/hosts.ini index 8a716fa..4a5278c 100644 --- a/ch1-lab-setup/sample/hosts.ini +++ b/ch1-lab-setup/sample/hosts.ini @@ -1,2 +1,7 @@ [linux] -192.168.100.21 +172.16.44.103 +172.16.44.231 +172.16.44.172 +#192.168.1.7 +#192.168.1.17 +#192.168.1.31 diff --git a/ch2-inventory/inventory/01-ipOnly.ini b/ch2-inventory/inventory/01-ipOnly.ini index 43895f0..2cb593d 100644 --- a/ch2-inventory/inventory/01-ipOnly.ini +++ b/ch2-inventory/inventory/01-ipOnly.ini @@ -1,7 +1,6 @@ -192.168.100.11 +192.168.1.17 -192.168.100.12 +192.168.1.43 -192.168.100.21 +192.168.1.239 -192.168.100.22 diff --git a/ch2-inventory/nctin/02-nonFQDN.yml b/ch2-inventory/nctin/02-nonFQDN.yml new file mode 100644 index 0000000..2a8e7d4 --- /dev/null +++ b/ch2-inventory/nctin/02-nonFQDN.yml @@ -0,0 +1,9 @@ +all: + hosts: + centos01: + ansible_host: 192.168.1.17 + centos02: + ansible_host: 192.168.1.43 + centos03: + ansible_host: 192.168.1.239 + diff --git a/ch2-inventory/nctin/03-hostgroups-children.yml b/ch2-inventory/nctin/03-hostgroups-children.yml new file mode 100644 index 0000000..a18be1f --- /dev/null +++ b/ch2-inventory/nctin/03-hostgroups-children.yml @@ -0,0 +1,19 @@ +all: + hosts: + fakehost.local: + children: + linux: + children: + ubuntu: + hosts: + ubuntu: + ansible_host: 192.168.1.109 + centos: + hosts: + centos1: + ansible_host: 192.168.1.17 + centos2: + ansible_host: 192.168.1.43 + centos3: + ansible_host: 192.168.1.239 + From 7a019b5da5c53e6672d6f7f46331420161d03f8d Mon Sep 17 00:00:00 2001 From: tinnguyennct Date: Fri, 28 May 2021 15:58:45 +0000 Subject: [PATCH 2/6] Tin commit ex01 --- ch2-inventory/student-nctin/02-nonFQDN.yml | 12 ++++++++++++ .../student-nctin/03-hostgroups-children.yml | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 ch2-inventory/student-nctin/02-nonFQDN.yml create mode 100644 ch2-inventory/student-nctin/03-hostgroups-children.yml diff --git a/ch2-inventory/student-nctin/02-nonFQDN.yml b/ch2-inventory/student-nctin/02-nonFQDN.yml new file mode 100644 index 0000000..a0a0ba2 --- /dev/null +++ b/ch2-inventory/student-nctin/02-nonFQDN.yml @@ -0,0 +1,12 @@ +all: + hosts: + ubuntu01: + ansible_host: 192.168.1.109 + centos01: + ansible_host: 192.168.1.17 + centos02: + ansible_host: 192.168.1.43 + centos03: + ansible_host: 192.168.1.239 + + diff --git a/ch2-inventory/student-nctin/03-hostgroups-children.yml b/ch2-inventory/student-nctin/03-hostgroups-children.yml new file mode 100644 index 0000000..a18be1f --- /dev/null +++ b/ch2-inventory/student-nctin/03-hostgroups-children.yml @@ -0,0 +1,19 @@ +all: + hosts: + fakehost.local: + children: + linux: + children: + ubuntu: + hosts: + ubuntu: + ansible_host: 192.168.1.109 + centos: + hosts: + centos1: + ansible_host: 192.168.1.17 + centos2: + ansible_host: 192.168.1.43 + centos3: + ansible_host: 192.168.1.239 + From a8fb097e851d47db55e6bd5b9ea77e0fa7c05045 Mon Sep 17 00:00:00 2001 From: tinnguyennct Date: Fri, 28 May 2021 16:09:21 +0000 Subject: [PATCH 3/6] Tin ex01 --- ch2-inventory/nctin/02-nonFQDN.yml | 9 --------- .../nctin/03-hostgroups-children.yml | 19 ------------------- 2 files changed, 28 deletions(-) delete mode 100644 ch2-inventory/nctin/02-nonFQDN.yml delete mode 100644 ch2-inventory/nctin/03-hostgroups-children.yml diff --git a/ch2-inventory/nctin/02-nonFQDN.yml b/ch2-inventory/nctin/02-nonFQDN.yml deleted file mode 100644 index 2a8e7d4..0000000 --- a/ch2-inventory/nctin/02-nonFQDN.yml +++ /dev/null @@ -1,9 +0,0 @@ -all: - hosts: - centos01: - ansible_host: 192.168.1.17 - centos02: - ansible_host: 192.168.1.43 - centos03: - ansible_host: 192.168.1.239 - diff --git a/ch2-inventory/nctin/03-hostgroups-children.yml b/ch2-inventory/nctin/03-hostgroups-children.yml deleted file mode 100644 index a18be1f..0000000 --- a/ch2-inventory/nctin/03-hostgroups-children.yml +++ /dev/null @@ -1,19 +0,0 @@ -all: - hosts: - fakehost.local: - children: - linux: - children: - ubuntu: - hosts: - ubuntu: - ansible_host: 192.168.1.109 - centos: - hosts: - centos1: - ansible_host: 192.168.1.17 - centos2: - ansible_host: 192.168.1.43 - centos3: - ansible_host: 192.168.1.239 - From 07c47f8ccaa8537fb60002013d4df5dcf704e378 Mon Sep 17 00:00:00 2001 From: tinnguyennct Date: Fri, 4 Jun 2021 12:11:27 +0000 Subject: [PATCH 4/6] Tinnc ex02 --- ch3-playbook/07-install-apache-not-work.yaml | 20 +++++++++++++++----- ch3-playbook/files/index.html | 8 ++++++++ ch3-playbook/inventory/group_vars/all.yaml | 6 ++++-- 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 ch3-playbook/files/index.html diff --git a/ch3-playbook/07-install-apache-not-work.yaml b/ch3-playbook/07-install-apache-not-work.yaml index 8a09eb2..7739826 100644 --- a/ch3-playbook/07-install-apache-not-work.yaml +++ b/ch3-playbook/07-install-apache-not-work.yaml @@ -3,15 +3,25 @@ - name: The demo playbook hosts: all gather_facts: yes - + vars: + - my_name: tinnc + - web_server: + Debian: apache2 + RedHat: httpd tasks: - - name: Install Apache package + - name: Install Apache package Centos yum: - name: httpd + name: "{{ web_server[ansible_os_family] }}" state: latest + - name: index Hello! + template: + src: "files/index.html" + dest: "/var/www/html/" + mode: 0755 + - name: Restart and enable the service service: - name: httpd + name: "{{ web_server[ansible_os_family] }}" state: restarted - enabled: yes \ No newline at end of file + enabled: yes diff --git a/ch3-playbook/files/index.html b/ch3-playbook/files/index.html new file mode 100644 index 0000000..faeb308 --- /dev/null +++ b/ch3-playbook/files/index.html @@ -0,0 +1,8 @@ + + + Hello tinnc ! + + +

Hello! tinnc!

+ + diff --git a/ch3-playbook/inventory/group_vars/all.yaml b/ch3-playbook/inventory/group_vars/all.yaml index e82f747..b45afa0 100644 --- a/ch3-playbook/inventory/group_vars/all.yaml +++ b/ch3-playbook/inventory/group_vars/all.yaml @@ -1,2 +1,4 @@ -ansible_user: ansible -ansible_password: admin123 #will be moved into Ansible Vault for more secure \ No newline at end of file +#ansible_user: ansible +#ansible_password: admin123 #will be moved into Ansible Vault for more secure +ansible_become: yes +ansible_become_method: sudo From 72a5f6d45dc371754787c0b38574cb52744dcdf9 Mon Sep 17 00:00:00 2001 From: tinnguyennct Date: Fri, 4 Jun 2021 12:18:29 +0000 Subject: [PATCH 5/6] edit index.html --- ch3-playbook/files/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ch3-playbook/files/index.html b/ch3-playbook/files/index.html index faeb308..0fe9c3a 100644 --- a/ch3-playbook/files/index.html +++ b/ch3-playbook/files/index.html @@ -1,8 +1,8 @@ - Hello tinnc ! + Hello {{ my_name }} ! -

Hello! tinnc!

+

Hello! {{ my_name }}!

From 613a875191312e92cdb1dcafb70af40c18f5824a Mon Sep 17 00:00:00 2001 From: tinnguyennct Date: Fri, 4 Jun 2021 12:20:23 +0000 Subject: [PATCH 6/6] edit ansible playbook --- ch3-playbook/07-install-apache-not-work.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch3-playbook/07-install-apache-not-work.yaml b/ch3-playbook/07-install-apache-not-work.yaml index 7739826..a802f87 100644 --- a/ch3-playbook/07-install-apache-not-work.yaml +++ b/ch3-playbook/07-install-apache-not-work.yaml @@ -9,7 +9,7 @@ Debian: apache2 RedHat: httpd tasks: - - name: Install Apache package Centos + - name: Install Apache package yum: name: "{{ web_server[ansible_os_family] }}" state: latest