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 [2021/12/29 10:30] – 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 |
| =====Contenu du Module===== | =====Contenu du Module===== | ||
| - | * **DOF505 | + | * **LCF805 |
| * Contenu du Module | * Contenu du Module | ||
| - | | + | * LAB #1 - Automatiser avec Ansible |
| - | | + | * 1.1 - Instructions |
| - | * 1.1 - Mettre à Jour PowerShell et .NET | + | * 1.2 - Corrigés |
| - | * 1.2 - Configurer WinRM | + | * Erreur #1 |
| - | * 1.3 - Consulter les Informations sur WinRM | + | * Erreur |
| - | * 1.4 - Créer un Utilisateur Local pour Ansible | + | * Erreur |
| - | * LAB #2 - Préparer le Contrôleur Ansible | + | * Erreurs |
| - | * 2.1 - Installer pywinrm | + | |
| - | * 2.2 - Tester la Configuration | + | |
| - | * LAB #3 - Travailler avec Ansible et Windows | + | |
| - | * 3.1 - Obtenir les Informations sur Windows10 | + | |
| - | * 3.2 - Exécuter une Commande | + | |
| - | * 3.3 - Exécuter un script PowerShell | + | |
| - | * 3.4 - Installer un Logiciel avec Chocolatey | + | |
| - | * 3.5 - Créer un Utilisateur Local | + | |
| - | =====Pré-requis Windows===== | + | =====LAB #1 - Automatiser avec Ansible===== |
| - | Ansible est capable de travailler avec les versions de Windows(tm) suivantes | + | Connectez-vous à la machine virtuelle **CentOS_7** |
| - | * Windows(tm) 7, | + | < |
| - | * Windows(tm) 8.1, | + | trainee@traineeXX: |
| - | * 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 : | + | ====1.1 - Instructions ==== |
| - | * PowerShell 3.0 ou supérieur | + | Il vous est demandé d' |
| - | * Au moins .NET 4.0. | + | |
| - | =====LAB #1 - Préparer Windows 10===== | + | * 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 | ||
| - | ====1.1 - Mettre | + | Installez donc Ansible |
| - | + | ||
| - | Afin de mettre à jour les versions de PowerShell et .NET, Ansible fournit un script appelé **Upgrade-PowerShell.ps1**. Exécutez PowerShell en tant qu' | + | |
| < | < | ||
| - | 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: | + | /bin/ansible-playbook |
| - | 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 }}" | ||
| </ | </ | ||
| - | ====1.2 - 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 "< | ||
| </ | </ | ||
| - | ====1.3 - 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.58, 10.29.0.34, 127.0.0.1, ::1 | + | |
| - | PS C:\Windows\system32> | + | Éditez le fichier **vsftpd.yml** |
| + | |||
| + | <code> | ||
| + | [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 }}" | ||
| </ | </ | ||
| - | Pour obtenir les informations concernant le certificat, exécutez les commandes suivantes | + | Relancez la commande **ansible-playbook** |
| < | < | ||
| - | PS C: | + | [root@centos7 ~]# ansible-playbook vsftpd.yml |
| - | PS C:\Windows\system32> | + | [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. | ||
| - | PSPath | + | The offending line appears to be: |
| - | | + | |
| - | PSParentPath | + | |
| - | PSChildName | + | |
| - | PSDrive | + | |
| - | PSProvider | + | |
| - | PSIsContainer | + | |
| - | EnhancedKeyUsageList | + | |
| - | DnsNameList | + | |
| - | SendAsTrustedIssuer | + | |
| - | EnrollmentPolicyEndPoint : Microsoft.CertificateServices.Commands.EnrollmentEndPointProperty | + | |
| - | EnrollmentServerEndPoint : Microsoft.CertificateServices.Commands.EnrollmentEndPointProperty | + | |
| - | PolicyId | + | |
| - | Archived | + | |
| - | Extensions | + | |
| - | | + | |
| - | FriendlyName | + | |
| - | IssuerName | + | |
| - | NotAfter | + | |
| - | NotBefore | + | |
| - | HasPrivateKey | + | |
| - | PrivateKey | + | |
| - | PublicKey | + | |
| - | RawData | + | |
| - | SerialNumber | + | |
| - | SubjectName | + | |
| - | SignatureAlgorithm | + | |
| - | Thumbprint | + | |
| - | Version | + | |
| - | Handle | + | |
| - | Issuer | + | |
| - | Subject | + | |
| + | name vsftpd | ||
| + | enabled: true | ||
| + | ^ here | ||
| + | </ | ||
| + | ===Erreur #2=== | ||
| - | PS C: | + | Editez |
| - | </ | + | |
| - | + | ||
| - | Dernièrement pour obtenir des informations concernant | + | |
| < | < | ||
| - | PS C: | + | [root@centos7 ~]# vi vsftpd.yml |
| - | Service | + | [root@centos7 ~]# cat vsftpd.yml |
| - | | + | --- |
| - | | + | - name: ftp server install |
| - | | + | hosts: localhost |
| - | | + | gather_facts: no |
| - | | + | become: yes |
| - | | + | |
| - | AllowUnencrypted = false | + | |
| - | Auth | + | |
| - | | + | |
| - | | + | yum: |
| - | | + | |
| - | | + | |
| - | | + | - name: latest firewalld version |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | service: |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | AllowRemoteAccess = true | + | |
| - | + | name: firewalld | |
| - | PS C:\Windows\system32> | + | |
| - | Winrs | + | state: started |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | user: |
| - | + | | |
| - | PS C:\Windows\system32> | + | |
| </ | </ | ||
| - | ====1.4 - Créer un Utilisateur Local pour Ansible==== | + | Relancez |
| - | + | ||
| - | Exécutez ensuite | + | |
| < | < | ||
| - | PS C:\Windows\system32> | + | [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ' |
| - | Service | + | 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 |
| - | MaxConcurrentOperationsPerUser = 1500 | + | |
| - | EnumerationTimeoutms = 240000 | + | |
| - | MaxConnections = 300 | + | |
| - | 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 | + | |
| - | AllowRemoteAccess = true | + | |
| - | + | ||
| - | PS C: | + | |
| </ | </ | ||
| - | Dans la fenêtre **Autorisations pour Default**, ajoutez l' | + | ===Erreur |
| - | + | ||
| - | {{ : | + | |
| - | + | ||
| - | =====LAB #2 - Préparer le Contrôleur Ansible===== | + | |
| - | + | ||
| - | ====2.1 - Installer pywinrm==== | + | |
| - | Dans la machine virtuelle | + | Créez le fichier |
| < | < | ||
| - | root@ansible:~# pip3 install " | + | [root@centos7 |
| - | Collecting pywinrm> | + | [root@centos7 ~]# cat users.yml |
| - | | + | ftp_users: |
| - | Collecting requests-ntlm> | + | |
| - | 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 | + | |
| </ | </ | ||
| - | ====2.2 | + | Relancez la commande **ansible-playbook** |
| - | + | ||
| - | Pour tester la configuration, | + | |
| < | < | ||
| - | 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=a39dae707d | + | |
| - | 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 #3 - Travailler avec Ansible et Windows===== | + | TASK [vsftpd] *********************************************************************************************************************************************************** |
| + | changed: [localhost] | ||
| - | ====3.1 - Obtenir les Informations sur Windows 10==== | + | 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" | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | ], | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | ], | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | } | + | |
| </ | </ | ||
| - | ====3.2 - 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] |
| - | </ | + | |
| - | ====3.3 - 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 | ||
| </ | </ | ||
| - | ====3.4 - 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 | + | |
| </ | </ | ||
| - | ====3.5 - 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. | Copyright © 2022 Hugh Norris. | ||