Ansible

SSH Jump

Wie man das nativ in Ansible macht, muss ich nochmal rausfinden und dokumentieren... ist auf jeden Fall möglich. Als Cheatcode gehts easy über die .ssh/config

Host samosa samosa.mrvn.eu
        Hostname samosa.mrvn.eu
        User cyber
        Port 55116
        IdentityFile ~/.ssh/exthost02

Host runner
        Hostname runner.internal.samosa
        User morph
        ProxyJump samosa
        ForwardAgent yes
        IdentityFile ~/.ssh/exthost01

Roles aus Galaxy holen

requirements.yml erstellen, Daten rein. Dann installieren mit ansible-galaxy install -r requirements.yml

# Install a role from the Ansible Galaxy
- src: dfarrell07.opendaylight

# Install a role from GitHub
- name: opendaylight
  src: https://github.com/dfarrell07/ansible-opendaylight

# Install a role from a specific git branch
- name: opendaylight
  src: https://github.com/dfarrell07/ansible-opendaylight
  version: origin/master

# Install a role at a specific tag from GitHub
- name: opendaylight
  src: https://github.com/dfarrell07/ansible-opendaylight
  version: 1.0.0

# Install a role at a specific commit from GitHub
- name: opendaylight
  src: https://github.com/dfarrell07/ansible-opendaylight
  version: <commit hash>

Quelle: https://stackoverflow.com/questions/25230376/how-to-automatically-install-ansible-galaxy-roles

Befehl nur ausführen, wenn Datei (nicht) existiert

Geht mit creates:

- name: Initialize etckeeper repository
  shell: etckeeper init
  args:
      creates: /etc/.gitignore

umgekehrt mit removes.

Templates

Irgendwas templaten, wenn es definiert ist, aber nicht, wenn nicht: {{ additional_nginx_options | default("") }}