Skip to content
Snippets Groups Projects
README.md 2.99 KiB
Newer Older
timbastin's avatar
timbastin committed
# 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.