Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Praktikumsblatt 3 - Ansible
## Aufgabe 1
### a)
```
ansible 2.10.8
config file = None
configured module search path = ['/home/timbastin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /bin/ansible
python version = 3.10.4 (main, Apr 2 2022, 09:04:19) [GCC 11.2.0]
```
### b)
```
ansible localhost -m ping
```
> ping - Try to connect to host, verify a usable python and return pong on success.
Nein, das Kommando funktioniert nicht für den Remote-Server `serv-ss22`.
```
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: 2001:638:408:200:FE10::1
```
Ansible interpretiert "localhost" nicht als Adresse, sondern als Ansible hostname.
### c)
```
ansible -i hosts.yml netlab -m ping
> netlab | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
```
### e)
```yml
- hosts: all
connection: ssh
gather_facts: yes
tasks:
- name: who am i
become: false
command: whoami
register: username_on_the_host
- debug: var=username_on_the_host
```
```
ansible-playbook -i hosts.yml ./roles/whoami.yml
```
### f)
```yml
- hosts: all
connection: ssh
gather_facts: yes
tasks:
- name: conn-check
become: true
command: whoami
register: username_on_the_host
- debug: var=username_on_the_host
```
```
ansible-playbook -i hosts.yml ./roles/pb-remoteserver-1.yml -K
```
## Aufgabe 2
```yml
- hosts: all
connection: ssh
gather_facts: yes
tasks:
- name: conn-check
become: true
command: whoami
register: username_on_the_host
- debug: var=username_on_the_host
```
```
ansible-playbook -i hosts.yml ./roles/pb-remoteserver-1.yml -K
```
## Aufgabe 4
```
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:48:02 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.14
API version: 1.41 (minimum version 1.12)
Go version: go1.16.15
Git commit: 87a90dc
Built: Thu Mar 24 01:45:53 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.11
GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc:
Version: 1.0.3
GitCommit: v1.0.3-0-gf46b6ba
docker-init:
Version: 0.19.0
GitCommit: de40ad0
```
## Aufgabe 5
Das Sudo-Passwort kann mittels `-K` Flag während des Aufrufes der Playbooks übergeben werden. Dies stellt eine sehr sichere Variante für das Handling mit Passwörtern her.