Benoît Hubert 890a7f7c4c Playbook for initial setup 1 ano atrás
..
README.md 890a7f7c4c Playbook for initial setup 1 ano atrás
ansible.cfg c3468b8edb ma propre doc WIP 1 ano atrás
inventory.ini c3468b8edb ma propre doc WIP 1 ano atrás
playbook-initial-setup.yml 890a7f7c4c Playbook for initial setup 1 ano atrás
root-creds.yml 890a7f7c4c Playbook for initial setup 1 ano atrás

README.md

Setup initial Debian 12 avec Ansible

Contexte :

  • On vient d'installer une debian 12.5 sans rien.
  • On veut automatiser la création de comptes utilisateurs

Mes deux hosts sur le LAN sont :

  • debian-111 : 192.168.1.18
  • debian-112 : 192.168.1.85
  • debian-113 : 192.168.1.109

NOTE sur utilisation macOS comme control node

Voir ansible-macos-control-node/README.md.

On va utiliser une VM debian comme control node.

Setup control node Debian 12.5

Install Ansible

Mon control node est 192.168.1.181.

  • su - (pas encore installé sudo)
  • apt install gnupg curl
  • les commandes données dans la doc officielle pour l'install sur Debian ne marchent pas
  • curl -o ansible.gpg "https://keyserver.ubuntu.com/pks/lookup?fingerprint=on&op=get&search=0x6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367"
  • gpg --dearmour -o /usr/share/keyrings/ansible-archive-keyring.gpg ansible.gpg (toujours comme root)
  • echo "deb [signed-by=/usr/share/keyrings/ansible-archive-keyring.gpg] http://ppa.launchpad.net/ansible/ansible/ubuntu $UBUNTU_CODENAME main" | tee /etc/apt/sources.list.d/ansible.list
  • apt update
  • apt install -y ansible

MIEUX de tout faire en sudo je suppose. On va aussi installer etckeeper.

Install Git et clone repo...

... où j'ai ma config ansible.cfg et mon inventory.ini.

D'abord commandes ad-hoc pour tester

Ping

$ ansible -i ./inventory.ini all -m ping -u debian -k
SSH password: 
192.168.1.18 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}
192.168.1.85 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}
192.168.1.109 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}

setup

ansible -i ./inventory.ini all -m setup -k

Produit une énorme sortie.

Setup initial

sudo n'est pas installé sur les managed nodes.

On va essayer de tout config en utilisant un vault pour le password root.

$ ansible-vault create creds.yml

stocke dedans :

root_password: ******

Playbook playbook-initial-setup.yml.

Le jouer :

ansible-playbook playbook-initial-setup.yml -i inventory.ini all -k

Etapes

  • Création inventory.ini avec les deux hosts.
  • Création playbook qui va

    • créer des utilisateurs avec droits sudo