Skip to content

Commit b1ae4f6

Browse files
committed
basic playbook slides and workshop finished
1 parent 2580cf1 commit b1ae4f6

23 files changed

+492
-16
lines changed

Diff for: .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-3-122-216-176.eu-central-1.compute.amazonaws.com",
6+
"ANSIBLEHOST": "ec2-18-196-100-40.eu-central-1.compute.amazonaws.com",
77
/* Path to Win SCP Executable*/
88
"WINSCPEXE": "C:\\Program Files (x86)\\WinSCP\\WinSCP.com",
99

Diff for: TODO.md

+13
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,16 @@
55
- Test lenght
66
- build docs with sphinx, da wir kein PDF Export haben?
77
- Wie machen wir die Slides ?
8+
9+
## Dauer zwischen Chapters
10+
11+
- 0_prelude
12+
- slideds 0,25
13+
- 1 overview
14+
- slides 0,25
15+
- Demo/workshop 0,5
16+
- 2 basic playbook
17+
- slides 0,25
18+
- work/workshop
19+
- Pause?? oder mach ma gleich Variablen
20+

Diff for: demos/1-add-hoc/demo.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ansible linux -m command -a "uptime" -i inventory.ini
8282
ansible windows -m win_ping
8383
8484
# windows version herausfinden
85-
ansible windows -m win_shell -a "whoami" -i inventory.ini
85+
ansible windows -m win_command -a "whoami" -i inventory.ini
8686
8787
# Facts abrufen
8888
ansible all -m setup -i inventory.ini
File renamed without changes.

Diff for: demos/1-add-hoc/userfile.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This is the Userfile, i should be in "admin" Home Directory
1+
This is the Userfile, i should be in "admin" Home Directory

