2024-02-11 18:21:54 +01:00
|
|
|
# Beispiel Ansible
|
|
|
|
|
2024-05-22 13:29:56 +02:00
|
|
|
## Erste schritte
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# Installiere ansible
|
|
|
|
apt update
|
|
|
|
apt install -y ansible
|
|
|
|
|
|
|
|
# Kopiere die "skeleton" rolle
|
|
|
|
cp -r roles/{skeleton,webserver}
|
|
|
|
|
|
|
|
# Editiere die inventory datei
|
|
|
|
$EDITOR inventory
|
|
|
|
```
|
|
|
|
|
|
|
|
Wenn die rolle kopiert ist, musst du sie in der `site.yml` noch importieren:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
- name: Import webserver role
|
|
|
|
hosts:
|
|
|
|
- all
|
|
|
|
roles:
|
|
|
|
- webserver
|
|
|
|
```
|
|
|
|
|
|
|
|
## Relevante befehle/tasks
|
|
|
|
|
|
|
|
### Rolle ausführen
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# Auf deinem Rechner
|
|
|
|
ansible-playbook site.yml
|
|
|
|
```
|
|
|
|
|
|
|
|
### Webserver neuladen
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# Auf dem Raspi
|
|
|
|
sudo nginx -s reload
|
|
|
|
```
|
|
|
|
|
|
|
|
(oder)
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
# In deiner Rolle
|
|
|
|
- name: Reload nginx
|
|
|
|
ansible.builtin.systemd_service:
|
|
|
|
name: nginx
|
|
|
|
state: reloaded
|
|
|
|
```
|
|
|
|
|
2024-05-22 12:04:48 +02:00
|
|
|
## TODO
|
2024-02-11 18:21:54 +01:00
|
|
|
|
2024-05-22 13:29:56 +02:00
|
|
|
- [ ] Installiere einen Webserver (apache/traefik/nginx/lighttpd)
|
|
|
|
- [ ] Serviere `files/index.html` (unter `/var/www/html/index.html` ablegen)
|
|
|
|
- [ ] Bonusaufgabe: aktiviere eine Password-Authentifizierung (Basic Auth)
|
|
|
|
|
|
|
|
## Relevante Dokumentation
|
|
|
|
|
|
|
|
- [Paket Installieren](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package_module.html)
|
|
|
|
- [Datei kopieren](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_module.html)
|
|
|
|
- [NGINX basic auth](https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/)
|