Beide Seiten der vorigen Revision Vorhergehende Überarbeitung | |
linux:ansible:playbook_example_08 [01.06.2024 13:46. ] – [Script Beschreibung] django | linux:ansible:playbook_example_08 [01.06.2024 13:48. ] (aktuell) – [Script starten] django |
---|
Das Ansible-Playbook lässt sich wie folgt auf dem Ansible-Controll-Host bzw. der Admin-Workstation aufrufen: | Das Ansible-Playbook lässt sich wie folgt auf dem Ansible-Controll-Host bzw. der Admin-Workstation aufrufen: |
| |
$ ansible-playbook ~/ansible/playbooks/ansible_grundconfig_v2.yml -K | $ ansible-playbook ~/devel/ansible/playbooks/ansible_grundconfig_v2.yml -K |
| |
<html> | |
<pre class="code"> | |
<font style="color: rgb(0, 0, 0)">BECOME password: </font> | |
<font style="color: rgb(170, 127, 166)"><b>[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'</b></font> | |
<font style="color: rgb(0, 0, 0)">Enter password for password-store?: | |
Retype password for password-store?: | |
Enter become-password for sudo?: | |
Retype become-password for sudo?: | |
| |
PLAY [ansible_grundconfig_v2.yml] ************************************************************************************************* | |
| |
TASK [Gathering Facts] ************************************************************************************************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Playbooklauf abbrechen sofern die beiden eigegebenen Passwörter nicht übereinstimmen!] **************************************</font> | |
<font style="color: rgb(43, 100, 164)">skipping: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Playbooklauf abbrechen sofern die beiden eigegebenen Passwörter nicht übereinstimmen!] **************************************</font> | |
<font style="color: rgb(43, 100, 164)">skipping: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Ansible Konfigurationsdatei /etc/ansible/ansible.cfg vorhanden?] ************************************************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Fehlerhinweis im Fehlerfall ausgeben] ***************************************************************************************</font> | |
<font style="color: rgb(43, 100, 164)">skipping: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Ansible Konfigurationsverzeichnis in das User/Admin-Verzeichnis kopieren] ***************************************************</font> | |
<font style="color: rgb(196, 160, 0)">changed: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Ansible Konfiguration anpassen] *********************************************************************************************</font> | |
<font style="color: rgb(196, 160, 0)">changed: [localhost] => (item={'regexp': '^\\[defaults\\]', 'line': '[defaults]\n# Generated by Ansible on 2022-09-22, do not edit manually!\n# default:\ninterpreter_python = auto_silent'}) | |
changed: [localhost] => (item={'regexp': '^\\#inventory = /etc/ansible/hosts', 'line': '# Generated by Ansible on 2022-09-22, do not edit manually!\n# default: #inventory = /etc/ansible/hosts\ninventory = /home/django/ansible/inventories/production'}) | |
changed: [localhost] => (item={'regexp': '^\\#roles_path = /etc/ansible/roles', 'line': '# Generated by Ansible on 2022-09-22, do not edit manually!\n# default: #roles_path = /etc/ansible/roles\nroles_path = ~/ansible/roles'}) | |
changed: [localhost] => (item={'regexp': '^\\#vault_password_file = /path/to/vault_password_file', 'line': '# Generated by Ansible on 2022-09-22, do not edit manually!\n# default: #vault_password_file = /path/to/vault_password_file\nvault_password_file = ~/bin/ansible_vault_password'})</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Ansible Directory Layout anlegen] *******************************************************************************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost] => (item={'directory': 'filter_plugins/'}) | |
ok: [localhost] => (item={'directory': 'library/'}) | |
ok: [localhost] => (item={'directory': 'module_utils/'}) | |
ok: [localhost] => (item={'directory': 'playbooks/'}) | |
ok: [localhost] => (item={'directory': 'inventories/production/group_vars/'}) | |
ok: [localhost] => (item={'directory': 'inventories/production/host_vars/'}) | |
ok: [localhost] => (item={'directory': 'inventories/staging/group_vars/'}) | |
ok: [localhost] => (item={'directory': 'inventories/staging/host_vars/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/defaults/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/files/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/handlers/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/library/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/lookup_plugins/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/meta/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/module_utils/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/tasks/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/templates/'}) | |
ok: [localhost] => (item={'directory': 'roles/common/vars/'})</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Ansible Directory Layout mit dummy-files main.yml befüllen] ***************************************************************</font> | |
<font style="color: rgb(196, 160, 0)">changed: [localhost] => (item={'file': 'filter_plugins/main.yml'}) | |
changed: [localhost] => (item={'file': 'library/main.yml'}) | |
changed: [localhost] => (item={'file': 'module_utils/main.yml'}) | |
changed: [localhost] => (item={'file': 'inventories/production/hosts'}) | |
changed: [localhost] => (item={'file': 'inventories/production/group_vars/main.yml'}) | |
changed: [localhost] => (item={'file': 'inventories/production/host_vars/main.yml'}) | |
changed: [localhost] => (item={'file': 'inventories/staging/hosts'}) | |
changed: [localhost] => (item={'file': 'inventories/staging/group_vars/main.yml'}) | |
changed: [localhost] => (item={'file': 'inventories/staging/host_vars/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/defaults/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/files/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/handlers/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/library/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/lookup_plugins/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/meta/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/module_utils/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/tasks/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/templates/main.yml'}) | |
changed: [localhost] => (item={'file': 'roles/common/vars/main.yml'})</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Passwort-Manager pass installieren] ***********************************************************************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Verzeichnis ~/bin anlegen] ********************************************************************************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [vault-Wrapperscript anlegen] ******************************************************************************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Sicherstellen dass das pass Store-Verzeichnis nicht existiert] ********************************************************</font> | |
<font style="color: rgb(196, 160, 0)">changed: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Pass-Store Passwort ablegen] ******************************************************************************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Sicherstellen dass das File für das verschlüsselte become-password noch nicht existiert] ******************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Ansible Become Password für sudo Rechteerweiterung anlegen] ***********************************************************</font> | |
<font style="color: rgb(196, 160, 0)">changed: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Ansible Become Password mit ansible-vault verschlüsseln] **************************************************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Sicherstellen dass das File mit der Ansible-Konfiguration nicht existiert] ********************************************</font> | |
<font style="color: rgb(25, 100, 5)">ok: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
TASK [Ansible Konfigurationsdatei mit den Definitionen zu privilege_escalation anlegen] *************************************</font> | |
<font style="color: rgb(196, 160, 0)">changed: [localhost]</font> | |
<font style="color: rgb(0, 0, 0)"> | |
PLAY RECAP ********************************************************************************************************************</font> | |
<font style="color: rgb(196, 160, 0)">localhost</font><font style="color: rgb(0, 0, 0)"> : </font><font style="color: rgb(25, 100, 5)">ok=16 </font><font style="color: rgb(196, 160, 0)">changed=6 </font><font style="color: rgb(0, 0, 0)">unreachable=0 failed=0 </font><font style="color: rgb(43, 100, 164)">skipped=3 </font><font style="color: rgb(0, 0, 0)">rescued=0 ignored=0</font> | |
| |
</pre> | |
</html> | |
| |
{{ :linux:ansible:ansible-krypto-stick.png?nolink&200|Bild: Ansible NitroKey Start}}Beim Aufruf eines Ansible-Playbooks liest das Programm **''ansible-playbook''** alle benötigten Dateien ein. Zum Abarbeiten benötigt Ansible natürlich die temporär entschlüsselten Informationen. Damit Ansible nun die verschlüsselten Informationen herankommt, benötigt Ansible natürlich vorübergehend das Vault-Passwort/-Passphrase, welches sich nun selbst verschlüsselt in einem Ansible-Vault befindet. Durch den Passwortmanager **''pass''** und unserem PGP-Schlüssel kommen wir nun direkt zu dem **Ansible Vault Passwort**. Wir brauchen also nur einmal das für den PGP zugehörige Passwort oder im Falle der Verwendung eines Security-Hardware-Devices wie eines **[[https://shop.nitrokey.com/de_DE/shop/product/nksa-nitrokey-start-6|Nitrokey Start]]**. | {{ :linux:ansible:ansible-krypto-stick.png?nolink&200|Bild: Ansible NitroKey Start}}Beim Aufruf eines Ansible-Playbooks liest das Programm **''ansible-playbook''** alle benötigten Dateien ein. Zum Abarbeiten benötigt Ansible natürlich die temporär entschlüsselten Informationen. Damit Ansible nun die verschlüsselten Informationen herankommt, benötigt Ansible natürlich vorübergehend das Vault-Passwort/-Passphrase, welches sich nun selbst verschlüsselt in einem Ansible-Vault befindet. Durch den Passwortmanager **''pass''** und unserem PGP-Schlüssel kommen wir nun direkt zu dem **Ansible Vault Passwort**. Wir brauchen also nur einmal das für den PGP zugehörige Passwort oder im Falle der Verwendung eines Security-Hardware-Devices wie eines **[[https://shop.nitrokey.com/de_DE/shop/product/nksa-nitrokey-start-6|Nitrokey Start]]**. |