Skip to content

Commit ea680b6

Browse files
committed
mega commit
this commit - adds remainder of spanish language links to all readmes for ansible_rhel workshop_type - changes all curls from IP addresses to DNS - adds solution for 1.7
1 parent 58bf3d8 commit ea680b6

37 files changed

+157
-55
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ansible/
2121
demos/servicenow/private.yml
2222
*.html
2323
!exercises/ansible_rhel/1.3-playbook/web.html
24+
!exercises/ansible_rhel/1.7-role/roles/apache_vhost/files/web.html
2425
!exercises/ansible_rhel/1.4-variables/files/dev_web.html
2526
!exercises/ansible_rhel/1.4-variables/files/prod_web.html
2627
demos/servicenow/closed_loop_incident_mgmt/input_vars.yaml

exercises/ansible_rhel/1.4-variables/README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,28 @@ Create a new Playbook called `deploy_index_html.yml` in the `~/ansible-files/` d
135135

136136
## Step 4 - Test the Result
137137

138-
The Playbook should copy different files as index.html to the hosts, use `curl` to test it. Check the inventory again if you forgot the IP addresses of your nodes.
138+
The Ansible Playbook copies different files as index.html to the hosts, use `curl` to test it.
139139

140-
```bash
141-
[student<X>@ansible ansible-files]$ grep node ~/lab_inventory/hosts
142-
node1 ansible_host=11.22.33.44
143-
node2 ansible_host=22.33.44.55
144-
node3 ansible_host=33.44.55.66
145-
[student<X>@ansible ansible-files]$ curl http://11.22.33.44
140+
For node1:
141+
```
142+
[student<X>@ansible ansible-files]$ curl http://node1
146143
<body>
147144
<h1>This is a development webserver, have fun!</h1>
148145
</body>
149-
[student1@ansible ansible-files]$ curl http://22.33.44.55
146+
```
147+
148+
For node2:
149+
150+
```
151+
[student1@ansible ansible-files]$ curl http://node2
150152
<body>
151153
<h1>This is a production webserver, take care!</h1>
152154
</body>
153-
[student1@ansible ansible-files]$ curl http://33.44.55.66
155+
```
156+
157+
For node3:
158+
```
159+
[student1@ansible ansible-files]$ curl http://node3
154160
<body>
155161
<h1>This is a development webserver, have fun!</h1>
156162
</body>

exercises/ansible_rhel/1.5-handlers/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ So what’s new here?
139139

140140
Run the Playbook. We didn’t change anything in the file yet so there should not be any `changed` lines in the output and of course the handler shouldn’t have fired.
141141

142-
- Now change the `Listen 80` line in `/etc/httpd/conf/httpd.conf` to:
142+
- Now change the `Listen 80` line in `~/ansible-files/files/httpd.conf` to:
143143

144144
```ini
145145
Listen 8080
@@ -154,9 +154,9 @@ Listen 8080
154154
Apache should now listen on port 8080. Easy enough to verify:
155155

156156
```bash
157-
[student1@ansible ansible-files]$ curl http://22.33.44.55
157+
[student1@ansible ansible-files]$ curl http://node1
158158
curl: (7) Failed connect to 22.33.44.55:80; Connection refused
159-
[student1@ansible ansible-files]$ curl http://22.33.44.55:8080
159+
[student1@ansible ansible-files]$ curl http://node1:8080
160160
<body>
161161
<h1>This is a production webserver, take care!</h1>
162162
</body>

exercises/ansible_rhel/1.7-role/README.es.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Ahora ya estás listo para ejecutar tu playbook:
283283
Ejecute un comando curl contra `node2` para confirmar que el role funcionó:
284284

285285
```bash
286-
[student<X>@ansible ansible-files]$ curl -s http://22.33.44.55:8080
286+
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
287287
simple vhost index
288288
```
289289

exercises/ansible_rhel/1.7-role/README.fr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Vous êtes maintenant prêt à exécuter votre playbook:
284284
Exécutez une commande curl contre `node2` pour confirmer que le rôle a fonctionné:
285285

286286
```bash
287-
[student<X>@ansible ansible-files]$ curl -s http://22.33.44.55:8080
287+
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
288288
simple vhost index
289289
```
290290

exercises/ansible_rhel/1.7-role/README.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ Playbook を実行する準備が整いましたので、実行してみまし
274274
`node2` に対して curl コマンドを実行して、 Roles が機能していることを確認します。バーチャルホストのポートは8080です。
275275

276276
```bash
277-
[student<X>@ansible ansible-files]$ curl -s http://<node2>:8080
277+
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
278278
simple vhost index
279279
```
280280

exercises/ansible_rhel/1.7-role/README.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ This exercise will cover:
2929

