solution blockinfile

This commit is contained in:
2022-10-31 14:04:44 +01:00
parent d0d005e782
commit 0a6c39884b

View File

@@ -87,4 +87,22 @@ ansible -i hosts -o -u root -m cron -a 'name="update starship" cron_file="stars
```bash
# avec distribution horaire aléatoire principe d'indempotence respecté
ansible -i hosts -o -u root -m cron -a 'name="update starship" cron_file="starship" hour="12" minute="{{ 59 | random(seed=inventory_hostname) }}" weekday="sun" job="sh /tmp/install.sh -y" user="root"'
```
```
## Rajouter des blocs de textes dans un fichier avec blockinfile
Rajouter dans ~/.ssh/config, sur la machine *pilote* les infos suivantes:
```bash
Host machinecible #cf variable inventory_hostname
User: formation
Port 22
```
```bash
ansible -oi localhost all -u formation -m blockinfile -a 'path=/home/formation//.ssh/config block="Host {{ inventory_hostname }}\n\tPort 22" create=true marker="# {mark} ssh config for {{ inventory_hostname }}"'
```
⚠️ on travaile sur *localhost*