Diff for: demos/2-basic-playbook/README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Basic Playbook
2+
3+
```bash
4+
ansible-playbook <playbook> -i <inventory_file>
5+
ansible-playbook simple.yml -i inventory.ini
6+
```
7+
8+
## Übung
9+
10+
- Kopiere die voher erstellte **inventory.ini** in den neuen Workfolder
11+
- Erstelle eine neue Inventory Gruppe für die Debian Server 'web'
12+
- Installiere **nginx** auf beiden Servern Debian Servers (apt)
13+
- Kopiere **index.html**/**image.jpg** in das webroot **/var/www/html** (copy)
14+
- Handler benutzen, um das restarten des services **nginx.service** zu vermeiden bei mehrmaligen aufruf
15+
- Stelle sicher das das Playbook öfters ausgeführt werden kann und es kein **changed** retour liefert
16+
- Teste ob die beiden Debian Hosts eine Website bereitstellen mit dem Browser über die Public FQDN
17+
18+
## Module Hints
19+
20+
https://docs.ansible.com/ansible/latest/modules/modules_by_category.html?highlight=module%20index
21+
22+
- copy (https://docs.ansible.com/ansible/latest/modules/copy_module.html)
23+
- apt (https://docs.ansible.com/ansible/latest/modules/apt_module.html?highlight=apt)
24+
- service (https://docs.ansible.com/ansible/latest/modules/service_module.html#service-module)
25+
26+
## Playbook Hint
27+
28+
```yaml
29+
30+
- name: "Make me an awesome webserver"
31+
hosts: web
32+
become: yes # We need sudo!
33+
tasks:
34+
- name: <beschreibung>
35+
<Module>:
36+
<Modul Parameter>
37+
<Modul Parameter>
38+
<Modul Parameter>
39+
notify: <Handler Name>
40+
- <Another Task>
41+
handlers:
42+
# Don't forget some awesome comments!
43+
- name: <handler name>
44+
<Module>
45+
<Module Parameter>
46+
<Module Parameter>
47+
<Module Parameter>
48+
```

Diff for: demos/2-basic-playbook/image.jpg

111 KB
Loading

Diff for: demos/2-basic-playbook/index.html

+9
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>What pill i choose, we will see after a break :-)</h2>
7+
<img src="image.jpg"/>
8+
</body>
9+
</html>

Diff for: demos/2-basic-playbook/inventory.ini

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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_user=admin
21+
ansible_port=22
22+
ansible_ssh_private_key_file="~/.ssh/workshop.key"
23+
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
24+
25+
[windows:vars]
26+
ansible_connection=winrm
27+
ansible_user="Administrator"
28+
ansible_password="ansible#workshop1"
29+
ansible_winrm_transport=basic
30+
ansible_winrm_server_cert_validation=ignore
31+
ansible_port=5986

Diff for: demos/2-basic-playbook/simple.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
3+
- name: We make us some Webservers
4+
hosts: web
5+
become: yes
6+
tasks:
7+
- name: nginx package is present
8+
apt:
9+
name: nginx
10+
state: latest
11+
notify: restart ngnix
12+
13+
- name: deploy our awesome app - index.html
14+
copy:
15+
src: index.html
16+
dest: /var/www/html/index.html
17+
18+
- name: deploy our awesome app - image.jpg
19+
copy:
20+
src: image.jpg
21+
dest: /var/www/html/image.jpg
22+
23+
handlers:
24+
- name: restart ngnix
25+
service:
26+
name: nginx.service
27+
state: restarted
28+

Diff for: demos/test/something.yml

Whitespace-only changes.

Diff for: slides/content/1_overview/3_modules.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ <h1>Modul Dokumentation - Ansible Doc Website</h1>
6161

6262
- **command / win_command:** Einfaches Command(Keine Shell)
6363

64-
- **shell:** Führt das Command durch eine Shell auf zb. /bin/sh und kann dadurch auch Pipen(**Hier aufpassen**)
64+
- **shell/win_shell:** Führt das Command durch eine Shell auf zb. /bin/sh und kann dadurch auch Pipen(**Hier aufpassen**)
6565

6666
- **script/win_script:** Führt das lokale Script auf den Remote Host aus
6767

Diff for: slides/content/1_overview/4_inventory.html

+2
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,6 @@ <h3>Quelle</h3>
9393

9494
notes:
9595
- verarbeitete Inventory ansehen und kontrollieren
96+
- überprüfen wenn gruppen sehr verschachtelnt sind
97+
- settings von dynamic inventory plugins überprüfen
9698
</section>

Diff for: slides/content/1_overview/7_demo.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<section data-markdown="">
2-
# Demo/Übung 1/Pause
2+
# Demo/Übung 1
33

44
** /workshop/1-addhoc/README.md **
55

@@ -9,6 +9,7 @@
99
> Nicht auf den VS Code Task (STRG + P + Tasks: Run Task > "Automatic Sync Workshop Folder" vergessen :-)
1010

1111
notes:
12+
- tasks.json anpassen
1213
- mit ihnen das inventory file schreibe und nochmals durcherklären
1314
- einzelne connection variablen beschreiben
1415
</section>

Diff for: slides/content/2_playbook_basics/1_vars_basic.html

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<section data-markdown="">
2+
# Playbook - Variablen
3+
4+
Ansible kann Metadaten von vielen Quellen in Form von Variablen verarbeiten
5+
6+
##### Commandline
7+
8+
```bash
9+
# Yaml
10+
ansible all -m win_ping -i inventory.ini -e "myvar=test mysecond=var"
11+
# JSON - Dict/Array
12+
ansible all -m win_ping -i inventory.ini --extra-vars "[ { app: app1 }, { app: app2 } }"
13+
```
14+
15+
##### Playbook
16+
17+
Play und Tasks
18+
19+
##### Externe Dateien
20+
21+
YAML und JSON Files
22+
23+
##### Inventory
24+
25+
Statisch / Dynamisches Inventory(inventory_plugins) mit Gruppen oder Host Variablen (ansible_user, ansible_winrm_server_cert_validation)
26+
27+
##### Facts (Module: Setup)
28+
29+
##### Roles
30+
31+
32+
notes:
33+
- Variablen können von mehrern Sourcen Command
34+
- Meistens in
35+
- inventory group vars
36+
- Externe json/yaml Files
37+
- Facts
38+
</section>
39+
<section>
40+
<h2>Variablen Vorang</h2>
41+
<p>Wenn Variablen / Host für an verschiedenen Source vorhanden sind gilt folgende Order</p>
42+
<div class="columns">
43+
<div class="col">
44+
<ol>
45+
<li>extra vars</li>
46+
<li>task vars (only for the task)</li>
47+
<li>block vars (only for tasks in block)</li>
48+
<li><strong>role and include vars</strong></li>
49+
<li><strong>play vars_files</strong></li>
50+
<li><strong>play vars_prompt</strong></li>
51+
<li><strong>play vars</strong></li>
52+
<li>set_facts</li>
53+
</ol>
54+
</div>
55+
<div class="col">
56+
<ol start="9" class="col">
57+
<li>registered vars</li>
58+
<li>host facts</li>
59+
<li>playbook host_vars</li>
60+
<li>playbook group_vars</li>
61+
<li><strong>inventory host_vars</strong></li>
62+
<li><strong>inventory group_vars</strong></li>
63+
<li>inventory vars</li>
64+
<li><strong>role defaults</strong></li>
65+
</ol>
66+
</div>
67+
</div>
68+
<aside class="notes">
69+
<ul>
70+
<li>Variablen werden per Host zusammengefasst</li>
71+
<li>Mann sollte die quellen für variablen klein halten</li>
72+
<li>Wie wir die Variablen verwenden kommt noch</li>
73+
<li>Mal merken das es einen Order gibt</li>
74+
</ul>
75+
</aside>
76+
</section>

0 commit comments

Comments
 (0)