3030
## Step 1 - Understanding the Ansible Role Structure
3131

32-
Roles are basically automation built around *include* directives and really don’t contain much additional magic beyond some improvements to search path handling for referenced files.
33-
3432
Roles follow a defined directory structure; a role is named by the top level directory. Some of the subdirectories contain YAML files, named `main.yml`. The files and templates subdirectories can contain objects referenced by the YAML files.
3533

3634
An example project structure could look like this, the name of the role would be "apache":
@@ -96,6 +94,27 @@ Have a look at the role directories and their content:
9694
[student<X>@ansible ansible-files]$ tree roles
9795
```
9896

97+
```
98+
roles/
99+
└── apache_vhost
100+
├── defaults
101+
│   └── main.yml
102+
├── files
103+
├── handlers
104+
│   └── main.yml
105+
├── meta
106+
│   └── main.yml
107+
├── README.md
108+
├── tasks
109+
│   └── main.yml
110+
├── templates
111+
├── tests
112+
│   ├── inventory
113+
│   └── test.yml
114+
└── vars
115+
└── main.yml
116+
```
117+
99118
## Step 3 - Create the Tasks File
100119
101120
The `main.yml` file in the tasks subdirectory of the role should do the following:
@@ -110,9 +129,9 @@ The `main.yml` file in the tasks subdirectory of the role should do the followin
110129
111130
> **WARNING**
112131
>
113-
> **The `main.yml` (and other files possibly included by main.yml) can only contain tasks, *not* complete Playbooks!**
132+
> **The `main.yml` (and other files possibly included by main.yml) can only contain tasks, *not* complete playbooks!**
114133
115-
Change into the `roles/apache_vhost` directory. Edit the `tasks/main.yml` file:
134+
Edit the `roles/apache_vhost/tasks/main.yml` file:
116135
117136
```yaml
118137
---
@@ -193,7 +212,7 @@ The full `tasks/main.yml` file is:
193212
- name: deliver html content
194213
copy:
195214
src: web.html
196-
dest: "/var/www/vhosts/{{ ansible_hostname }}"
215+
dest: "/var/www/vhosts/{{ ansible_hostname }}/index.html"
197216
198217
- name: template vhost file
199218
template:
@@ -210,7 +229,7 @@ The full `tasks/main.yml` file is:
210229

211230
## Step 4 - Create the handler
212231

213-
Create the handler in the file `handlers/main.yml` to restart httpd when notified by the template task:
232+
Create the handler in the file `roles/apache_vhost/handlers/main.yml` to restart httpd when notified by the template task:
214233

215234
```yaml
216235
---
@@ -225,14 +244,16 @@ Create the handler in the file `handlers/main.yml` to restart httpd when notifie
225244

226245
Create the HTML content that will be served by the webserver.
227246

228-
- Create the `web.html` file in the "src" directory of the role, `files`:
247+
- Create an web.html file in the "src" directory of the role, `files`:
229248

230-
```bash
231-
[student<X>@ansible ansible-files]$ echo 'simple vhost index' > ~/ansible-files/roles/apache_vhost/files/web.html
249+
```
250+
$ echo 'simple vhost index' > ~/ansible-files/roles/apache_vhost/files/web.html
232251
```
233252
234253
- Create the `vhost.conf.j2` template file in the role's `templates` subdirectory.
235254
255+
`$ cat roles/apache_vhost/templates/vhost.conf.j2`
256+
236257
<!-- {% raw %} -->
237258
```
238259
# {{ ansible_managed }}
@@ -286,11 +307,11 @@ Now you are ready to run your playbook:
286307
Run a curl command against `node2` to confirm that the role worked:
287308

288309
```bash
289-
[student<X>@ansible ansible-files]$ curl -s http://22.33.44.55:8080
310+
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
290311
simple vhost index
291312
```
292313

293-
All looking good? Congratulations! You have successfully completed the Ansible Engine Workshop Exercises!
314+
Congratulations! You have successfully completed this exercise!
294315

295316
----
296317
**Navigation**

exercises/ansible_rhel/1.7-role/README.pt-br.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ Agora você está pronto para executar seu playbook:
272272
Execute um comando curl no `node2` para confirmar que a role funcionou:
273273

274274
```bash
275-
[student<X>@ansible ansible-files]$ curl -s http://22.33.44.55:8080
275+
[student<X>@ansible ansible-files]$ curl -s http://node2:8080
276276
vhost index
277277
```
278278

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
simple vhost index
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
# handlers file for roles/apache_vhost
3+
- name: restart_httpd
4+
service:
5+
name: httpd
6+
state: restarted

0 commit comments

Comments
 (0)