Skip to content

Commit 09e953e

Browse files
committed
Re-adds labs
1 parent 196f1e8 commit 09e953e

1 file changed

Lines changed: 77 additions & 8 deletions

File tree

2024/day27.md

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This presentation will give a broad overview of Ansible and its architecture and
1616
Participants will get first-hand insights into Ansible, its strengths, weaknesses, and the potential of event-driven automation within the DevOps world.
1717

1818
> [!NOTE]
19-
> The below content is a copy of the [lab repository's] README for convenience.
19+
> The below content is a copy of the [lab repository's](https://github.com/mocdaniel/lab-event-driven-ansible) README for convenience.
2020
2121
---
2222

@@ -28,7 +28,7 @@ The setup is done with Ansible, too. It will install **Ansible, EDA, Prometheus*
2828

2929
## Prerequisites
3030

31-
To follow along with this lab in its entirety, you will need four VMs:
31+
To follow along with this lab in its entirety, you will need three VMs:
3232

3333
> [!NOTE]
3434
> If you want to skip Ansible basics and go straight to EDA, you'll need just the `eda-controller.example.com` VM and can skip the others.
@@ -37,8 +37,7 @@ To follow along with this lab in its entirety, you will need four VMs:
3737
|--------------------|-------------|
3838
| eda-controller.example.com | CentOS/Rocky 8.9 |
3939
| company.example.com | CentOS/Rocky 8.9 |
40-
| internal.example.com | Ubuntu 22.04 |
41-
| webshop.example.com | OpenSUSE 15.5 |
40+
| webshop.example.com | Ubuntu 22.04 |
4241

4342
**You'll need to be able to SSH to each of these VMs as root using SSH keys.**
4443

@@ -68,13 +67,10 @@ webservers:
6867
hosts:
6968
webshop.example.com:
7069
ansible_host: <ip-address>
71-
webserver: nginx
70+
webserver: apache2
7271
company.example.com:
7372
ansible_host: <ip-address>
7473
webserver: httpd
75-
internal.example.com:
76-
ansible_host: <ip-address>
77-
webserver: apache2
7874
eda_controller:
7975
hosts:
8076
eda-controller.example.com:
@@ -97,3 +93,76 @@ ansible-playbook playbooks/setup.yml
9793

9894
> [!CAUTION]
9995
> Due to a known bug with Python on MacOS, you need to run `export NO_PROXY="*"` on MacOS before running the playbook
96+
97+
---
98+
99+
## Demos
100+
101+
### Lab 1: Ansible Basics
102+
103+
<details>
104+
105+
<summary>Ansible from the CLI via ansible</summary>
106+
107+
#### Ansible from the CLI via `ansible`
108+
109+
The first example installs a webserver on all hosts in the `webservers` group. The installed webserver is defined as a **host variable** in the inventory file `hosts.yml` (*see above*).
110+
111+
```console
112+
ansible \
113+
webservers \
114+
-m package \
115+
-a 'name="{{ webserver }}"' \
116+
--one-line
117+
```
118+
119+
Afterwards, we can start the webserver on all hosts in the `webservers` group.
120+
121+
```console
122+
ansible \
123+
webservers \
124+
-m service \
125+
-a 'name="{{ webserver }}" state=started' \
126+
--one-line
127+
```
128+
129+
Go on and check if the web servers are running on the respective hosts.
130+
131+
> [!TIP]
132+
> Ansible is **idempotent** - try running the commands again and see how the output differs.
133+
134+
</details>
135+
136+
<details>
137+
138+
<summary>Ansible from the CLI via ansible-playbook</summary>
139+
140+
#### Ansible from the CLI via `ansible-playbook`
141+
142+
The second example utilizes the following **playbook** to **gather** and **display information** for all hosts in the `webservers` group, utilizing the **example** role from the lab repository.
143+
144+
```yaml
145+
---
146+
- name: Example role
147+
hosts: webservers
148+
gather_facts: false
149+
vars:
150+
greeting: "Hello World!"
151+
pre_tasks:
152+
- name: Say Hello
153+
ansible.builtin.debug:
154+
msg: "{{ greeting }}"
155+
roles:
156+
- role: example
157+
post_tasks:
158+
- name: Say goodbye
159+
ansible.builtin.debug:
160+
msg: Goodbye!
161+
```
162+
163+
```console
164+
ansible-playbook \
165+
playbooks/example.yml
166+
```
167+
168+
</details>

0 commit comments

Comments
 (0)