This commit is contained in:
2023-02-20 15:51:25 +01:00
parent 630afe52cd
commit 2c69e42135

View File

@@ -9,10 +9,10 @@
**Pratique:** Convertir les 4 commandes adhoc de l'atelier précédent en place en playbook, associées aux machines du groupe **cibles** :
```bash
ansible localhost -m openssh_keypair -a 'path=/home/formation/.ssh/id_rsa owner=formation group=formation' -u formation
ansible cibles -u formation -k -m user -a 'user=ansible password={{ "123Soleil!"| password_hash( "sha512", 65534 | random(seed=inventory_hostname) | string) }} create_home=yes home=/home/ansible'
ansible cibles -u formation -k -m copy -a 'dest=/etc/sudoers.d/ansible content="ansible ALL=(ALL) NOPASSWD: ALL" validate="/usr/sbin/visudo -cf %s"'
ansible cibles -u formation -k -m authorized_key -a 'key={{ lookup( "file", "~/.ssh/id_rsa.pub") }} user=ansible'
ansible localhost -m community.crypto.openssh_keypair -a 'path=/home/formation/.ssh/id_rsa owner=formation group=formation' -u formation
ansible cibles -m ansible.builtin.user -a 'user=ansible password={{ "123Soleil!"| password_hash( "sha512", 65534 | random(seed=inventory_hostname) | string) }} create_home=yes home=/home/ansible'
ansible cibles -m community.general.sudoers -a 'name="ansible" user=ansible commands=ALL nopassword=true'
ansible cibles -m ansible.posix.authorized_key -a 'key={{ lookup( "file", "~/.ssh/id_rsa.pub") }} user=ansible'
```
Rajouter 2 tâches: