Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ch2-inventory/student-lqvan/03-hostgroups-children.yml
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions ch3-playbook/08-install-apache.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions ch3-playbook/files/index.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>Hello {{ http_host[ansible_os_family] }} !</title>
</head>
<body>
<h1>Hello! {{ http_host[ansible_os_family] }} apache is working!</h1>
</body>
</html>