Skip to content

Commit 32d025f

Browse files
committed
WIP
1 parent 15a3772 commit 32d025f

29 files changed

+346
-42
lines changed

.vscode/tasks.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"options": {
44
"env": {
55
/* Public FQDN to the Ansible Controller Host*/
6-
"ANSIBLEHOST": "ec2-18-184-71-54.eu-central-1.compute.amazonaws.com",
6+
"ANSIBLEHOST": "ec2-18-194-207-94.eu-central-1.compute.amazonaws.com",
77
/* Path to Win SCP Executable*/
88
"WINSCPEXE": "C:\\Program Files (x86)\\WinSCP\\WinSCP.com",
99

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ SSH Putty key: /vagrant/ssh/putty.workshop.priv.ppk
6666
### environment
6767

6868
Ansible Playbook to manage all attendant ec2 instances for workshop
69+
70+
> It takes ~15min to build the Infra on AWS
6971
7072
#### Create AWS Infrastructure
7173

TODO.md

-22
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11

22

3-
- Slogan für Schulungs start folie
43

5-
- loop , da dies nun die default sache ist
6-
https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#standard-loops
7-
8-
- Yaml Basics
94

105
- Übersicht liste nochmal durchgehen ob wir nochwas vergessen haben
116

12-
- Ansible for Network Devices
13-
14-
15-
167
- Hinzufügen was mir noch einfällt was ich erzählen will per folie
178

189
- Ausdrucken der Speak notes > javascript Console > PrintRevealNotes();
@@ -23,22 +14,9 @@
2314

2415
https://linuxacademy.com/site-content/uploads/2019/05/Linux-Academy-Ansible-Roles-Cheatsheet.pdf
2516

26-
- Bonus task? HA Proxy auf ctrl ec2 instance
27-
28-
29-
30-
3117
- Implement ARA on ansible vm
3218
- Do the slides
3319
- Writeout help desk for slides
3420
- write up handout
3521
- Test lenght
3622
- build docs with sphinx, da wir kein PDF Export haben?
37-
38-
39-
40-
41-
Coole memes
42-
43-
https://www.imagenesmy.com/imagenes/configuration-management-meme-a3.html
44-

demos/5-bonus/ansible_req.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ansible-galaxy install -r requirements.yml --roles-path roles

demos/5-bonus/bonus.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
- name: We make us some Webservers
3+
hosts: web,win1
4+
tasks:
5+
- import_role: name=myapp
6+
vars:
7+
config: "{{ app_config }}"
8+
9+
- name: Ensure HA Proxy
10+
hosts: ctrl
11+
tasks:
12+
- import_role: name=geerlingguy.haproxy
13+
vars:
14+
haproxy_frontend_name: 'hafrontend'
15+
haproxy_frontend_bind_address: '*'
16+
haproxy_frontend_port: 80
17+
haproxy_frontend_mode: 'http'
18+
19+
haproxy_backend_name: 'habackend'
20+
haproxy_backend_mode: 'http'
21+
haproxy_backend_balance_method: 'roundrobin'
22+
haproxy_backend_httpchk: 'HEAD / HTTP/1.1\r\nHost:localhost'
23+
24+
haproxy_backend_servers:
25+
- name: debian1
26+
address: 10.0.1.21
27+
- name: debian2
28+
address: 10.0.1.22
29+
- name: win1
30+
address: 10.0.1.41
31+
32+

demos/5-bonus/host_vars/debian1.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
app_config:
2+
title: "Automate all the things!"
3+
image: image1.jpg

demos/5-bonus/host_vars/debian2.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
app_config:
2+
title: "I know Ansible and Yaml!"
3+
image: image2.jpg

demos/5-bonus/host_vars/win1.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
app_config:
2+
title: "640K ought to be enough for anyone."
3+
image: windows.png

demos/5-bonus/inventory.ini

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
ctrl ansible_host=10.0.1.10
2+
debian1 ansible_host=10.0.1.21
3+
debian2 ansible_host=10.0.1.22
4+
win1 ansible_host=10.0.1.41
5+
6+
[windows]
7+
win1
8+
9+
[linux]
10+
ctrl
11+
debian1
12+
debian2
13+
14+
# Added this
15+
[web]
16+
debian1
17+
debian2
18+
19+
[linux:vars]
20+
ansible_become=yes
21+
ansible_user=admin
22+
ansible_port=22
23+
ansible_ssh_private_key_file="~/.ssh/workshop.key"
24+
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
25+
26+
[windows:vars]
27+
ansible_connection=winrm
28+
ansible_user="Administrator"
29+
ansible_password="ansible#workshop1"
30+
ansible_winrm_transport=basic
31+
ansible_winrm_server_cert_validation=ignore
32+
ansible_port=5986

demos/5-bonus/requirements.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- src: geerlingguy.haproxy
2+
version: 1.1.2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
config:
2+
title: "Automate all the things!"
3+
image: image1.jpg
4+
5+
iis_default_root: "c:/inetpub/wwwroot"
49.1 KB
Loading
21.1 KB
Loading
242 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- name: restart_nginx
2+
service:
3+
name: nginx.service
4+
state: restarted
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
- name: nginx package is present
2+
apt:
3+
name: nginx
4+
state: latest
5+
notify: restart_nginx
6+
7+
- name: deploy our awesome app - index.html
8+
template:
9+
src: index.html
10+
dest: /var/www/html/index.html
11+
12+
- name: deploy our awesome app - image.jpg
13+
copy:
14+
src: "{{ app_config.image }}"
15+
dest: "/var/www/html/{{ app_config.image }}"
16+
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- include_tasks: debian.yml
2+
when: "ansible_os_family == 'Debian'"
3+
4+
- include_tasks: windows.yml
5+
when: "ansible_os_family == 'Windows'"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
- name: "windows: ensure iis role is installed"
2+
win_feature:
3+
name: Web-Server
4+
5+
- name: "windows: ensure index.html is present as default.htm"
6+
win_template:
7+
src: "index.html"
8+
dest: "{{ iis_default_root }}/default.htm"
9+
10+
- name: "windows: ensure image.png exists in webroot"
11+
win_copy:
12+
src: "{{ config.image }}"
13+
dest: "{{ iis_default_root }}/{{ config.image }}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head>
3+
<title>Ansible Configured Host</title>
4+
</head>
5+
<body>
6+
<h2>{{ config.title }}</h2>
7+
<img src="{{ config.image }}"/>
8+
</body>
9+
</html>

doc/README.md

-7
This file was deleted.

doc/writeout.md

-1
This file was deleted.

slides/content/3_playbook_advanced/10_block.html

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
note:
2424
- Gruppiert die tasks für das when
25-
- Gruppiert become
2625
</section>
2726

2827
<section data-markdown="">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<section data-markdown="">
2+
# Assert
3+
4+
Überprüft eine Jinja2 Expression
5+
6+
```yaml
7+
- assert:
8+
that:
9+
- my_param <=100
10+
- my_param >=0
11+
fail_msg: "'my_param' must be between 0 and 100"
12+
success_msg: "'my_param' is between 0 and 100"
13+
14+
# quiet = true, Gibt das Assert nicht im Output aus
15+
- assert:
16+
that:
17+
- my_param <=100
18+
- my_param >=0
19+
quiet: true
20+
```
21+
22+
note:
23+
- Überprüfung von Eingabevariablen
24+
- zb. wenn das playbook von einem anderen System aufgerufen wird
25+
- Rollen Variablen
26+
27+
</section>
28+
<section data-markdown="">
29+
# Pause / Input
30+
31+
Hält das Playbook an und wartet auf Keypress bzw. Ablauf der zeit
32+
33+
```yaml
34+
# Wartet 5 Minuten
35+
- pause:
36+
minutes: 5
37+
38+
# Als Erinnerung
39+
- pause:
40+
prompt: "Überprüfe ob der Tomcat Server die Anwendung geladen hat"
41+
42+
# Erwartet eingabe, aber gibt kein char echo aus
43+
# Speichert die Eingabe unter in die Variable my_ultra_secert.user_input
44+
- pause:
45+
prompt: Enter a secret
46+
echo: no
47+
register: my_ultra_secret
48+
```
49+
50+
note:
51+
- Pause mit Warten
52+
- Pause unendlich warten mit prompt
53+
- eingabe erfassen
54+
- echo aus
55+
56+
</section>

slides/content/3_playbook_advanced/6_loops.html

+48-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
<section>
2+
<h1>Loops - loop</h1>
3+
<p>
4+
Fürt das Modul für für jedes Element in der Liste auf den Host aus.
5+
</p>
6+
<p>
7+
<pre><code class="hls yaml">
8+
- name: add serveral users
9+
user:
10+
name: "{{ item }}"
11+
state: present
12+
groups: "wheel"
13+
loop:
14+
- testuser1
15+
- testuser2
16+
</code></pre>
17+
</p>
18+
</section>
119
<section>
220

321
<h1>Loops - with_items</h1>
@@ -42,6 +60,7 @@ <h3>Simple Loop / For Each</h3>
4260
</div>
4361
<aside class="notes">
4462
<ul>
63+
<li>Ist eine erweiterung zu loop, kann auch mit jinj2 filters und loop durchgeführt werden</li>
4564
<li>Erwartet List / Array</li>
4665
<li>Variable <b>item</b></li>
4766
<li>Kann auch eine Variable sein</li>
@@ -120,7 +139,7 @@ <h3>Simple Loop / For Each</h3>
120139
</section>
121140

122141
<section data-markdown="">
123-
# Loop - Do/Until
142+
# Do/Until
124143

125144
Führt das Modul immer wieder aus bis **until == true** oder **retries == 0** eintritt.
126145

@@ -143,9 +162,9 @@ <h3>Simple Loop / For Each</h3>
143162

144163
<section data-markdown="">
145164

146-
# Loops: loop_control
165+
# loop_control - **loop_var**
147166

148-
## Anderen Variablen Name verwenden für den Loop
167+
**Benutzerdefinierten Variablen Name** verwenden für den Loop.
149168

150169
```yaml
151170
- copy:
@@ -156,9 +175,30 @@ <h3>Simple Loop / For Each</h3>
156175
- server.cfg
157176
loop_control:
158177
loop_var: config_file_name
178+
179+
```
180+
181+
</section>
182+
<section data-markdown="">
183+
# loop_control - **index_var**
184+
185+
**Index Variable** für den loop.
186+
187+
```yaml
188+
- debug:
189+
msg "{{ item }} with index {{ my_idx }}"
190+
loop:
191+
- item1
192+
- item2
193+
loop_control:
194+
index_var: my_idx
159195
```
160196

161-
## Output im stdout minimieren bei Loops über größere Objekte
197+
</section>
198+
<section data-markdown="">
199+
# loop_control - **label**
200+
201+
Output im stdout minimieren bei Loops über größere Objekte
162202

163203
Gibt im Output dann nur mehr **item.name** aus, anstatt der gesamten Datenstruktur als **JSON im stdout** __(Logging!)__
164204

@@ -167,10 +207,12 @@ <h3>Simple Loop / For Each</h3>
167207
servers:
168208
- name: server1
169209
config:
170-
# Massiv große Datenstruktur
210+
# Große Yaml Datenstruktur
211+
# ...
171212
- name: server2
172213
config:
173-
# Massiv große Datenstruktur
214+
# Große Yaml Datenstruktur
215+
# ...
174216

175217
tasks:
176218
- my_module:

0 commit comments

Comments
 (0)