From 371475c01866af1a349de66f4e440e3c397faa97 Mon Sep 17 00:00:00 2001 From: lqvan87 Date: Fri, 28 May 2021 15:29:36 +0000 Subject: [PATCH 1/2] add 03-hostgroups-children.yml --- .../student-lqvan/03-hostgroups-children.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 ch2-inventory/student-lqvan/03-hostgroups-children.yml diff --git a/ch2-inventory/student-lqvan/03-hostgroups-children.yml b/ch2-inventory/student-lqvan/03-hostgroups-children.yml new file mode 100644 index 0000000..75f26b0 --- /dev/null +++ b/ch2-inventory/student-lqvan/03-hostgroups-children.yml @@ -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 1c5255512b25419f4f9e1031fbadccba6852cbd8 Mon Sep 17 00:00:00 2001 From: VAN LQ Date: Thu, 3 Jun 2021 01:43:24 +0700 Subject: [PATCH 2/2] Add 08-install-apache.yaml and index.html.j2 --- ch3-playbook/08-install-apache.yaml | 47 +++++++++++++++++++++++++++++ ch3-playbook/files/index.html.j2 | 8 +++++ 2 files changed, 55 insertions(+) create mode 100644 ch3-playbook/08-install-apache.yaml create mode 100644 ch3-playbook/files/index.html.j2 diff --git a/ch3-playbook/08-install-apache.yaml b/ch3-playbook/08-install-apache.yaml new file mode 100644 index 0000000..31012a8 --- /dev/null +++ b/ch3-playbook/08-install-apache.yaml @@ -0,0 +1,47 @@ +# Playbook for automated apache installation +--- +- name: The demo playbook + hosts: all + become: true + gather_facts: yes + vars: + - repo: + Debian: + - apt # already installed, but need something here + RedHat: + - epel-release + - packages: + Debian: + - apache2 + RedHat: + - httpd + - services: + Debian: apache2 + RedHat: httpd + - http_host: + Debian: + - lqvan-Debian + RedHat: + - lqvan-RedHat + + tasks: + - name: Install repo + # Seperate package transaction for EPEL + # so it is available in the next task + package: + name: "{{ repo[ansible_os_family] }}" + - name: Install Web Server Packages + # Keyed by OS family fact to also support RHEL and Debian + package: + name: "{{ packages[ansible_os_family] }}" + state: latest + - name: Copy index test page + template: + src: "files/index.html.j2" + dest: "/var/www/html/index.html" + + - name: Restart and enable the web service + service: + name: "{{ services[ansible_os_family] }}" + state: restarted + enabled: yes \ No newline at end of file diff --git a/ch3-playbook/files/index.html.j2 b/ch3-playbook/files/index.html.j2 new file mode 100644 index 0000000..ebd0ea1 --- /dev/null +++ b/ch3-playbook/files/index.html.j2 @@ -0,0 +1,8 @@ + + + Hello {{ http_host[ansible_os_family] }} ! + + +

Hello! {{ http_host[ansible_os_family] }} apache is working!

+ + \ No newline at end of file