Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| elearning:workbooks:debian:6:avance:l130:part2 [2021/12/29 10:30] – admin | elearning:workbooks:debian:6:avance:l130:part2 [2023/08/25 01:28] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~PDF: | ~~PDF: | ||
| - | Version : **2022.01** | + | Version : **2023.02** |
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| - | ====== | + | ====== |
| =====Contenu du Module===== | =====Contenu du Module===== | ||
| - | * **DOF502 | + | * **LCF802 |
| * Contenu du Module | * Contenu du Module | ||
| * LAB #1 - Débuter avec Ansible | * LAB #1 - Débuter avec Ansible | ||
| Ligne 35: | Ligne 35: | ||
| < | < | ||
| - | trainee@ansible:~$ ansible all -i 10.0.2.52, -m ping | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host 10.0.2.52 should use / | + | |
| - | with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| 10.0.2.52 | SUCCESS => { | 10.0.2.52 | SUCCESS => { | ||
| " | " | ||
| Ligne 51: | Ligne 45: | ||
| </ | </ | ||
| - | <WRAP center round important | + | <WRAP center round important> |
| **Important** : Cette commande indique à Ansible qu' | **Important** : Cette commande indique à Ansible qu' | ||
| </ | </ | ||
| Ligne 58: | Ligne 52: | ||
| < | < | ||
| - | trainee@ansible:~$ ansible --help | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| usage: ansible [-h] [--version] [-v] [-b] [--become-method BECOME_METHOD] | usage: ansible [-h] [--version] [-v] [-b] [--become-method BECOME_METHOD] | ||
| | | ||
| Ligne 73: | Ligne 65: | ||
| | | ||
| [-f FORKS] [-M MODULE_PATH] [--playbook-dir BASEDIR] | [-f FORKS] [-M MODULE_PATH] [--playbook-dir BASEDIR] | ||
| - | [-a MODULE_ARGS] [-m MODULE_NAME] | + | [--task-timeout TASK_TIMEOUT] |
| | | ||
| Ligne 93: | Ligne 85: | ||
| --syntax-check | --syntax-check | ||
| execute it | execute it | ||
| + | --task-timeout TASK_TIMEOUT | ||
| + | set task timeout limit in seconds, must be positive | ||
| + | integer. | ||
| --vault-id VAULT_IDS | --vault-id VAULT_IDS | ||
| --vault-password-file VAULT_PASSWORD_FILES, | --vault-password-file VAULT_PASSWORD_FILES, | ||
| Ligne 113: | Ligne 108: | ||
| set the poll interval if using -B (default=15) | set the poll interval if using -B (default=15) | ||
| -a MODULE_ARGS, | -a MODULE_ARGS, | ||
| - | | + | |
| + | ' | ||
| -e EXTRA_VARS, --extra-vars EXTRA_VARS | -e EXTRA_VARS, --extra-vars EXTRA_VARS | ||
| set additional variables as key=value or YAML/JSON, if | set additional variables as key=value or YAML/JSON, if | ||
| Ligne 127: | Ligne 123: | ||
| further limit selected hosts to an additional pattern | further limit selected hosts to an additional pattern | ||
| -m MODULE_NAME, | -m MODULE_NAME, | ||
| - | | + | |
| -o, --one-line | -o, --one-line | ||
| -t TREE, --tree TREE log output to this directory | -t TREE, --tree TREE log output to this directory | ||
| Ligne 170: | Ligne 166: | ||
| connect as this user (default=None) | connect as this user (default=None) | ||
| - | Some modules | + | Some actions |
| </ | </ | ||
| - | Les quatre machines | + | Les quatre machines **WebXX** mises à votre disposition sont dans le même réseau que la machine |
| ^ Machine ^ Nom d' | ^ Machine ^ Nom d' | ||
| Ligne 184: | Ligne 180: | ||
| < | < | ||
| - | trainee@ansible:~$ scp .ssh/ | + | [trainee@centos8 |
| - | The authenticity of host 'web01.i2tch.loc (10.0.2.54)' | + | The authenticity of host '10.0.2.54 (10.0.2.54)' |
| ECDSA key fingerprint is SHA256: | ECDSA key fingerprint is SHA256: | ||
| - | Are you sure you want to continue connecting (yes/no)? yes | + | Are you sure you want to continue connecting (yes/no/ |
| - | Warning: Permanently added 'web01.i2tch.loc, | + | Warning: Permanently added ' |
| Debian GNU/Linux 9 | Debian GNU/Linux 9 | ||
| - | trainee@web01.i2tch.loc's password: | + | trainee@10.0.2.54's password: |
| - | authorized_keys | + | authorized_keys |
| - | trainee@ansible:~$ scp .ssh/ | + | |
| - | The authenticity of host 'web02.i2tch.loc (10.0.2.55)' | + | [trainee@centos8 |
| + | The authenticity of host '10.0.2.55 (10.0.2.55)' | ||
| ECDSA key fingerprint is SHA256: | ECDSA key fingerprint is SHA256: | ||
| - | Are you sure you want to continue connecting (yes/no)? yes | + | Are you sure you want to continue connecting (yes/no/ |
| - | Warning: Permanently added 'web02.i2tch.loc, | + | Warning: Permanently added ' |
| Debian GNU/Linux 9 | Debian GNU/Linux 9 | ||
| - | trainee@web02.i2tch.loc's password: | + | trainee@10.0.2.55's password: |
| - | authorized_keys | + | authorized_keys |
| - | trainee@ansible:~$ scp .ssh/ | + | |
| - | The authenticity of host 'web03.i2tch.loc (10.0.2.56)' | + | [trainee@centos8 |
| + | The authenticity of host '10.0.2.56 (10.0.2.56)' | ||
| ECDSA key fingerprint is SHA256: | ECDSA key fingerprint is SHA256: | ||
| - | Are you sure you want to continue connecting (yes/no)? yes | + | Are you sure you want to continue connecting (yes/no/ |
| - | Warning: Permanently added 'web03.i2tch.loc, | + | Warning: Permanently added ' |
| Debian GNU/Linux 9 | Debian GNU/Linux 9 | ||
| - | trainee@web03.i2tch.loc's password: | + | trainee@10.0.2.56's password: |
| - | authorized_keys | + | authorized_keys |
| - | trainee@ansible:~$ scp .ssh/ | + | |
| - | The authenticity of host 'web04.i2tch.loc (10.0.2.57)' | + | [trainee@centos8 |
| + | The authenticity of host '10.0.2.57 (10.0.2.57)' | ||
| ECDSA key fingerprint is SHA256: | ECDSA key fingerprint is SHA256: | ||
| - | Are you sure you want to continue connecting (yes/no)? yes | + | Are you sure you want to continue connecting (yes/no/ |
| - | Warning: Permanently added 'web04.i2tch.loc, | + | Warning: Permanently added ' |
| Debian GNU/Linux 9 | Debian GNU/Linux 9 | ||
| - | trainee@web04.i2tch.loc's password: | + | trainee@10.0.2.57's password: |
| - | authorized_keys | + | authorized_keys |
| </ | </ | ||
| - | Vérifiez que vous pouvez vous connecter aux machines virtuelles | + | Modifier le fichier |
| < | < | ||
| - | trainee@ansible:~$ ssh -l trainee web01 | + | [trainee@centos8 |
| - | The authenticity of host 'web01 (10.0.2.54)' can't be established. | + | Password: fenestros |
| - | ECDSA key fingerprint is SHA256: | + | [root@centos8 ~]# vi / |
| - | Are you sure you want to continue connecting (yes/no)? yes | + | [root@centos8 ~]# cat / |
| - | Warning: Permanently added 'web01' (ECDSA) to the list of known hosts. | + | 127.0.0.1 |
| + | ::1 | ||
| + | 10.0.2.45 centos8.ittraining.loc centos8 | ||
| + | 10.0.2.54 | ||
| + | 10.0.2.55 web02.i2tch.loc web02 | ||
| + | 10.0.2.56 web03.i2tch.loc web03 | ||
| + | 10.0.2.57 web04.i2tch.loc web04 | ||
| + | [root@centos8 ~]# exit | ||
| + | logout | ||
| + | [trainee@centos8 ~]$ | ||
| + | </code> | ||
| + | |||
| + | Vérifiez que vous pouvez vous connecter aux machines virtuelles **Web01**, **Web02**, **Web03** et **Web04** sans entrer de mot de passe et que la configuration de sudo est correcte | ||
| + | |||
| + | < | ||
| + | [trainee@centos8 ~]$ ssh -l trainee | ||
| Debian GNU/Linux 9 | Debian GNU/Linux 9 | ||
| Linux web01.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | Linux web01.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | ||
| Ligne 235: | Ligne 249: | ||
| Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | ||
| permitted by applicable law. | permitted by applicable law. | ||
| - | Last login: | + | Last login: |
| + | trainee@web01: | ||
| + | Réception de:1 http:// | ||
| + | Ign:2 http:// | ||
| + | Réception de:3 http:// | ||
| + | Réception de:4 http:// | ||
| + | Réception de:5 http:// | ||
| + | Réception de:6 http:// | ||
| + | Réception de:7 http:// | ||
| + | Réception de:8 http:// | ||
| + | Réception de:9 http:// | ||
| + | Réception de:10 http:// | ||
| + | Réception de:11 http:// | ||
| + | 21,0 Mo réceptionnés en 32s (638 ko/s) | ||
| + | Lecture des listes de paquets... Fait | ||
| + | Construction de l' | ||
| + | Lecture des informations d' | ||
| + | 341 packages can be upgraded. Run 'apt list --upgradable' | ||
| trainee@web01: | trainee@web01: | ||
| déconnexion | déconnexion | ||
| Connection to web01 closed. | Connection to web01 closed. | ||
| - | trainee@ansible:~$ ssh -l trainee web02 | + | [trainee@centos8 |
| - | The authenticity of host 'web02 (10.0.2.55)' | + | |
| - | ECDSA key fingerprint is SHA256: | + | |
| - | Are you sure you want to continue connecting (yes/no)? yes | + | |
| - | Warning: Permanently added ' | + | |
| Debian GNU/Linux 9 | Debian GNU/Linux 9 | ||
| Linux web02.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | Linux web02.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | ||
| Ligne 253: | Ligne 280: | ||
| Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | ||
| permitted by applicable law. | permitted by applicable law. | ||
| - | Last login: | + | Last login: |
| + | trainee@web02: | ||
| + | Réception de:1 http:// | ||
| + | Ign:2 http:// | ||
| + | Réception de:3 http:// | ||
| + | Réception de:4 http:// | ||
| + | Réception de:5 http:// | ||
| + | Réception de:6 http:// | ||
| + | Réception de:7 http:// | ||
| + | Réception de:8 http:// | ||
| + | Réception de:9 http:// | ||
| + | Réception de:10 http:// | ||
| + | Réception de:11 http:// | ||
| + | 21,0 Mo réceptionnés en 32s (639 ko/s) | ||
| + | Lecture des listes de paquets... Fait | ||
| + | Construction de l' | ||
| + | Lecture des informations d' | ||
| + | 341 packages can be upgraded. Run 'apt list --upgradable' | ||
| trainee@web02: | trainee@web02: | ||
| déconnexion | déconnexion | ||
| Connection to web02 closed. | Connection to web02 closed. | ||
| - | trainee@ansible:~$ ssh -l trainee web03 | + | [trainee@centos8 |
| - | The authenticity of host 'web03 (10.0.2.56)' | + | |
| - | ECDSA key fingerprint is SHA256: | + | |
| - | Are you sure you want to continue connecting (yes/no)? yes | + | |
| - | Warning: Permanently added ' | + | |
| Debian GNU/Linux 9 | Debian GNU/Linux 9 | ||
| Linux web03.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | Linux web03.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | ||
| Ligne 271: | Ligne 311: | ||
| Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | ||
| permitted by applicable law. | permitted by applicable law. | ||
| - | Last login: | + | Last login: |
| + | trainee@web03: | ||
| + | Réception de:1 http:// | ||
| + | Ign:2 http:// | ||
| + | Réception de:3 http:// | ||
| + | Réception de:4 http:// | ||
| + | Réception de:5 http:// | ||
| + | Réception de:6 http:// | ||
| + | Réception de:7 http:// | ||
| + | Réception de:8 http:// | ||
| + | Réception de:9 http:// | ||
| + | Réception de:10 http:// | ||
| + | Réception de:11 http:// | ||
| + | 21,0 Mo réceptionnés en 40s (524 ko/s) | ||
| + | Lecture des listes de paquets... Fait | ||
| + | Construction de l' | ||
| + | Lecture des informations d' | ||
| + | 341 packages can be upgraded. Run 'apt list --upgradable' | ||
| trainee@web03: | trainee@web03: | ||
| déconnexion | déconnexion | ||
| Connection to web03 closed. | Connection to web03 closed. | ||
| - | trainee@ansible:~$ ssh -l trainee web04 | + | [trainee@centos8 |
| - | The authenticity of host 'web04 (10.0.2.57)' | + | |
| - | ECDSA key fingerprint is SHA256: | + | |
| - | Are you sure you want to continue connecting (yes/no)? yes | + | |
| - | Warning: Permanently added ' | + | |
| Debian GNU/Linux 9 | Debian GNU/Linux 9 | ||
| Linux web04.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | Linux web04.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | ||
| Ligne 289: | Ligne 342: | ||
| Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | ||
| permitted by applicable law. | permitted by applicable law. | ||
| - | Last login: | + | Last login: |
| + | trainee@web04: | ||
| + | Réception de:1 http:// | ||
| + | Ign:2 http:// | ||
| + | Réception de:3 http:// | ||
| + | Réception de:4 http:// | ||
| + | Réception de:5 http:// | ||
| + | Réception de:6 http:// | ||
| + | Réception de:7 http:// | ||
| + | Réception de:8 http:// | ||
| + | Réception de:9 http:// | ||
| + | Réception de:10 http:// | ||
| + | Réception de:11 http:// | ||
| + | 21,0 Mo réceptionnés en 39s (535 ko/s) | ||
| + | Lecture des listes de paquets... Fait | ||
| + | Construction de l' | ||
| + | Lecture des informations d' | ||
| + | 341 packages can be upgraded. Run 'apt list --upgradable' | ||
| trainee@web04: | trainee@web04: | ||
| déconnexion | déconnexion | ||
| Connection to web04 closed. | Connection to web04 closed. | ||
| + | [trainee@centos8 ~]$ | ||
| </ | </ | ||
| - | Utilisez ensuite la commende | + | Utilisez ensuite la commande |
| < | < | ||
| - | trainee@ansible:~$ ansible all -i web01, -m ping | + | [trainee@centos8 |
| - | / | + | 10.0.2.54 | SUCCESS => { |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web01 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | web01 | SUCCESS => { | + | |
| " | " | ||
| " | " | ||
| Ligne 312: | Ligne 377: | ||
| " | " | ||
| } | } | ||
| - | trainee@ansible:~$ ansible all -i web02, -m ping | + | [trainee@centos8 |
| - | / | + | 10.0.2.55 | SUCCESS => { |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web02 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | web02 | SUCCESS => { | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | trainee@ansible: | + | |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web03 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | web03 | SUCCESS => { | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | trainee@ansible: | + | |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | web04 | SUCCESS => { | + | |
| " | " | ||
| " | " | ||
| Ligne 359: | Ligne 390: | ||
| < | < | ||
| - | trainee@ansible:~$ ansible all -i web01, | + | [trainee@centos8 |
| - | / | + | web02 | SUCCESS => { |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web03 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | web03 | SUCCESS => { | + | |
| " | " | ||
| " | " | ||
| Ligne 373: | Ligne 398: | ||
| " | " | ||
| } | } | ||
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web01 should use / | ||
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | ||
| - | https:// | ||
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | ||
| web01 | SUCCESS => { | web01 | SUCCESS => { | ||
| " | " | ||
| Ligne 384: | Ligne 405: | ||
| " | " | ||
| } | } | ||
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | + | web03 | SUCCESS => { |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | web04 | SUCCESS => { | + | |
| " | " | ||
| " | " | ||
| Ligne 395: | Ligne 412: | ||
| " | " | ||
| } | } | ||
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web02 should use / | + | web04 | SUCCESS => { |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | web02 | SUCCESS => { | + | |
| " | " | ||
| " | " | ||
| Ligne 408: | Ligne 421: | ||
| </ | </ | ||
| - | <WRAP center round important | + | <WRAP center round important> |
| **Important** : Notez que les résultats ne sont pas retournés dans un ordre séquentiel par rapport à la commande exécutée. En effet, ansible a paralléliser l' | **Important** : Notez que les résultats ne sont pas retournés dans un ordre séquentiel par rapport à la commande exécutée. En effet, ansible a paralléliser l' | ||
| </ | </ | ||
| Ligne 415: | Ligne 428: | ||
| < | < | ||
| - | trainee@ansible:~$ ansible all -i web01, | + | [trainee@centos8 |
| - | / | + | web02 | CHANGED | rc=0 >> |
| - | from cryptography.exceptions import InvalidSignature | + | 11:40:49 up 18:26, 1 user, load average: 0,24, 0,11, 0,03 |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web03 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| web03 | CHANGED | rc=0 >> | web03 | CHANGED | rc=0 >> | ||
| - | 11:59:28 up 1:03, 1 user, load average: 0,04, 0,01, 0,00 | + | 11:40:49 up 18:26, 1 user, load average: 0,10, 0,03, 0,01 |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web01 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| web01 | CHANGED | rc=0 >> | web01 | CHANGED | rc=0 >> | ||
| - | 11:59:28 up 1:03, 1 user, load average: 0,00, 0,00, 0,00 | + | 11:40:49 up 18:26, 1 user, load average: 0,00, 0,00, 0,00 |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web02 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | web02 | CHANGED | rc=0 >> | + | |
| - | | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| web04 | CHANGED | rc=0 >> | web04 | CHANGED | rc=0 >> | ||
| - | 11:59:28 up 1:02, 1 user, load average: 0,00, 0,00, 0,00 | + | 11:40:49 up 18:26, 1 user, load average: 0,00, 0,00, 0,00 |
| </ | </ | ||
| - | |||
| - | Exécutez ensuite une commande pour installer **apache2** dans les machines web01, web02, web03 et web04 en utilisant le module **command**. Vous devez voire la confirmation que le paquet a déjà été installé - **apache2 is already the newest version** : | ||
| - | |||
| - | < | ||
| - | trainee@ansible: | ||
| - | / | ||
| - | from cryptography.exceptions import InvalidSignature | ||
| - | [WARNING]: Consider using ' | ||
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | ||
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | ||
| - | https:// | ||
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | ||
| - | web04 | CHANGED | rc=0 >> | ||
| - | Lecture des listes de paquets… | ||
| - | Construction de l' | ||
| - | Lecture des informations d' | ||
| - | apache2 is already the newest version (2.4.25-3+deb9u6). | ||
| - | 0 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour. | ||
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web03 should use / | ||
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | ||
| - | https:// | ||
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | ||
| - | web03 | CHANGED | rc=0 >> | ||
| - | Lecture des listes de paquets… | ||
| - | Construction de l' | ||
| - | Lecture des informations d' | ||
| - | apache2 is already the newest version (2.4.25-3+deb9u6). | ||
| - | 0 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour. | ||
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web02 should use / | ||
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | ||
| - | https:// | ||
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | ||
| - | web02 | CHANGED | rc=0 >> | ||
| - | Lecture des listes de paquets… | ||
| - | Construction de l' | ||
| - | Lecture des informations d' | ||
| - | apache2 is already the newest version (2.4.25-3+deb9u6). | ||
| - | 0 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour. | ||
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web01 should use / | ||
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | ||
| - | https:// | ||
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | ||
| - | web01 | CHANGED | rc=0 >> | ||
| - | Lecture des listes de paquets… | ||
| - | Construction de l' | ||
| - | Lecture des informations d' | ||
| - | apache2 is already the newest version (2.4.25-3+deb9u6). | ||
| - | 0 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour. | ||
| - | </ | ||
| - | |||
| - | <WRAP center round important 60%> | ||
| - | **Important** : Notez l' | ||
| - | </ | ||
| =====LAB #2 - La Commande ansible-playbook===== | =====LAB #2 - La Commande ansible-playbook===== | ||
| Ligne 504: | Ligne 446: | ||
| Un Playbook File contient une liste de **Plays** qui regroupent des tâches, appelées des **tasks**. Chaque task est une commande à exécuter sur une machine cible : | Un Playbook File contient une liste de **Plays** qui regroupent des tâches, appelées des **tasks**. Chaque task est une commande à exécuter sur une machine cible : | ||
| + | |||
| + | {{ : | ||
| {{ : | {{ : | ||
| + | |||
| + | {{ : | ||
| Dans l' | Dans l' | ||
| Ligne 594: | Ligne 540: | ||
| * Dans le cas contraire, le handler n'est pas appelé. | * Dans le cas contraire, le handler n'est pas appelé. | ||
| - | <WRAP center round important | + | <WRAP center round important> |
| **Important** : Notez que les handlers sont appelés **après** l' | **Important** : Notez que les handlers sont appelés **après** l' | ||
| </ | </ | ||
| Ligne 778: | Ligne 724: | ||
| Dans cet exemple, la valeur du mot clef **hosts:** est le nom d'un groupe. | Dans cet exemple, la valeur du mot clef **hosts:** est le nom d'un groupe. | ||
| - | <WRAP center round important | + | <WRAP center round important> |
| **Important** : Notez qu'il existe un groupe spécial appelé **all**. Ce groupe n'a pas besoin d' | **Important** : Notez qu'il existe un groupe spécial appelé **all**. Ce groupe n'a pas besoin d' | ||
| </ | </ | ||
| - | Dans la machine virtuelle | + | Dans la machine virtuelle |
| < | < | ||
| - | trainee@ansible:~$ vi inventory | + | [trainee@centos8 |
| - | trainee@ansible:~$ cat inventory | + | [trainee@centos8 |
| [basededonnees] | [basededonnees] | ||
| web01 | web01 | ||
| Ligne 809: | Ligne 755: | ||
| < | < | ||
| - | trainee@ansible:~$ vi playbook.yaml | + | [trainee@centos8 |
| - | trainee@ansible:~$ cat playbook.yaml | + | [trainee@centos8 |
| - | --- | + | |
| - | - hosts: basededonnees | + | |
| - | become: true | + | |
| - | tasks: | + | |
| - | - name: install | + | |
| - | package: name=postgresql state=installed | + | |
| - | - name: service | + | |
| - | service: name=postgresql state=started enabled=yes | + | |
| - | tags: service | + | |
| - | - hosts: dotcms | + | |
| - | become: true | + | |
| - | tasks: | + | |
| - | - name: install jre | + | |
| - | package: name=openjdk-8-jre state=installed | + | |
| - | - hosts: equilibrage | + | |
| - | become: true | + | |
| - | tasks: | + | |
| - | - name: install | + | |
| - | package: name=haproxy stated=installed | + | |
| - | - name: service | + | |
| - | service: name=haproxy state=started enabled=yes | + | |
| - | tags: service | + | |
| - | </ | + | |
| - | + | ||
| - | Exécutez la commande **ansible-playbook** : | + | |
| - | + | ||
| - | < | + | |
| - | trainee@ansible: | + | |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | + | ||
| - | PLAY [basededonnees] *********************************************************************************************************************************** | + | |
| - | + | ||
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web01 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | ok: [web01] | + | |
| - | + | ||
| - | TASK [install] ***************************************************************************************************************************************** | + | |
| - | fatal: [web01]: FAILED! => {" | + | |
| - | + | ||
| - | PLAY RECAP ********************************************************************************************************************************************* | + | |
| - | web01 : ok=1 changed=0 | + | |
| - | </ | + | |
| - | + | ||
| - | <WRAP center round important 60%> | + | |
| - | **Important** : Notez l' | + | |
| - | </ | + | |
| - | + | ||
| - | En consultant le fichier playbook.yaml, | + | |
| - | + | ||
| - | < | + | |
| - | trainee@ansible: | + | |
| - | | + | |
| - | 2 - hosts: basededonnees | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | 10 - hosts: dotcms | + | |
| - | 11 become: true | + | |
| - | 12 tasks: | + | |
| - | 13 - name: install jre | + | |
| - | 14 package: name=openjdk-8-jre state=installed | + | |
| - | 15 - hosts: equilibrage | + | |
| - | 16 become: true | + | |
| - | 17 tasks: | + | |
| - | 18 - name: install | + | |
| - | 19 package: name=haproxy stated=installed | + | |
| - | 20 - name: service | + | |
| - | 21 service: name=haproxy state=started enabled=yes | + | |
| - | 22 tags: service | + | |
| - | </ | + | |
| - | + | ||
| - | Corrigez le fichier playbook.yaml aux lignes **6**, **14** et **19** et remplacez le mot **installed** par **present** : | + | |
| - | + | ||
| - | < | + | |
| - | trainee@ansible: | + | |
| - | trainee@ansible: | + | |
| --- | --- | ||
| - hosts: basededonnees | - hosts: basededonnees | ||
| Ligne 913: | Ligne 775: | ||
| tasks: | tasks: | ||
| - name: install | - name: install | ||
| - | package: name=haproxy | + | package: name=haproxy |
| - name: service | - name: service | ||
| service: name=haproxy state=started enabled=yes | service: name=haproxy state=started enabled=yes | ||
| Ligne 919: | Ligne 781: | ||
| </ | </ | ||
| - | Ré-exécutez | + | Exécutez |
| < | < | ||
| - | trainee@ansible:~$ ansible-playbook -i inventory playbook.yaml | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | PLAY [basededonnees] *********************************************************************************************************************************** | + | PLAY [basededonnees] |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web01 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web01] | ok: [web01] | ||
| - | TASK [install] ***************************************************************************************************************************************** | + | TASK [install] *************************************************************************************************************************************************************************************************** |
| - | [WARNING]: Updating cache and auto-installing missing dependency: python-apt | + | |
| changed: [web01] | changed: [web01] | ||
| - | TASK [service] ***************************************************************************************************************************************** | + | TASK [service] |
| ok: [web01] | ok: [web01] | ||
| - | PLAY [dotcms] ****************************************************************************************************************************************** | + | PLAY [dotcms] **************************************************************************************************************************************************************************************************** |
| - | + | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web03 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | ok: [web03] | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web02 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web02] | ok: [web02] | ||
| - | |||
| - | TASK [install jre] ************************************************************************************************************************************* | ||
| ok: [web03] | ok: [web03] | ||
| - | ok: [web02] | ||
| - | PLAY [equilibrage] ************************************************************************************************************************************* | + | TASK [install jre] *********************************************************************************************************************************************************************************************** |
| - | + | ||
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | ok: [web04] | + | |
| - | + | ||
| - | TASK [install] ***************************************************************************************************************************************** | + | |
| - | fatal: [web04]: FAILED! => {" | + | |
| - | + | ||
| - | PLAY RECAP ********************************************************************************************************************************************* | + | |
| - | web01 : ok=3 changed=1 | + | |
| - | web02 : ok=2 changed=0 | + | |
| - | web03 : ok=2 changed=0 | + | |
| - | web04 : ok=1 changed=0 | + | |
| - | </ | + | |
| - | + | ||
| - | <WRAP center round important 60%> | + | |
| - | **Important** : Notez l' | + | |
| - | </ | + | |
| - | + | ||
| - | En consultant le fichier playbook.yaml, | + | |
| - | + | ||
| - | < | + | |
| - | trainee@ansible: | + | |
| - | | + | |
| - | 2 - hosts: basededonnees | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | 10 - hosts: dotcms | + | |
| - | 11 become: true | + | |
| - | 12 tasks: | + | |
| - | 13 - name: install jre | + | |
| - | 14 package: name=openjdk-8-jre state=present | + | |
| - | 15 - hosts: equilibrage | + | |
| - | 16 become: true | + | |
| - | 17 tasks: | + | |
| - | 18 - name: install | + | |
| - | 19 package: name=haproxy stated=present | + | |
| - | 20 - name: service | + | |
| - | 21 service: name=haproxy state=started enabled=yes | + | |
| - | 22 tags: service | + | |
| - | </ | + | |
| - | + | ||
| - | Corrigez le fichier playbook.yaml : | + | |
| - | + | ||
| - | < | + | |
| - | trainee@ansible: | + | |
| - | trainee@ansible: | + | |
| - | --- | + | |
| - | - hosts: basededonnees | + | |
| - | become: true | + | |
| - | tasks: | + | |
| - | - name: install | + | |
| - | package: name=postgresql state=present | + | |
| - | - name: service | + | |
| - | service: name=postgresql state=started enabled=yes | + | |
| - | tags: service | + | |
| - | - hosts: dotcms | + | |
| - | become: true | + | |
| - | tasks: | + | |
| - | - name: install jre | + | |
| - | package: name=openjdk-8-jre state=present | + | |
| - | - hosts: equilibrage | + | |
| - | become: true | + | |
| - | tasks: | + | |
| - | - name: install | + | |
| - | package: name=haproxy state=present | + | |
| - | - name: service | + | |
| - | service: name=haproxy state=started enabled=yes | + | |
| - | tags: service | + | |
| - | </ | + | |
| - | + | ||
| - | Ré-exécutez la commande **ansible-playbook** : | + | |
| - | + | ||
| - | < | + | |
| - | trainee@ansible: | + | |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | + | ||
| - | PLAY [basededonnees] *********************************************************************************************************************************** | + | |
| - | + | ||
| - | TASK [Gathering Facts] | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web01 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| - | ok: [web01] | + | |
| - | + | ||
| - | TASK [install] ***************************************************************************************************************************************** | + | |
| - | ok: [web01] | + | |
| - | + | ||
| - | TASK [service] ***************************************************************************************************************************************** | + | |
| - | ok: [web01] | + | |
| - | + | ||
| - | PLAY [dotcms] ****************************************************************************************************************************************** | + | |
| - | + | ||
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web03 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web03] | ok: [web03] | ||
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web02 should use / | ||
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | ||
| - | https:// | ||
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | ||
| ok: [web02] | ok: [web02] | ||
| - | TASK [install jre] ************************************************************************************************************************************* | + | PLAY [equilibrage] *********************************************************************************************************************************************************************************************** |
| - | ok: [web02] | + | |
| - | ok: [web03] | + | |
| - | + | ||
| - | PLAY [equilibrage] | + | |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web04] | ok: [web04] | ||
| - | TASK [install] ***************************************************************************************************************************************** | + | TASK [install] *************************************************************************************************************************************************************************************************** |
| - | [WARNING]: Updating cache and auto-installing missing dependency: python-apt | + | |
| changed: [web04] | changed: [web04] | ||
| - | TASK [service] ***************************************************************************************************************************************** | + | TASK [service] |
| ok: [web04] | ok: [web04] | ||
| - | PLAY RECAP ********************************************************************************************************************************************* | + | PLAY RECAP ******************************************************************************************************************************************************************************************************* |
| - | web01 : ok=3 changed=0 | + | web01 : ok=3 changed=1 |
| web02 : ok=2 changed=0 | web02 : ok=2 changed=0 | ||
| web03 : ok=2 changed=0 | web03 : ok=2 changed=0 | ||
| - | web04 : ok=3 changed=1 | + | web04 : ok=3 changed=1 |
| </ | </ | ||
| - | |||
| - | <WRAP center round important 60%> | ||
| - | **Important** : Notez que seul **web04** a été modifié. | ||
| - | </ | ||
| Il est possible de limiter l' | Il est possible de limiter l' | ||
| < | < | ||
| - | trainee@ansible:~$ ansible-playbook -i inventory playbook.yaml -l equilibrage | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | PLAY [basededonnees] *********************************************************************************************************************************** | + | PLAY [basededonnees] |
| skipping: no hosts matched | skipping: no hosts matched | ||
| - | PLAY [dotcms] ****************************************************************************************************************************************** | + | PLAY [dotcms] |
| skipping: no hosts matched | skipping: no hosts matched | ||
| - | PLAY [equilibrage] ************************************************************************************************************************************* | + | PLAY [equilibrage] |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web04] | ok: [web04] | ||
| - | TASK [install] ***************************************************************************************************************************************** | + | TASK [install] |
| ok: [web04] | ok: [web04] | ||
| - | TASK [service] ***************************************************************************************************************************************** | + | TASK [service] |
| ok: [web04] | ok: [web04] | ||
| - | PLAY RECAP ********************************************************************************************************************************************* | + | PLAY RECAP ******************************************************************************************************************************************************************************************************* |
| - | web04 : ok=3 changed=0 | + | web04 : ok=3 changed=0 |
| </ | </ | ||
| Ligne 1142: | Ligne 853: | ||
| < | < | ||
| - | trainee@ansible:~$ ansible-playbook -i inventory playbook.yaml -l web04 | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | PLAY [basededonnees] *********************************************************************************************************************************** | + | PLAY [basededonnees] |
| skipping: no hosts matched | skipping: no hosts matched | ||
| - | PLAY [dotcms] ****************************************************************************************************************************************** | + | PLAY [dotcms] |
| skipping: no hosts matched | skipping: no hosts matched | ||
| - | PLAY [equilibrage] ************************************************************************************************************************************* | + | PLAY [equilibrage] |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web04] | ok: [web04] | ||
| - | TASK [install] ***************************************************************************************************************************************** | + | TASK [install] |
| ok: [web04] | ok: [web04] | ||
| - | TASK [service] ***************************************************************************************************************************************** | + | TASK [service] |
| ok: [web04] | ok: [web04] | ||
| - | PLAY RECAP ********************************************************************************************************************************************* | + | PLAY RECAP ******************************************************************************************************************************************************************************************************* |
| - | web04 : ok=3 changed=0 | + | web04 : ok=3 changed=0 |
| </ | </ | ||
| Ligne 1187: | Ligne 892: | ||
| < | < | ||
| - | trainee@ansible:~$ ansible-playbook -i inventory playbook.yaml --tags service | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | PLAY [basededonnees] *********************************************************************************************************************************** | + | PLAY [basededonnees] |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web01 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web01] | ok: [web01] | ||
| - | TASK [service] ***************************************************************************************************************************************** | + | TASK [service] |
| ok: [web01] | ok: [web01] | ||
| - | PLAY [dotcms] ****************************************************************************************************************************************** | + | PLAY [dotcms] |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web02 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web02] | ok: [web02] | ||
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web03 should use / | ||
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | ||
| - | https:// | ||
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | ||
| ok: [web03] | ok: [web03] | ||
| - | PLAY [equilibrage] ************************************************************************************************************************************* | + | PLAY [equilibrage] |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web04] | ok: [web04] | ||
| - | TASK [service] ***************************************************************************************************************************************** | + | TASK [service] |
| ok: [web04] | ok: [web04] | ||
| - | PLAY RECAP ********************************************************************************************************************************************* | + | PLAY RECAP ******************************************************************************************************************************************************************************************************* |
| web01 : ok=2 changed=0 | web01 : ok=2 changed=0 | ||
| web02 : ok=1 changed=0 | web02 : ok=1 changed=0 | ||
| Ligne 1239: | Ligne 926: | ||
| < | < | ||
| - | trainee@ansible:~$ ansible-playbook -i inventory playbook.yaml --tags service -l equilibrage | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | PLAY [basededonnees] *********************************************************************************************************************************** | + | PLAY [basededonnees] |
| skipping: no hosts matched | skipping: no hosts matched | ||
| - | PLAY [dotcms] ****************************************************************************************************************************************** | + | PLAY [dotcms] |
| skipping: no hosts matched | skipping: no hosts matched | ||
| - | PLAY [equilibrage] ************************************************************************************************************************************* | + | PLAY [equilibrage] |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* |
| - | [DEPRECATION WARNING]: Distribution debian 9.7 on host web04 should use / | + | |
| - | prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See | + | |
| - | https:// | + | |
| - | 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
| ok: [web04] | ok: [web04] | ||
| - | TASK [service] ***************************************************************************************************************************************** | + | TASK [service] |
| ok: [web04] | ok: [web04] | ||
| - | PLAY RECAP ********************************************************************************************************************************************* | + | PLAY RECAP ******************************************************************************************************************************************************************************************************* |
| - | web04 : ok=2 changed=0 | + | web04 : ok=2 changed=0 |
| </ | </ | ||
| Ligne 1270: | Ligne 951: | ||
| Les **Rôles** permettent la création d'une bibliothèque réutilisable. | Les **Rôles** permettent la création d'une bibliothèque réutilisable. | ||
| + | |||
| + | {{ : | ||
| Un **Rôle** est un répertoire contenant les sous-répertoires suivants : | Un **Rôle** est un répertoire contenant les sous-répertoires suivants : | ||
| Ligne 1288: | Ligne 971: | ||
| * contient des variables de configuration de haute priorité, difficilement sur-chargées par des variables ailleurs. | * contient des variables de configuration de haute priorité, difficilement sur-chargées par des variables ailleurs. | ||
| - | <WRAP center round important | + | <WRAP center round important> |
| **Important** : Notez que seul le répertoire **tasks** est obligatoire. | **Important** : Notez que seul le répertoire **tasks** est obligatoire. | ||
| </ | </ | ||
| Ligne 1370: | Ligne 1053: | ||
| {{ : | {{ : | ||
| - | <WRAP center round important | + | <WRAP center round important> |
| **Important** : Notez que la convention utilisée pour les noms est // | **Important** : Notez que la convention utilisée pour les noms est // | ||
| </ | </ | ||
| - | Dans la machine **Ansible**, collez la commande copiée et exécutez-la : | + | Dans la machine **centos8**, collez la commande copiée et exécutez-la : |
| < | < | ||
| - | trainee@ansible:~$ ansible-galaxy install geerlingguy.java | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| Starting galaxy role install process | Starting galaxy role install process | ||
| - downloading role ' | - downloading role ' | ||
| - | - downloading role from https:// | + | - downloading role from https:// |
| - extracting geerlingguy.java to / | - extracting geerlingguy.java to / | ||
| - | - geerlingguy.java (1.10.0) was installed successfully | + | - geerlingguy.java (2.0.1) was installed successfully |
| </ | </ | ||
| Ligne 1390: | Ligne 1071: | ||
| < | < | ||
| - | trainee@ansible:~$ su - | + | [trainee@centos8 |
| - | Mot de passe : fenestros | + | Password: |
| - | root@ansible:~# apt-get install | + | [root@centos8 |
| - | ... | + | / |
| - | root@ansible:~# exit | + | [root@centos8 |
| - | déconnexion | + | logout |
| - | trainee@ansible:~$ tree / | + | [trainee@centos8 |
| / | / | ||
| ├── defaults | ├── defaults | ||
| - | │ └── main.yml | + | │ |
| ├── LICENSE | ├── LICENSE | ||
| ├── meta | ├── meta | ||
| - | │ └── main.yml | + | │ |
| ├── molecule | ├── molecule | ||
| - | │ └── default | + | │ |
| - | │ ├── converge.yml | + | │ |
| - | │ └── molecule.yml | + | │ |
| ├── README.md | ├── README.md | ||
| ├── tasks | ├── tasks | ||
| - | │ ├── main.yml | + | │ |
| - | │ ├── setup-Debian.yml | + | │ |
| - | │ ├── setup-FreeBSD.yml | + | │ |
| - | │ └── setup-RedHat.yml | + | │ |
| ├── templates | ├── templates | ||
| - | │ └── java_home.sh.j2 | + | │ |
| └── vars | └── vars | ||
| ├── Debian-10.yml | ├── Debian-10.yml | ||
| + | ├── Debian-11.yml | ||
| ├── Debian-8.yml | ├── Debian-8.yml | ||
| ├── Debian-9.yml | ├── Debian-9.yml | ||
| ├── Fedora.yml | ├── Fedora.yml | ||
| ├── FreeBSD.yml | ├── FreeBSD.yml | ||
| - | ├── RedHat-6.yml | ||
| ├── RedHat-7.yml | ├── RedHat-7.yml | ||
| ├── RedHat-8.yml | ├── RedHat-8.yml | ||
| Ligne 1433: | Ligne 1114: | ||
| </ | </ | ||
| - | <WRAP center round important | + | <WRAP center round important> |
| **Important** : Notez que dans ce cas il n'y a pas eu de dépendances. Par contre la commande **ansible-galaxy** sait résoudre et gérer les dépendances. | **Important** : Notez que dans ce cas il n'y a pas eu de dépendances. Par contre la commande **ansible-galaxy** sait résoudre et gérer les dépendances. | ||
| </ | </ | ||
| Ligne 1440: | Ligne 1121: | ||
| < | < | ||
| - | trainee@ansible:~$ vi playbook_java.yaml | + | [trainee@centos8 |
| - | trainee@ansible:~$ cat playbook_java.yaml | + | [trainee@centos8 |
| --- | --- | ||
| - hosts: all | - hosts: all | ||
| Ligne 1449: | Ligne 1130: | ||
| </ | </ | ||
| - | Avant d' | + | Avant d’exécuter |
| < | < | ||
| - | trainee@ansible:~$ vi .ansible.cfg | + | [trainee@centos8 |
| - | trainee@ansible:~$ cat .ansible.cfg | + | [trainee@centos8 |
| [defaults] | [defaults] | ||
| deprecation_warnings=False | deprecation_warnings=False | ||
| + | log_path = ./ | ||
| </ | </ | ||
| - | <WRAP center round important | + | <WRAP center round important> |
| **Important** : Le comportement d' | **Important** : Le comportement d' | ||
| </ | </ | ||
| Ligne 1465: | Ligne 1147: | ||
| < | < | ||
| - | trainee@ansible:~$ ansible-config list | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| ACTION_WARNINGS: | ACTION_WARNINGS: | ||
| default: true | default: true | ||
| - | description: | + | description: |
| - | - By default Ansible will issue a warning when received from a task action (module | + | |
| - | | + | |
| - | - These warnings can be silenced by adjusting this setting to False. | + | |
| env: | env: | ||
| - | - name: ANSIBLE_ACTION_WARNINGS | + | - {name: ANSIBLE_ACTION_WARNINGS} |
| ini: | ini: | ||
| - | - key: action_warnings | + | - {key: action_warnings, section: defaults} |
| - | | + | |
| name: Toggle action warnings | name: Toggle action warnings | ||
| type: boolean | type: boolean | ||
| Ligne 1487: | Ligne 1165: | ||
| the command line supplied become method | the command line supplied become method | ||
| env: | env: | ||
| - | - name: ANSIBLE_AGNOSTIC_BECOME_PROMPT | + | - {name: ANSIBLE_AGNOSTIC_BECOME_PROMPT} |
| ini: | ini: | ||
| - | - key: agnostic_become_prompt | + | - {key: agnostic_become_prompt, section: privilege_escalation} |
| - | | + | |
| name: Display an agnostic become prompt | name: Display an agnostic become prompt | ||
| type: boolean | type: boolean | ||
| version_added: | version_added: | ||
| - | yaml: | + | yaml: {key: privilege_escalation.agnostic_become_prompt} |
| - | | + | |
| ALLOW_WORLD_READABLE_TMPFILES: | ALLOW_WORLD_READABLE_TMPFILES: | ||
| default: false | default: false | ||
| - | deprecated: | + | deprecated: |
| - | | + | version: ' |
| - | itself and not using the general constant. | + | description: |
| - | | + | plugin option : |
| - | version: ' | + | still accepted with the shell plugin adding additional options, like variables.', |
| - | | + | This message will be removed in 2.14.] |
| - | description: | + | |
| - | - This makes the temporary files created on the machine world-readable and will | + | type: boolean |
| - | | + | ANSIBLE_CONNECTION_PATH: |
| - | : | + | default: null |
| + | description: | ||
| + | | ||
| + | same directory as the ansible script.' | ||
| + | env: | ||
| + | - {name: ANSIBLE_CONNECTION_PATH} | ||
| + | ini: | ||
| + | - {key: ansible_connection_path, | ||
| + | name: Path of ansible-connection script | ||
| + | type: path | ||
| + | version_added: | ||
| + | yaml: {key: persistent_connection.ansible_connection_path} | ||
| + | ANSIBLE_COW_ACCEPTLIST: | ||
| + | default: [bud-frogs, bunny, cheese, daemon, default, dragon, elephant-in-snake, | ||
| + | | ||
| + | sheep, small, stegosaurus, | ||
| + | udder, vader-koala, | ||
| + | description: | ||
| + | list if you want to enable all installed templates. | ||
| + | env: | ||
| + | - deprecated: {alternatives: | ||
| + | --More-- | ||
| </ | </ | ||
| Ligne 1513: | Ligne 1210: | ||
| < | < | ||
| - | trainee@ansible:~$ ansible-playbook -i inventory playbook_java.yaml | + | [trainee@centos8 |
| - | / | + | |
| - | from cryptography.exceptions import InvalidSignature | + | |
| - | PLAY [all] ********************************************************************************************************************************************* | + | PLAY [all] ******************************************************************************************************************************************************************************************************* |
| - | TASK [Gathering Facts] ********************************************************************************************************************************* | + | TASK [Gathering Facts] |
| ok: [web04] | ok: [web04] | ||
| ok: [web01] | ok: [web01] | ||
| - | ok: [web02] | ||
| ok: [web03] | ok: [web03] | ||
| + | ok: [web02] | ||
| - | TASK [geerlingguy.java : Include OS-specific variables for Fedora or FreeBSD.] ************************************************************************* | + | TASK [geerlingguy.java : Include OS-specific variables for Fedora or FreeBSD.] |
| skipping: [web01] | skipping: [web01] | ||
| skipping: [web02] | skipping: [web02] | ||
| Ligne 1531: | Ligne 1226: | ||
| skipping: [web04] | skipping: [web04] | ||
| - | TASK [geerlingguy.java : Include version-specific variables for CentOS/ | + | TASK [geerlingguy.java : Include version-specific variables for CentOS/ |
| skipping: [web01] | skipping: [web01] | ||
| skipping: [web02] | skipping: [web02] | ||
| Ligne 1537: | Ligne 1232: | ||
| skipping: [web04] | skipping: [web04] | ||
| - | TASK [geerlingguy.java : Include version-specific variables for Ubuntu.] ******************************************************************************* | + | TASK [geerlingguy.java : Include version-specific variables for Ubuntu.] |
| skipping: [web01] | skipping: [web01] | ||
| skipping: [web02] | skipping: [web02] | ||
| Ligne 1543: | Ligne 1238: | ||
| skipping: [web04] | skipping: [web04] | ||
| - | TASK [geerlingguy.java : Include version-specific variables for Debian.] ******************************************************************************* | + | TASK [geerlingguy.java : Include version-specific variables for Debian.] ***************************************************************************************************************************************** |
| - | ok: [web01] | + | |
| ok: [web02] | ok: [web02] | ||
| ok: [web03] | ok: [web03] | ||
| + | ok: [web01] | ||
| ok: [web04] | ok: [web04] | ||
| - | TASK [geerlingguy.java : Define java_packages.] ******************************************************************************************************** | + | TASK [geerlingguy.java : Define java_packages.] |
| ok: [web01] | ok: [web01] | ||
| ok: [web02] | ok: [web02] | ||
| Ligne 1555: | Ligne 1250: | ||
| ok: [web04] | ok: [web04] | ||
| - | TASK [geerlingguy.java : include_tasks] **************************************************************************************************************** | + | TASK [geerlingguy.java : include_tasks] |
| skipping: [web01] | skipping: [web01] | ||
| skipping: [web02] | skipping: [web02] | ||
| Ligne 1561: | Ligne 1256: | ||
| skipping: [web04] | skipping: [web04] | ||
| - | TASK [geerlingguy.java : include_tasks] **************************************************************************************************************** | + | TASK [geerlingguy.java : include_tasks] |
| included: / | included: / | ||
| - | TASK [geerlingguy.java : Ensure ' | + | TASK [geerlingguy.java : Ensure ' |
| skipping: [web01] | skipping: [web01] | ||
| skipping: [web02] | skipping: [web02] | ||
| Ligne 1570: | Ligne 1265: | ||
| skipping: [web04] | skipping: [web04] | ||
| - | TASK [geerlingguy.java : Ensure Java is installed.] **************************************************************************************************** | + | TASK [geerlingguy.java : Ensure Java is installed.] |
| changed: [web04] | changed: [web04] | ||
| - | changed: [web02] | ||
| changed: [web03] | changed: [web03] | ||
| + | changed: [web02] | ||
| changed: [web01] | changed: [web01] | ||
| - | TASK [geerlingguy.java : include_tasks] **************************************************************************************************************** | + | TASK [geerlingguy.java : include_tasks] |
| skipping: [web01] | skipping: [web01] | ||
| skipping: [web02] | skipping: [web02] | ||
| Ligne 1582: | Ligne 1277: | ||
| skipping: [web04] | skipping: [web04] | ||
| - | TASK [geerlingguy.java : Set JAVA_HOME if configured.] ************************************************************************************************* | + | TASK [geerlingguy.java : Set JAVA_HOME if configured.] |
| skipping: [web01] | skipping: [web01] | ||
| skipping: [web02] | skipping: [web02] | ||
| Ligne 1588: | Ligne 1283: | ||
| skipping: [web04] | skipping: [web04] | ||
| - | PLAY RECAP ********************************************************************************************************************************************* | + | PLAY RECAP ******************************************************************************************************************************************************************************************************* |
| web01 : ok=5 changed=1 | web01 : ok=5 changed=1 | ||
| web02 : ok=5 changed=1 | web02 : ok=5 changed=1 | ||
| Ligne 1595: | Ligne 1290: | ||
| </ | </ | ||
| - | <WRAP center round important 60%> | + | Notez qu' |
| - | **Important** : Notez qu' | + | |
| - | </WRAP> | + | < |
| + | [trainee@centos8 ~]$ ansible-config dump |grep ROLES_PATH | ||
| + | DEFAULT_ROLES_PATH(default) = ['/ | ||
| + | </code> | ||
| + | |||
| + | Le PLAY RECAP contient 7 catégories : | ||
| + | |||
| + | * **ok** | ||
| + | * le nombre de tâches qui ont été traitées sans erreur | ||
| + | * **changed** | ||
| + | * le nombre de tâches qui ont effectué des modifications sur un des hôtes concernés | ||
| + | * **unreachable** | ||
| + | * le nombre de tâches qui n'ont pas été exécutées parce que l' | ||
| + | * **failed** | ||
| + | * le nombre de tâches en erreur pour lesquelles la valeur de **ignore_errors: | ||
| + | * **skipped** | ||
| + | * le nombre de tâches qui n'ont pas été exécutées parce que la valeur de la clause **when** était **fausse** | ||
| + | * **rescued** | ||
| + | * le nombre de tâches de type **rescue** qui ont été exécutées suite à une erreur ailleurs dans le playbook | ||
| + | * **ignored** | ||
| + | * le nombre de tâches en erreur pour lesquelles la valeur de **ignore_errors: | ||
| + | |||
| + | Pour mieux expliquer la catégorie **rescued**, | ||
| + | |||
| + | < | ||
| + | --- | ||
| + | - name: Ansible Blocks | ||
| + | | ||
| + | | ||
| + | |||
| + | | ||
| + | - block: | ||
| + | - name: List home directory content | ||
| + | command: "ls -l ~/" | ||
| + | |||
| + | - name: Failing intentionally | ||
| + | command: "ls -l / | ||
| + | |||
| + | | ||
| + | - name: Rescue block (perform recovery) | ||
| + | debug: | ||
| + | msg: " | ||
| + | |||
| + | | ||
| + | - name: This will execute always | ||
| + | debug: | ||
| + | msg: "I will execute even in failure scenario" | ||
| + | </ | ||
| + | |||
| + | Dans le cas ci-dessus, la deuxième tâche dans la section **block** va générer une erreur. Dans ce cas la tâche dans la section **rescue** sera exécutée. Dans **tous** les cas la tâche dans la section **always** sera exécutée. | ||
| ----- | ----- | ||
| - | Copyright © 2022 Hugh Norris. | + | Copyright © 2023 Hugh Norris. |