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:part5 [2020/03/27 08:28] – admin | elearning:workbooks:debian:6:avance:l130:part5 [2023/01/20 07:28] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~PDF: | ~~PDF: | ||
| - | Version | + | Version |
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| - | ======DOF505 | + | ======LCF805 |
| - | =====Pré-requis Windows===== | + | =====Contenu du Module===== |
| - | Ansible est capable | + | * **LCF805 - Automatiser l' |
| + | * Contenu du Module | ||
| + | * LAB #1 - Automatiser | ||
| + | * 1.1 - Instructions | ||
| + | * 1.2 - Corrigés | ||
| + | * Erreur #1 | ||
| + | * Erreur #2 | ||
| + | * Erreur #3 | ||
| + | * Erreurs 4, 5 et 6 | ||
| - | * Windows(tm) 7, | + | =====LAB #1 - Automatiser avec Ansible===== |
| - | * Windows(tm) 8.1, | + | |
| - | * Windowst(tm) 10, | + | |
| - | * Windows(tm) Server 2008, | + | |
| - | * Windows(tm) 2008 R2, | + | |
| - | * Wondows(tm) 2012, | + | |
| - | * Windows(tm) 2012 R2, | + | |
| - | * Windows(tm) 2016, | + | |
| - | * Windows(tm) 2019. | + | |
| - | Ansible nécessite sur chaque hôte : | + | Connectez-vous à la machine virtuelle **CentOS_7** |
| - | * PowerShell 3.0 ou supérieur | + | < |
| - | * Au moins .NET 4.0. | + | trainee@traineeXX: |
| + | </ | ||
| - | =====LAB #14 - Préparer Windows 10===== | + | ====1.1 - Instructions |
| - | ====Mettre à Jour PowerShell et .NET==== | + | Il vous est demandé d' |
| - | Afin de mettre | + | * l' |
| + | * la mise à jour éventuelle | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | * user : bob | ||
| + | * mot de passe : tata | ||
| + | |||
| + | Installez donc Ansible à partir des dépôts | ||
| < | < | ||
| - | Windows PowerShell | + | [trainee@centos7 ~]$ su - |
| - | Copyright (C) Microsoft Corporation. Tous droits réservés. | + | 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 | ||
| + | </ | ||
| - | Testez le nouveau système multiplateforme PowerShell https:// | + | Vérifiez ensuite la présence des exécutables |
| - | PS C: | + | <code> |
| - | PS C: | + | [root@centos7 ~]# which ansible |
| - | PS C: | + | /bin/ansible |
| - | PS C: | + | [root@centos7 ~]# which ansible-playbook |
| - | PS C: | + | / |
| - | PS C: | + | |
| - | PS C: | + | |
| - | COMMENTAIRES : | + | |
| - | COMMENTAIRES : | + | |
| - | COMMENTAIRES : | + | |
| </ | </ | ||
| - | Au cas où, vous pouvez enlever l' | + | Afin de vous aider, on vous fournit deux fichiers |
| < | < | ||
| - | PS C: | + | [root@centos7 ~]# cat vsftpd.yml |
| - | PS C:\Windows\system32> | + | --- |
| - | PS C:\Windows\system32> | + | - name: ftp server install |
| - | PS C:\Windows\system32> | + | hosts: localhost |
| - | PS C:\Windows\system32> | + | |
| - | PS C:\Windows\system32> | + | become: yes |
| + | vars_files: | ||
| + | | ||
| + | tasks: | ||
| + | | ||
| + | yum: | ||
| + | name: vsftpd | ||
| + | state: latest | ||
| + | | ||
| + | name: firewalld | ||
| + | state: latest | ||
| + | | ||
| + | | ||
| + | name vsftpd | ||
| + | enabled: true | ||
| + | state: started | ||
| + | | ||
| + | service: | ||
| + | name: firewalld | ||
| + | enabled: true | ||
| + | state: started | ||
| + | | ||
| + | | ||
| + | permanent: yes | ||
| + | immediate: yes | ||
| + | state: enabled | ||
| + | | ||
| + | user: | ||
| + | password: "{{ item.password | password_hash(sha512) }}" | ||
| + | with_items: "{{ ftp_users }}" | ||
| </ | </ | ||
| - | ====Configurer WinRM==== | + | < |
| + | [root@centos7 ~]# ansible-vault view secrets.yml | ||
| + | Vault password: fenestros | ||
| + | ftp_users: | ||
| + | - { username: mike, password: toto } | ||
| + | - { username: bob, password: tata } | ||
| + | </ | ||
| - | Pour mettre en place un **listener** WinRM en HTTP et un **listener** WinRM en HTTPS, créer un certificat auto-signé et activer | + | Lors de l'exécution |
| < | < | ||
| - | PS C: | + | [root@centos7 ~]# ansible-playbook vsftpd.yml |
| - | PS C:\Windows\system32> | + | [WARNING]: Could not match supplied host pattern, ignoring: all |
| - | PS C:\Windows\system32> | + | |
| - | PS C: | + | [WARNING]: provided hosts list is empty, only localhost is available |
| - | Self-signed SSL certificate generated; thumbprint: 17502EEEAC259F4C76D0F199A4B803E94E980CAD | + | |
| + | ERROR! Syntax Error while loading YAML. | ||
| - | wxf : http:// | ||
| - | a : http:// | ||
| - | w : http:// | ||
| - | lang : fr-FR | ||
| - | Address | ||
| - | ReferenceParameters : ReferenceParameters | ||
| - | Ok. | + | 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 | ||
| - | PS C:\Windows\system32> | + | exception type: <class ' |
| + | exception: mapping values are not allowed in this context | ||
| + | in "< | ||
| </ | </ | ||
| - | ====Consulter les Informations sur WinRM==== | + | A vous de jouer ! |
| - | Pour voir la liste des listeners ainsi créés, utilisez la commande suivante : | + | [isauth account,@admin] |
| - | < | + | ====1.2 - Corrigés==== |
| - | PS C: | + | |
| - | Listener | + | |
| - | Address | + | |
| - | Transport | + | |
| - | Port = 5985 | + | |
| - | Hostname | + | |
| - | Enabled | + | |
| - | URLPrefix | + | |
| - | CertificateThumbprint | + | |
| - | ListeningOn | + | |
| - | Listener | + | ===Erreur #1=== |
| - | Address | + | |
| - | Transport | + | |
| - | Port = 5986 | + | |
| - | Hostname | + | |
| - | Enabled | + | |
| - | URLPrefix | + | |
| - | CertificateThumbprint = 17502EEEAC259F4C76D0F199A4B803E94E980CAD | + | |
| - | ListeningOn = 10.0.2.15, 10.29.0.34, 127.0.0.1, ::1 | + | |
| - | PS C: | + | Éditez |
| - | </ | + | |
| - | + | ||
| - | Pour obtenir les informations concernant | + | |
| < | < | ||
| - | PS C: | + | [root@centos7 ~]# vi vsftpd.yml |
| - | PS C: | + | [root@centos7 ~]# cat vsftpd.yml |
| - | + | --- | |
| - | + | - name: ftp server install | |
| - | PSPath | + | |
| - | E980CAD | + | |
| - | PSParentPath | + | |
| - | PSChildName | + | vars_files: |
| - | PSDrive | + | - users.yml |
| - | PSProvider | + | tasks: |
| - | PSIsContainer | + | - name: latest vsftpd version |
| - | EnhancedKeyUsageList | + | yum: |
| - | DnsNameList | + | name: vsftpd |
| - | SendAsTrustedIssuer | + | state: latest |
| - | EnrollmentPolicyEndPoint | + | - name: latest firewalld version |
| - | EnrollmentServerEndPoint | + | |
| - | PolicyId | + | name: firewalld |
| - | Archived | + | state: latest |
| - | Extensions | + | - name: vsftpd |
| - | System.Security.Cryptography.Oid, | + | |
| - | FriendlyName | + | name vsftpd |
| - | IssuerName | + | |
| - | NotAfter | + | state: started |
| - | NotBefore | + | - name: firewalld |
| - | HasPrivateKey | + | |
| - | PrivateKey | + | name: firewalld |
| - | PublicKey | + | |
| - | RawData | + | state: started |
| - | SerialNumber | + | - name: firewalld allows ftp |
| - | SubjectName | + | |
| - | SignatureAlgorithm | + | |
| - | Thumbprint | + | |
| - | Version | + | state: enabled |
| - | Handle | + | - name: Create_FTP_users |
| - | Issuer | + | user: |
| - | Subject | + | |
| - | + | | |
| - | + | ||
| - | + | ||
| - | PS C: | + | |
| </ | </ | ||
| - | Dernièrement pour obtenir des informations concernant le service, exécutez les deux commandes suivantes | + | Relancez la commande **ansible-playbook** |
| < | < | ||
| - | PS C: | + | [root@centos7 ~]# ansible-playbook vsftpd.yml |
| - | Service | + | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' |
| - | | + | ERROR! Syntax Error while loading YAML. |
| - | | + | |
| - | | + | |
| - | | + | The error appears to be in '/ |
| - | | + | be elsewhere in the file depending on the exact syntax problem. |
| - | MaxPacketRetrievalTimeSeconds = 120 | + | |
| - | AllowUnencrypted = false | + | |
| - | Auth | + | |
| - | Basic = true | + | |
| - | Kerberos = true | + | |
| - | Negotiate = true | + | |
| - | Certificate = false | + | |
| - | CredSSP = false | + | |
| - | CbtHardeningLevel = Relaxed | + | |
| - | DefaultPorts | + | |
| - | HTTP = 5985 | + | |
| - | HTTPS = 5986 | + | |
| - | IPv4Filter = * | + | |
| - | IPv6Filter = * | + | |
| - | EnableCompatibilityHttpListener = false | + | |
| - | EnableCompatibilityHttpsListener = false | + | |
| - | CertificateThumbprint | + | |
| - | | + | |
| - | PS C:\Windows\system32> | + | The offending line appears to be: |
| - | Winrs | + | |
| - | AllowRemoteShellAccess = true | + | |
| - | IdleTimeout = 7200000 | + | |
| - | MaxConcurrentUsers = 2147483647 | + | |
| - | MaxShellRunTime = 2147483647 | + | |
| - | MaxProcessesPerShell = 2147483647 | + | |
| - | MaxMemoryPerShellMB = 2147483647 | + | |
| - | MaxShellsPerUser = 2147483647 | + | |
| - | PS C:\Windows\system32> | + | name vsftpd |
| + | enabled: true | ||
| + | ^ here | ||
| </ | </ | ||
| - | ====Créer un Utilisateur Local pour Ansible==== | + | ===Erreur #2=== |
| - | Créez un utilisateur local appelé **trainee ayant un mot de passe trainee** et le type de compte | + | Editez |
| - | + | ||
| - | Exécutez ensuite la commande suivante | + | |
| < | < | ||
| - | PS C: | + | [root@centos7 ~]# vi vsftpd.yml |
| - | Service | + | [root@centos7 ~]# cat vsftpd.yml |
| - | | + | --- |
| - | | + | - name: ftp server install |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | yum: |
| - | | + | |
| - | | + | |
| - | | + | - name: latest firewalld version |
| - | | + | yum: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
| - | | + | |
| - | | + | |
| - | | + | - name: vsftpd |
| - | | + | service: |
| - | | + | |
| - | | + | |
| - | | + | state: started |
| - | | + | |
| - | | + | service: |
| - | + | | |
| - | PS C:\Windows\system32> | + | |
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | state: enabled | ||
| + | | ||
| + | user: | ||
| + | | ||
| + | with_items: "{{ ftp_users }}" | ||
| </ | </ | ||
| - | Dans la fenêtre | + | Relancez |
| - | + | ||
| - | {{ : | + | |
| - | + | ||
| - | =====LAB #15 - Préparer le Contrôleur Ansible===== | + | |
| - | + | ||
| - | ====Installer pywinrm==== | + | |
| - | + | ||
| - | Dans la machine virtuelle **Ansible**, installez le support python pour WinRM : | + | |
| < | < | ||
| - | root@ansible:~# pip3 install " | + | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' |
| - | Collecting pywinrm> | + | ERROR! vars file users.yml was not found |
| - | | + | Could not find file on the Ansible Controller. |
| - | Collecting requests-ntlm> | + | If you are using a module and expect the file to exist on the remote, see the remote_src option |
| - | Downloading https:// | + | |
| - | Collecting xmltodict (from pywinrm> | + | |
| - | Downloading https:// | + | |
| - | Requirement already satisfied: six in / | + | |
| - | Requirement already satisfied: requests> | + | |
| - | Collecting ntlm-auth> | + | |
| - | Downloading https:// | + | |
| - | Requirement already satisfied: cryptography> | + | |
| - | Installing collected packages: ntlm-auth, requests-ntlm, | + | |
| - | Successfully installed ntlm-auth-1.4.0 pywinrm-0.3.0 requests-ntlm-1.1.0 xmltodict-0.12.0 | + | |
| </ | </ | ||
| - | ====Tester la Configuration==== | + | ===Erreur #3=== |
| - | Pour tester la configuration, | + | Créez |
| < | < | ||
| - | root@ansible:~# vi /etc/hosts | + | [root@centos7 |
| - | root@ansible:~# cat / | + | [root@centos7 |
| - | 127.0.0.1 localhost | + | ftp_users: |
| - | 127.0.1.1 ansible.i2tch.loc | + | |
| - | 10.0.2.9 ansible.i2tch.loc | + | |
| - | 10.0.2.10 | + | |
| - | 10.0.2.11 web01.i2tch.loc web01 | + | |
| - | 10.0.2.12 web02.i2tch.loc web02 | + | |
| - | 10.0.2.13 web03.i2tch.loc web03 | + | |
| - | 10.0.2.14 web04.i2tch.loc web04 | + | |
| - | 10.0.2.15 | + | |
| - | + | ||
| - | # The following lines are desirable for IPv6 capable hosts | + | |
| - | ::1 | + | |
| - | ff02::1 ip6-allnodes | + | |
| - | ff02::2 ip6-allrouters | + | |
| - | root@ansible:~# exit | + | |
| - | déconnexion | + | |
| - | trainee@ansible:~$ | + | |
| </ | </ | ||
| - | Créez ensuite un Inventory file en tant que trainee | + | Relancez la commande **ansible-playbook** |
| < | < | ||
| - | trainee@ansible:~$ vi inventory | + | [root@centos7 |
| - | trainee@ansible:~$ cat inventory | + | [root@centos7 |
| - | [windows] | + | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' |
| - | windows10 | + | |
| - | [windows: | + | PLAY [ftp server install] *********************************************************************************************************************************************** |
| - | ansible_user=trainee | + | |
| - | ansible_password=trainee | + | |
| - | ansible_connection=winrm | + | |
| - | ansible_winrm_server_cert_validation=ignore | + | |
| - | </ | + | |
| - | Procédez au test : | + | TASK [latest vsftpd version] ******************************************************************************************************************************************** |
| + | changed: [localhost] | ||
| - | < | + | TASK [latest firewalld version] ***************************************************************************************************************************************** |
| - | trainee@ansible: | + | changed: |
| - | windows10 | SUCCESS => { | + | |
| - | "changed": false, | + | |
| - | " | + | |
| - | } | + | |
| - | </ | + | |
| - | =====LAB #16 - Travailler avec Ansible et Windows===== | + | TASK [vsftpd] *********************************************************************************************************************************************************** |
| + | changed: [localhost] | ||
| - | ====Obtenir les Informations sur Windows10==== | + | TASK [firewalld] ******************************************************************************************************************************************************** |
| + | ok: [localhost] | ||
| - | De la même façon qu' | + | TASK [firewalld allows ftp] ********************************************************************************************************************************************* |
| + | ok: [localhost] | ||
| - | < | + | TASK [Create_FTP_users] ************************************************************************************************************************************************* |
| - | trainee@ansible:~$ ansible windows -i inventory -m setup | + | fatal: [localhost]: |
| - | windows10 | SUCCESS | + | |
| - | | + | PLAY RECAP ************************************************************************************************************************************************************** |
| - | | + | localhost |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | ], | + | |
| - | " | + | |
| - | "10.0.2.15" | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | ], | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | } | + | |
| </ | </ | ||
| - | ====Exécutez une Commande==== | + | ===Erreurs 4, 5 et 6=== |
| - | + | ||
| - | Créez le PlayBook **command.yml** : | + | |
| < | < | ||
| - | trainee@ansible:~$ vi command.yml | + | [root@centos7 |
| - | trainee@ansible:~$ cat command.yml | + | [root@centos7 |
| --- | --- | ||
| - | - name: ipconfig | + | - name: ftp server install |
| - | hosts: | + | hosts: |
| + | gather_facts: | ||
| + | become: yes | ||
| + | vars_files: | ||
| + | - users.yml | ||
| tasks: | tasks: | ||
| - | - name: run ipconfig | + | - name: latest vsftpd version |
| - | | + | |
| - | | + | name: vsftpd |
| - | - debug: var=ipconfig | + | 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: | ||
| + | name: "{{ item.username }}" | ||
| + | password: "{{ item.password | password_hash(' | ||
| + | with_items: "{{ ftp_users }}" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| </ | </ | ||
| - | Exécutez le PlayBook | + | Relancez la commande **ansible-playbook** |
| < | < | ||
| - | trainee@ansible:~$ ansible-playbook | + | [root@centos7 |
| + | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' | ||
| - | PLAY [ipconfig] ********************************************************************************************************************************************************* | + | PLAY [ftp server install] *********************************************************************************************************************************************** |
| - | TASK [Gathering Facts] ************************************************************************************************************************************************** | + | TASK [latest vsftpd version] ******************************************************************************************************************************************** |
| - | ok: [windows10] | + | ok: [localhost] |
| - | TASK [run ipconfig] ***************************************************************************************************************************************************** | + | TASK [latest firewalld version] ***************************************************************************************************************************************** |
| - | changed: [windows10] | + | ok: [localhost] |
| - | TASK [debug] ************************************************************************************************************************************************************ | + | TASK [vsftpd] *********************************************************************************************************************************************************** |
| - | ok: [windows10] => { | + | ok: [localhost] |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | "", | + | |
| - | " | + | |
| - | "", | + | |
| - | "", | + | |
| - | "Carte Ethernet Ethernet 2 :", | + | |
| - | "", | + | |
| - | " | + | |
| - | " | + | |
| - | "", | + | |
| - | "Carte Ethernet Ethernet :", | + | |
| - | "", | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | ] | + | |
| - | } | + | |
| - | } | + | |
| - | PLAY RECAP ************************************************************************************************************************************************************** | + | TASK [firewalld] |
| - | windows10 | + | ok: [localhost] |
| - | </ | + | |
| - | ====Exécuter un script PowerShell==== | + | TASK [firewalld allows ftp] ********************************************************************************************************************************************* |
| + | ok: [localhost] | ||
| - | Créez un script PowerShell pour démarrer le service Windows Update | + | TASK [Create_FTP_users] ************************************************************************************************************************************************* |
| + | changed: [localhost] => (item={u' | ||
| + | changed: [localhost] => (item={u' | ||
| - | < | + | PLAY RECAP ************************************************************************************************************************************************************** |
| - | trainee@ansible:~$ vi script1.ps1 | + | localhost |
| - | trainee@ansible: | + | |
| - | Start-Service -Name wuauserv | + | |
| </ | </ | ||
| - | Créez ensuite un PlayBook appelé **winupdate.yml** : | + | Crypter le fichier users.yml : |
| < | < | ||
| - | trainee@ansible:~$ vi winupdate.yml | + | [root@centos7 |
| - | trainee@ansible:~$ cat winupdate.yml | + | New Vault password: fenestros |
| - | - name: " | + | Confirm New Vault password: fenestros |
| - | hosts: " | + | Encryption successful |
| - | | + | |
| - | tasks: | + | |
| - | - name: " | + | |
| - | script: " | + | |
| </ | </ | ||
| - | Exécutez | + | Consultez |
| < | < | ||
| - | trainee@ansible:~$ ansible-playbook winupdate.yml -i inventory | + | [root@centos7 |
| + | Vault password: | ||
| + | ftp_users: | ||
| + | - { username: mike, password: toto } | ||
| + | - { username: bob, password: tata } | ||
| - | PLAY [PowerShell script] ************************************************************************************************************************************************ | + | [root@centos7 ~]# cat users.yml |
| - | + | $ANSIBLE_VAULT; | |
| - | TASK [Windows Update] *************************************************************************************************************************************************** | + | 30323061313265353234666230373765333865663061626362646332376639356463623238343166 |
| - | changed: [windows10] | + | 3635356261383732373633626230353837393735393933390a323561663963666262343835363166 |
| - | + | 61306137383463303138656131626236633935383031323864396164366139323265653732663834 | |
| - | PLAY RECAP ************************************************************************************************************************************************************** | + | 6130656163356661360a663635333537373961616230353766666130633537323065663161393939 |
| - | windows10 | + | 65353936613539303631373530643536616335356461323735646165616136303839636166663232 |
| + | 38616133393235636632646461346430373966306463636662333431373936633837616336326461 | ||
| + | 38633139616339343865626630333531366138313761663330346231333131346535663761396233 | ||
| + | 35353036373530323636636335336539616433373461653866316138306632323038626266623264 | ||
| + | 6634 | ||
| </ | </ | ||
| - | ====Installer un Logiciel avec Chocolatey==== | + | Exécutez le playbook : |
| - | **[[https:// | + | < |
| + | [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 ' | ||
| - | Créez le PlayBook | + | PLAY [ftp server install] ************************************************************************************************************************************************* |
| - | < | + | TASK [latest vsftpd version] ********************************************************************************************************************************************** |
| - | trainee@ansible:~$ vi firefox.yml | + | ok: [localhost] |
| - | trainee@ansible: | + | |
| - | --- | + | |
| - | - name: Install Firefox using Chocolatey | + | |
| - | hosts: all | + | |
| - | tasks: | + | |
| - | - name: Install Firefox | + | |
| - | win_chocolatey: | + | |
| - | name: firefox | + | |
| - | state: present | + | |
| - | </ | + | |
| - | Exécutez le PlayBook | + | TASK [latest firewalld version] ******************************************************************************************************************************************* |
| + | ok: [localhost] | ||
| - | < | + | TASK [vsftpd] ************************************************************************************************************************************************************* |
| - | trainee@ansible:~$ ansible-playbook firefox.yml -i inventory | + | ok: [localhost] |
| - | PLAY [Install Firefox using Chocolatey] ********************************************************************************************************************************* | + | TASK [firewalld] ********************************************************************************************************************************************************** |
| + | ok: [localhost] | ||
| - | TASK [Gathering Facts] ************************************************************************************************************************************************** | + | TASK [firewalld allows ftp] *********************************************************************************************************************************************** |
| - | ok: [windows10] | + | ok: [localhost] |
| - | TASK [Install Firefox] ************************************************************************************************************************************************** | + | TASK [Create_FTP_users] *************************************************************************************************************************************************** |
| - | [WARNING]: Chocolatey was missing from this system, so it was installed during this task run. | + | changed: |
| + | changed: [localhost] => (item={u' | ||
| - | changed: [windows10] | + | PLAY RECAP **************************************************************************************************************************************************************** |
| - | + | localhost | |
| - | PLAY RECAP ************************************************************************************************************************************************************** | + | |
| - | windows10 | + | |
| </ | </ | ||
| - | ====Créer un Utilisateur Local==== | + | Notez que malgré le fait que le fichier **users.yml** soit crypté, les mots de passe des utilisateurs apparaissent en clair lors de l' |
| - | Créez le PlayBook **user.yml** : | ||
| < | < | ||
| - | trainee@ansible:~$ vi users.yml | + | [root@centos7 |
| - | trainee@ansible:~$ cat users.yml | + | [root@centos7 |
| - | --- | + | ... |
| - | - name: Create a user | + | - name: Create_FTP_users |
| - | hosts: windows | + | |
| - | tasks: | + | name: "{{ item.username }}" # pas d' |
| - | - name: Create Jean | + | password: |
| - | | + | |
| - | name: jean | + | |
| - | password: | + | |
| - | state: present | + | |
| - | | + | |
| - | - utilisateurs | + | |
| </ | </ | ||
| - | Exécutez le PlayBook | + | De cette façon lors de l' |
| < | < | ||
| - | trainee@ansible:~$ ansible-playbook | + | [root@centos7 |
| + | 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 [Create a user] **************************************************************************************************************************************************** | + | PLAY RECAP **************************************************************************************************************************************************************** |
| - | + | localhost | |
| - | TASK [Gathering Facts] ************************************************************************************************************************************************** | + | |
| - | ok: [windows10] | + | |
| - | + | ||
| - | TASK [Create Jean] ****************************************************************************************************************************************************** | + | |
| - | changed: [windows10] | + | |
| - | + | ||
| - | PLAY RECAP ************************************************************************************************************************************************************** | + | |
| - | windows10 | + | |
| </ | </ | ||
| - | Vérifiez que le compte a été créé : | + | [/isauth] |
| - | {{ : | + | ----- |
| - | ----- | + | Copyright © 2022 Hugh Norris. |
| - | < | + | |
| - | <div align=" | + | |
| - | Copyright © 2020 Hugh NORRIS | + | |
| - | </ | + | |
| - | </ | + | |