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:part7 [2021/11/25 14:35] – admin | elearning:workbooks:debian:6:avance:l130:part7 [2022/03/12 07:22] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version : **2021.01** | + | Version : **2022.01** |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======DOF507 | + | ======DOF506 |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **DOF507 | + | * **DOF506 |
* Contenu du Module | * Contenu du Module | ||
* Support de Cours | * Support de Cours | ||
Ligne 15: | Ligne 15: | ||
* Jour #1 | * Jour #1 | ||
* Jour #2 | * Jour #2 | ||
+ | * LAB #1 - Validation des Acquis Pratique | ||
+ | * 1.1 - Instructions | ||
+ | * 1.2 - Corrigés | ||
+ | * Erreur #1 | ||
+ | * Erreur #2 | ||
+ | * Erreur #3 | ||
+ | * Erreurs 4, 5 et 6 | ||
* Évaluation de la Formation | * Évaluation de la Formation | ||
- | * Remerciements | + | * Validation des Acquis Théorique |
=====Support de Cours===== | =====Support de Cours===== | ||
Ligne 111: | Ligne 118: | ||
* 3.5 - Créer un Utilisateur Local | * 3.5 - Créer un Utilisateur Local | ||
- | * **DOF506 - Validation | + | * **DOF506 - Validation |
- | * LAB #1 - Automatiser avec Ansible | + | * Support de Cours |
+ | * Rappel du Programme de la Formation | ||
+ | * Jour #1 | ||
+ | * Jour #2 | ||
+ | * LAB #1 - Validation des Acquis Pratique | ||
* 1.1 - Instructions | * 1.1 - Instructions | ||
* 1.2 - Corrigés | * 1.2 - Corrigés | ||
Ligne 119: | Ligne 130: | ||
* Erreur #3 | * Erreur #3 | ||
* Erreurs 4, 5 et 6 | * Erreurs 4, 5 et 6 | ||
- | |||
- | * **DOF507 - Validation de la Formation** | ||
- | * Support de Cours | ||
- | * Rappel du Programme de la Formation | ||
- | * Jour #1 | ||
- | * Jour #2 | ||
* Évaluation de la Formation | * Évaluation de la Formation | ||
- | * Validation des Acquis | + | * Validation des Acquis |
+ | =====LAB #1 - Validation des Acquis Pratique===== | ||
+ | |||
+ | Connectez-vous à la machine virtuelle **CentOS_7** : | ||
+ | |||
+ | < | ||
+ | trainee@traineeXX: | ||
+ | </ | ||
+ | |||
+ | ====1.1 - Instructions ==== | ||
+ | |||
+ | Il vous est demandé d' | ||
+ | |||
+ | * l' | ||
+ | * la mise à jour éventuelle de firewalld, | ||
+ | * la création d'une règle dans firewalld pour le trafic vers le serveur vsfptd, | ||
+ | * la création sécurisée de deux comptes ftp : | ||
+ | * user : mike | ||
+ | * mot de passe : toto | ||
+ | * user : bob | ||
+ | * mot de passe : tata | ||
+ | |||
+ | Installez donc Ansible à partir des dépôts : | ||
+ | |||
+ | < | ||
+ | [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 : | ||
+ | |||
+ | < | ||
+ | [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] | ||
=====Évaluation de la Formation===== | =====Évaluation de la Formation===== | ||
- | Afin de valider votre formation, veuillez compléter l’Évaluation de la Formation | + | Afin de valider votre formation, veuillez compléter l’Évaluation de la Formation. |
- | ----- | + | =====Validation des Acquis Théorique===== |
- | < | + | Afin de valider votre formation, veuillez passer la Validation des Acquis. |
- | <DIV ALIGN=" | + | |
- | Copyright © 2021 Hugh Norris< | + | ----- |
- | Document non-contractuel. Le programme peut être modifié sans préavis. | + | |
- | </ | + | |
- | </ | + | |
+ | Copyright © 2022 Hugh Norris - Document non-contractuel. Le programme peut être modifié sans préavis. |