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:part6 [2021/12/29 10:31] – admin | elearning:workbooks:debian:6:avance:l130:part6 [2023/08/25 01:32] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~PDF: | ~~PDF: | ||
| - | Version | + | Version |
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| - | ======DOF506 | + | ======LCF805 |
| =====Contenu du Module===== | =====Contenu du Module===== | ||
| - | * **DOF506 | + | * **LCF805 |
| * Contenu du Module | * Contenu du Module | ||
| - | * LAB #1 - Automatiser avec Ansible | + | * Rappel du Programme de la Formation |
| - | * 1.1 - Instructions | + | * Validation des acquis globale |
| - | * 1.2 - Corrigés | + | * Évaluation de la Formation |
| - | * Erreur #1 | + | |
| - | * Erreur #2 | + | |
| - | * Erreur #3 | + | |
| - | * Erreurs 4, 5 et 6 | + | |
| - | =====LAB #1 - Automatiser avec Ansible===== | + | =====Rappel du Programme de la Formation===== |
| - | Connectez-vous à la machine virtuelle | + | * **LCF800 |
| + | | ||
| + | * Matériel | ||
| + | * Logiciels | ||
| + | * Internet | ||
| + | * Programme de la Formation | ||
| + | | ||
| - | < | + | * **LCF801 - Installation d' |
| - | trainee@traineeXX: | + | * Qu' |
| - | </ | + | * Installation d' |
| + | * LAB #1 - Configuration de ssh et de sudo | ||
| + | * 1.1 - ssh | ||
| + | * 1.2 - sudo | ||
| - | ====1.1 - Instructions ==== | + | * **LCF802 - Les Commandes ansible, ansible-playbook et ansible-galaxy**. |
| + | * LAB #1 - Débuter avec Ansible | ||
| + | * 1.1 - La Commande ansible | ||
| + | * LAB #2 - La Commande ansible-playbook | ||
| + | * 2.1 - Playbook Files | ||
| + | * 2.2 - Tasks | ||
| + | * 2.3 - Handlers | ||
| + | * 2.4 - Modules | ||
| + | * 2.4.1 - Modules pour des Paquets | ||
| + | * 2.4.2 - Modules pour des Fichiers | ||
| + | * 2.4.3 - Modules pour le Système | ||
| + | * 2.5 - Inventory Files | ||
| + | * 2.6 - Privilèges | ||
| + | * 2.6.1 - Création de Groupes | ||
| + | * LAB #3 - La Commande ansible-galaxy | ||
| + | * 3.1 - Utiliser des Rôles avec un Play Book | ||
| + | * 3.2 - Ansible Galaxy | ||
| - | Il vous est demandé | + | * **LCF803 - Rôles, Gabarits, Variables et Facts** |
| + | * LAB #1 - Dépendances de Rôles | ||
| + | * LAB #2 - Utilisation des Gabarits | ||
| + | * 2.1 - Variables | ||
| + | * 2.2 - Gabarits Conditionnels | ||
| + | * 2.3 - Boucles | ||
| + | * 2.4 - Macros | ||
| + | * 2.5 - Filtres | ||
| + | * 2.5.1 - Default | ||
| + | * 2.5.2 - Join | ||
| + | * 2.5.3 - Map | ||
| + | * 2.6 - Gabarits Parent - Enfants | ||
| + | * 2.6.1 - Le Gabarit Parent | ||
| + | * 2.6.2 - Le Gabarit Enfant | ||
| + | * LAB #3 - Gestion de la Hiérarchie des Variables | ||
| + | * LAB #4 - Utilisation des Facts d' | ||
| + | * LAB #5 - La Commande ansible-vault | ||
| + | * 5.1 - Crypter le Fichier | ||
| + | * 5.2 - Editer le Fichier | ||
| + | * 5.3 - Décrypter le Fichier | ||
| + | * 5.4 - Utilisation de Mots de Passe Aléatoires | ||
| + | * LAB #6 - Ansible par la Pratique | ||
| + | * 6.1 - Instructions | ||
| + | * 6.2 - Corrigés | ||
| - | * l'installation du serveur vsftpd, | + | * **LCF804 - Utilisation d'Ansible avec Docker et Windows** |
| - | * la mise à jour éventuelle | + | * LAB #1 - Ansible et Docker |
| - | * la création d'une règle dans firewalld | + | * 1.1 - Présentation |
| - | * la création sécurisée de deux comptes ftp : | + | * 1.2 - Installer Docker |
| - | * user : mike | + | * 1.3 - La Connexion à Docker |
| - | * mot de passe : toto | + | * LAB #2 - Préparer Windows 10 |
| - | * user : bob | + | * 2.1 - Mettre à Jour PowerShell et .NET |
| - | * mot de passe : tata | + | * 2.2 - Configurer WinRM |
| + | * 2.3 - Consulter les Informations sur WinRM | ||
| + | * 2.4 - Créer un Utilisateur Local pour Ansible | ||
| + | * LAB #3 - Préparer | ||
| + | * 3.1 - Installer pywinrm | ||
| + | * 3.2 - Tester | ||
| + | * LAB #4 - Travailler avec Ansible et Windows | ||
| + | * 4.1 - Obtenir les Informations sur Windows10 | ||
| + | * 4.2 - Exécuter une Commande | ||
| + | * 4.3 - Exécuter un script PowerShell | ||
| + | * 4.4 - Installer un Logiciel avec Chocolatey | ||
| + | * 4.5 - Créer un Utilisateur Local | ||
| - | Installez donc Ansible à partir | + | * **LCF805 - Validation de la Formation**. |
| + | * Support de Cours | ||
| + | * Rappel du Programme de la Formation | ||
| + | * Validation | ||
| + | * Évaluation de la Formation | ||
| - | < | + | =====Évaluation |
| - | [trainee@centos7 ~]$ su - | + | |
| - | Mot de passe : fenestros | + | |
| - | Dernière connexion : jeudi 5 septembre 2019 à 18:28:51 CEST sur pts/0 | + | |
| - | [root@centos7 ~]# yum install epel-release | + | |
| - | [root@centos7 ~]# yum install ansible | + | |
| - | </ | + | |
| - | Vérifiez ensuite la présence des exécutables : | + | Afin de valider votre formation, veuillez compléter |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# which ansible | + | |
| - | / | + | |
| - | [root@centos7 ~]# which ansible-playbook | + | |
| - | / | + | |
| - | </ | + | |
| - | + | ||
| - | Afin de vous aider, on vous fournit deux fichiers : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# cat vsftpd.yml | + | |
| - | --- | + | |
| - | - name: ftp server install | + | |
| - | hosts: localhost | + | |
| - | gather_facts: | + | |
| - | become: yes | + | |
| - | vars_files: | + | |
| - | - users.yml | + | |
| - | tasks: | + | |
| - | - name: latest vsftpd version | + | |
| - | yum: | + | |
| - | name: vsftpd | + | |
| - | state: latest | + | |
| - | - name: latest firewalld version | + | |
| - | name: firewalld | + | |
| - | state: latest | + | |
| - | - name: vsftpd | + | |
| - | service: | + | |
| - | name vsftpd | + | |
| - | enabled: true | + | |
| - | state: started | + | |
| - | - name: firewalld | + | |
| - | service: | + | |
| - | name: firewalld | + | |
| - | enabled: true | + | |
| - | state: started | + | |
| - | - name: firewalld allows ftp | + | |
| - | firewalld: | + | |
| - | permanent: yes | + | |
| - | immediate: yes | + | |
| - | state: enabled | + | |
| - | - name: Create_FTP_users | + | |
| - | user: | + | |
| - | password: "{{ item.password | password_hash(sha512) }}" | + | |
| - | with_items: "{{ ftp_users }}" | + | |
| - | </ | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# ansible-vault view secrets.yml | + | |
| - | Vault password: fenestros | + | |
| - | ftp_users: | + | |
| - | - { username: mike, password: toto } | + | |
| - | - { username: bob, password: tata } | + | |
| - | </ | + | |
| - | + | ||
| - | Lors de l' | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# ansible-playbook vsftpd.yml | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | ERROR! Syntax Error while loading YAML. | + | |
| - | + | ||
| - | + | ||
| - | The error appears to have been in '/ | + | |
| - | be elsewhere in the file depending on the exact syntax problem. | + | |
| - | + | ||
| - | The offending line appears to be: | + | |
| - | + | ||
| - | - name: latest firewalld version | + | |
| - | name: firewalld | + | |
| - | ^ here | + | |
| - | + | ||
| - | exception type: <class ' | + | |
| - | exception: mapping values are not allowed in this context | + | |
| - | in "< | + | |
| - | </ | + | |
| - | + | ||
| - | A vous de jouer ! | + | |
| - | + | ||
| - | [isauth account, | + | |
| - | + | ||
| - | ====1.2 - Corrigés==== | + | |
| - | + | ||
| - | ===Erreur #1=== | + | |
| - | + | ||
| - | Éditez le fichier **vsftpd.yml** : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# vi vsftpd.yml | + | |
| - | [root@centos7 ~]# cat vsftpd.yml | + | |
| - | --- | + | |
| - | - name: ftp server install | + | |
| - | hosts: localhost | + | |
| - | gather_facts: | + | |
| - | become: yes | + | |
| - | vars_files: | + | |
| - | - users.yml | + | |
| - | tasks: | + | |
| - | - name: latest vsftpd version | + | |
| - | yum: | + | |
| - | name: vsftpd | + | |
| - | state: latest | + | |
| - | - name: latest firewalld version | + | |
| - | yum: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | + | |
| - | name: firewalld | + | |
| - | state: latest | + | |
| - | - name: vsftpd | + | |
| - | service: | + | |
| - | name vsftpd | + | |
| - | enabled: true | + | |
| - | state: started | + | |
| - | - name: firewalld | + | |
| - | service: | + | |
| - | name: firewalld | + | |
| - | enabled: true | + | |
| - | state: started | + | |
| - | - name: firewalld allows ftp | + | |
| - | firewalld: | + | |
| - | permanent: yes | + | |
| - | immediate: yes | + | |
| - | state: enabled | + | |
| - | - name: Create_FTP_users | + | |
| - | user: | + | |
| - | password: "{{ item.password | password_hash(sha512) }}" | + | |
| - | with_items: "{{ ftp_users }}" | + | |
| - | </ | + | |
| - | + | ||
| - | Relancez la commande **ansible-playbook** : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# ansible-playbook vsftpd.yml | + | |
| - | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' | + | |
| - | ERROR! Syntax Error while loading YAML. | + | |
| - | mapping values are not allowed in this context | + | |
| - | + | ||
| - | The error appears to be in '/ | + | |
| - | be elsewhere in the file depending on the exact syntax problem. | + | |
| - | + | ||
| - | The offending line appears to be: | + | |
| - | + | ||
| - | name vsftpd | + | |
| - | enabled: true | + | |
| - | ^ here | + | |
| - | </ | + | |
| - | + | ||
| - | ===Erreur #2=== | + | |
| - | + | ||
| - | Editez le fichier **vsftpd.yml** : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# vi vsftpd.yml | + | |
| - | [root@centos7 ~]# cat vsftpd.yml | + | |
| - | --- | + | |
| - | - name: ftp server install | + | |
| - | hosts: localhost | + | |
| - | gather_facts: | + | |
| - | become: yes | + | |
| - | vars_files: | + | |
| - | - users.yml | + | |
| - | tasks: | + | |
| - | - name: latest vsftpd version | + | |
| - | yum: | + | |
| - | name: vsftpd | + | |
| - | state: latest | + | |
| - | - name: latest firewalld version | + | |
| - | yum: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | + | |
| - | name: firewalld | + | |
| - | state: latest | + | |
| - | - name: vsftpd | + | |
| - | service: | + | |
| - | name: vsftpd <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | + | |
| - | enabled: true | + | |
| - | state: started | + | |
| - | - name: firewalld | + | |
| - | service: | + | |
| - | name: firewalld | + | |
| - | enabled: true | + | |
| - | state: started | + | |
| - | - name: firewalld allows ftp | + | |
| - | firewalld: | + | |
| - | permanent: yes | + | |
| - | immediate: yes | + | |
| - | state: enabled | + | |
| - | - name: Create_FTP_users | + | |
| - | user: | + | |
| - | password: "{{ item.password | password_hash(sha512) }}" | + | |
| - | with_items: "{{ ftp_users }}" | + | |
| - | </ | + | |
| - | + | ||
| - | Relancez la commande **ansible-playbook** : | + | |
| - | + | ||
| - | < | + | |
| - | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' | + | |
| - | ERROR! vars file users.yml was not found | + | |
| - | Could not find file on the Ansible Controller. | + | |
| - | If you are using a module and expect the file to exist on the remote, see the remote_src option | + | |
| - | </ | + | |
| - | + | ||
| - | ===Erreur #3=== | + | |
| - | + | ||
| - | Créez le fichier **users.yml** : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# vi users.yml | + | |
| - | [root@centos7 ~]# cat users.yml | + | |
| - | ftp_users: | + | |
| - | - { username: mike, password: toto } | + | |
| - | - { username: bob, password: tata } | + | |
| - | </ | + | |
| - | + | ||
| - | Relancez la commande **ansible-playbook** : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# mv user.yml users.yml | + | |
| - | [root@centos7 ~]# ansible-playbook vsftpd.yml | + | |
| - | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' | + | |
| - | + | ||
| - | PLAY [ftp server install] *********************************************************************************************************************************************** | + | |
| - | + | ||
| - | TASK [latest vsftpd version] ******************************************************************************************************************************************** | + | |
| - | changed: [localhost] | + | |
| - | + | ||
| - | TASK [latest firewalld version] ***************************************************************************************************************************************** | + | |
| - | changed: [localhost] | + | |
| - | + | ||
| - | TASK [vsftpd] *********************************************************************************************************************************************************** | + | |
| - | changed: [localhost] | + | |
| - | + | ||
| - | TASK [firewalld] ******************************************************************************************************************************************************** | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [firewalld allows ftp] ********************************************************************************************************************************************* | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [Create_FTP_users] ************************************************************************************************************************************************* | + | |
| - | fatal: [localhost]: | + | |
| - | + | ||
| - | PLAY RECAP ************************************************************************************************************************************************************** | + | |
| - | localhost | + | |
| - | </ | + | |
| - | + | ||
| - | ===Erreurs 4, 5 et 6=== | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# vi vsftpd.yml | + | |
| - | [root@centos7 ~]# cat vsftpd.yml | + | |
| - | --- | + | |
| - | - name: ftp server install | + | |
| - | hosts: localhost | + | |
| - | gather_facts: | + | |
| - | become: yes | + | |
| - | vars_files: | + | |
| - | - users.yml | + | |
| - | tasks: | + | |
| - | - name: latest vsftpd version | + | |
| - | yum: | + | |
| - | name: vsftpd | + | |
| - | state: latest | + | |
| - | - name: latest firewalld version | + | |
| - | yum: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | + | |
| - | name: firewalld | + | |
| - | state: latest | + | |
| - | - name: vsftpd | + | |
| - | service: | + | |
| - | name: vsftpd <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | + | |
| - | enabled: true | + | |
| - | state: started | + | |
| - | - name: firewalld | + | |
| - | service: | + | |
| - | name: firewalld | + | |
| - | enabled: true | + | |
| - | state: started | + | |
| - | - name: firewalld allows ftp | + | |
| - | firewalld: | + | |
| - | permanent: yes | + | |
| - | immediate: yes | + | |
| - | state: enabled | + | |
| - | - name: Create_FTP_users | + | |
| - | user: | + | |
| - | name: "{{ item.username }}" | + | |
| - | password: "{{ item.password | password_hash(' | + | |
| - | with_items: "{{ ftp_users }}" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | + | |
| - | </ | + | |
| - | + | ||
| - | Relancez la commande **ansible-playbook** : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# ansible-playbook vsftpd.yml | + | |
| - | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' | + | |
| - | + | ||
| - | PLAY [ftp server install] *********************************************************************************************************************************************** | + | |
| - | + | ||
| - | TASK [latest vsftpd version] ******************************************************************************************************************************************** | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [latest firewalld version] ***************************************************************************************************************************************** | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [vsftpd] *********************************************************************************************************************************************************** | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [firewalld] ******************************************************************************************************************************************************** | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [firewalld allows ftp] ********************************************************************************************************************************************* | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [Create_FTP_users] ************************************************************************************************************************************************* | + | |
| - | changed: [localhost] => (item={u' | + | |
| - | changed: [localhost] => (item={u' | + | |
| - | + | ||
| - | PLAY RECAP ************************************************************************************************************************************************************** | + | |
| - | localhost | + | |
| - | </ | + | |
| - | + | ||
| - | Crypter le fichier users.yml : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# ansible-vault encrypt users.yml | + | |
| - | New Vault password: fenestros | + | |
| - | Confirm New Vault password: fenestros | + | |
| - | Encryption successful | + | |
| - | </ | + | |
| - | + | ||
| - | Consultez le fichier users.yml : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# ansible-vault view users.yml | + | |
| - | Vault password: | + | |
| - | ftp_users: | + | |
| - | - { username: mike, password: toto } | + | |
| - | - { username: bob, password: tata } | + | |
| - | + | ||
| - | [root@centos7 ~]# cat users.yml | + | |
| - | $ANSIBLE_VAULT; | + | |
| - | 30323061313265353234666230373765333865663061626362646332376639356463623238343166 | + | |
| - | 3635356261383732373633626230353837393735393933390a323561663963666262343835363166 | + | |
| - | 61306137383463303138656131626236633935383031323864396164366139323265653732663834 | + | |
| - | 6130656163356661360a663635333537373961616230353766666130633537323065663161393939 | + | |
| - | 65353936613539303631373530643536616335356461323735646165616136303839636166663232 | + | |
| - | 38616133393235636632646461346430373966306463636662333431373936633837616336326461 | + | |
| - | 38633139616339343865626630333531366138313761663330346231333131346535663761396233 | + | |
| - | 35353036373530323636636335336539616433373461653866316138306632323038626266623264 | + | |
| - | 6634 | + | |
| - | </ | + | |
| - | + | ||
| - | Exécutez le playbook : | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# ansible-playbook vsftpd.yml --ask-vault-pass | + | |
| - | Vault password: fenestros | + | |
| - | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' | + | |
| - | + | ||
| - | PLAY [ftp server install] ************************************************************************************************************************************************* | + | |
| - | + | ||
| - | TASK [latest vsftpd version] ********************************************************************************************************************************************** | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [latest firewalld version] ******************************************************************************************************************************************* | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [vsftpd] ************************************************************************************************************************************************************* | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [firewalld] ********************************************************************************************************************************************************** | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [firewalld allows ftp] *********************************************************************************************************************************************** | + | |
| - | ok: [localhost] | + | |
| - | + | ||
| - | TASK [Create_FTP_users] *************************************************************************************************************************************************** | + | |
| - | changed: [localhost] => (item={u' | + | |
| - | changed: [localhost] => (item={u' | + | |
| - | + | ||
| - | PLAY RECAP **************************************************************************************************************************************************************** | + | |
| - | localhost | + | |
| - | </ | + | |
| - | + | ||
| - | Notez que malgré le fait que le fichier **users.yml** soit crypté, les mots de passe des utilisateurs apparaissent en clair lors de l' | + | |
| - | + | ||
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# vi vsftpd.yml | + | |
| - | [root@centos7 ~]# cat vsftpd.yml | + | |
| - | ... | + | |
| - | - name: Create_FTP_users | + | |
| - | user: | + | |
| - | name: "{{ item.username }}" # pas d' | + | |
| - | password: "{{ item.password | password_hash(' | + | |
| - | with_items: "{{ ftp_users }}" # erreur d' | + | |
| - | no_log: True | + | |
| - | </ | + | |
| - | + | ||
| - | De cette façon lors de l' | + | |
| - | + | ||
| - | < | + | |
| - | [root@centos7 ~]# ansible-playbook vsftpd.yml --ask-vault-pass | + | |
| - | Vault password: fenestros | + | |
| - | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' | + | |
| - | ... | + | |
| - | TASK [Create_FTP_users] *************************************************************************************************************************************************** | + | |
| - | changed: [localhost] => (item=None) | + | |
| - | changed: [localhost] => (item=None) | + | |
| - | + | ||
| - | PLAY RECAP **************************************************************************************************************************************************************** | + | |
| - | localhost | + | |
| - | </ | + | |
| - | + | ||
| - | [/isauth] | + | |
| ----- | ----- | ||
| - | Copyright © 2022 Hugh Norris. | + | Copyright © 2023 Hugh Norris |