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:part4 [2022/03/09 18:44] – admin | elearning:workbooks:debian:6:avance:l130:part4 [2023/08/25 01:31] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version | + | Version |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ====== | + | ======LCF804 |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **DOF504 | + | * **LCF804 |
* Contenu du Module | * Contenu du Module | ||
- | * LAB #1 - Utilisation des Facts d'Ansible | + | * LAB #1 - Ansible |
- | * LAB #2 - La Commande ansible-vault | + | * 1.1 - Présentation de Docker |
- | * 2.1 - Crypter le Fichier | + | * 1.2 - Installer Docker |
- | * 2.2 - Editer le Fichier | + | * 1.3 - La Connexion à Docker |
- | * 2.3 - Décrypter le Fichier | + | * LAB #2 - Préparer Windows 10 |
- | * 2.4 - Utilisation de Mots de Passe Aléatoires | + | * 2.1 - Mettre à Jour PowerShell et .NET |
- | * LAB #3 - Ansible | + | * 2.2 - Configurer WinRM |
- | * 3.1 - Présentation de Docker | + | * 2.3 - Consulter les Informations sur WinRM |
- | * 3.2 - Installer Docker | + | * 2.4 - Créer un Utilisateur Local pour Ansible |
- | * 3.3 - La Connexion à Docker | + | * LAB #3 - Préparer le Contrôleur |
+ | * 3.1 - Installer pywinrm | ||
+ | * 3.2 - Tester la Configuration | ||
+ | * 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 | ||
- | =====LAB #1 - Utilisation des Facts d'Ansible===== | + | =====LAB #1 - Ansible |
- | Ansible Facts sont : | + | ====1.1 - Présentation de Docker==== |
- | * des variables collectées automatiquement par le module | + | Docker est une application de virtualisation légère qui utilise |
- | | + | |
- | Il est cependant possible | + | Une **image** |
- | <code> | + | * le code |
- | [trainee@centos8 roles]$ ansible all -i web01, -m setup | more | + | * un runtime |
- | web01 | SUCCESS => { | + | * des bibliothèques, |
- | " | + | * des variables d' |
- | " | + | * des fichiers de configuration |
- | " | + | |
- | ], | + | |
- | " | + | |
- | " | + | |
- | ], | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | --More-- | + | |
- | </ | + | |
- | <WRAP center round important 60%> | + | Un **conteneur** est une instance |
- | **Important** : Notez que le nom de chaque **Fact** commence par **ansible_**. Évitez donc de créer | + | |
- | </ | + | |
- | Parmi les Facts, les plus utiles | + | Les conteneurs exécutent des applications nativement en utilisant le noyau de la machine hôte. De ce fait les performances d'un conteneur |
- | | + | Docker existe en deux versions |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | Ainsi que dictionnaire **ansible_default_ipv4** : | + | ====1.2 - Installer docker==== |
- | < | + | Docker n'est pas dans le dépôts de CentOS. Afin de l' |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | </ | + | |
- | + | ||
- | Modifiez | + | |
< | < | ||
- | [trainee@centos8 roles]$ | + | [trainee@centos8 roles]$ |
- | [trainee@centos8 | + | Password: fenestros |
- | [linux] | + | [root@centos8 |
- | targeta | + | Adding repo from: https:// |
- | targetb | + | |
- | [group1] | + | [root@centos8 ~]# dnf list docker-ce |
- | localhost ansible_connection=local | + | Docker CE Stable - x86_64 |
+ | Last metadata expiration check: 0:00:01 ago on Wed 09 Mar 2022 12:38:58 EST. | ||
+ | Available Packages | ||
+ | docker-ce.x86_64 | ||
+ | </ | ||
- | [basededonnees] | + | Installez ensuite la dépendance **containerd** de docker-ce : |
- | web01 | + | |
- | [dotcms] | + | < |
- | web02 | + | [root@centos8 ~]# dnf install https:// |
- | web03 | + | Last metadata expiration check: 0:06:03 ago on Wed 09 Mar 2022 12:38:58 EST. |
+ | containerd.io-1.2.10-3.2.el7.x86_64.rpm | ||
+ | Dependencies resolved. | ||
+ | ================================================================================================================================================================================================================== | ||
+ | | ||
+ | ================================================================================================================================================================================================================== | ||
+ | Installing: | ||
+ | containerd.io | ||
+ | replacing | ||
- | [equilibrage] | + | Transaction Summary |
- | web04 | + | ================================================================================================================================================================================================================== |
+ | Install | ||
- | [debian:children] | + | Total size: 23 M |
- | basededonnees | + | Is this ok [y/N]: y |
- | dotcms | + | |
- | equilibrage | + | |
- | + | ||
- | [debian:vars] | + | |
- | ansible_user=trainee | + | |
</ | </ | ||
- | Modifiez | + | Installez maintenant |
< | < | ||
- | [trainee@centos8 | + | [root@centos8 |
- | [trainee@centos8 roles]$ cat playbook.yaml | + | |
- | --- | + | |
- | - hosts: all | + | |
- | become: true | + | |
- | roles: | + | |
- | | + | |
</ | </ | ||
- | Connectez-vous à la machine TargetA | + | Dernièrement, |
< | < | ||
- | [trainee@centos8 | + | [root@centos8 |
- | Debian GNU/Linux 9 | + | [root@centos8 ~]# systemctl start docker |
- | Linux targeta.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | + | [root@centos8 ~]# systemctl status docker |
+ | ● docker.service - Docker Application Container Engine | ||
+ | Loaded: loaded (/usr/ | ||
+ | Active: activating (start) since Wed 2022-03-09 12:48:23 EST; 51s ago | ||
+ | Docs: https:// | ||
+ | Main PID: 59410 (dockerd) | ||
+ | Tasks: 16 | ||
+ | | ||
+ | | ||
+ | | ||
- | The programs included with the Debian GNU/Linux system are free software; | + | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: |
- | the exact distribution terms for each program are described in the | + | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: |
- | individual files in /usr/share/doc/*/copyright. | + | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: |
+ | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: | ||
+ | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: | ||
+ | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | ||
+ | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | ||
+ | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | ||
+ | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | ||
+ | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | ||
+ | [root@centos8 ~]# docker --version | ||
+ | Docker version 20.10.12, build e91ed57 | ||
+ | [root@centos8 ~]# docker version | ||
+ | Client: Docker Engine - Community | ||
+ | | ||
+ | API version: | ||
+ | Go version: | ||
+ | Git commit: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
- | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | + | Server: Docker Engine - Community |
- | permitted by applicable law. | + | Engine: |
- | Last login: Wed Mar 9 11:29:25 2022 from 10.0.2.45 | + | Version: |
- | trainee@targeta:~$ sudo apt-get -y remove openjdk-8-jre | + | API version: 1.40 (minimum version 1.12) |
- | ... | + | Go version: go1.13.15 |
- | trainee@targeta:~$ exit | + | Git commit: |
- | déconnexion | + | Built: |
- | Connection to 10.0.2.52 closed. | + | OS/ |
- | [trainee@centos8 roles]$ | + | Experimental: |
+ | | ||
+ | Version: | ||
+ | | ||
+ | runc: | ||
+ | Version: | ||
+ | | ||
+ | docker-init: | ||
+ | | ||
+ | | ||
</ | </ | ||
- | Utilisez la commande scp pour copier le fichier authorized_keys | + | <WRAP center round important> |
+ | **Important** - Docker est composé | ||
+ | </ | ||
- | < | + | Démarrez un conteneur dénommé **postgresql** en mode détaché |
- | [trainee@centos8 roles]$ cd ~ | + | |
- | [trainee@centos8 ~]$ scp .ssh/ | + | |
- | trainee@10.0.2.53' | + | |
- | authorized_keys | + | |
- | [trainee@centos8 ~]$ cd - | + | |
- | / | + | |
- | [trainee@centos8 roles]$ | + | |
- | </ | + | |
- | + | ||
- | Connectez-vous | + | |
< | < | ||
- | [trainee@centos8 | + | [root@centos8 ~]# docker run -d --name postgresql centos sleep infinity |
- | Last login: Wed Mar 9 16:51:41 2022 from 10.0.2.45 | + | Unable to find image ' |
- | [trainee@targetb | + | latest: Pulling from library/ |
- | ... | + | a1d0c7532777: |
- | [trainee@targetb ~]$ exit | + | Digest: sha256: |
- | logout | + | Status: Downloaded newer image for centos: |
- | Connection to 10.0.2.53 closed. | + | 1028e25f81d14d685678794902cd599aa618eb283d80e274526d71ec9708e69d |
- | [trainee@centos8 roles]$ | + | |
</ | </ | ||
- | Grâce au Fact **ansible_os_family** il est possible d' | + | Vérifiez que le conteneur fonctionne |
< | < | ||
- | [trainee@centos8 | + | [root@centos8 |
- | [trainee@centos8 roles]$ cat exemple01.java/ | + | CONTAINER ID |
- | --- | + | 1028e25f81d1 |
- | - name: install jre (Debian) | + | |
- | package: name=openjdk-8-jre state=present | + | |
- | when: ansible_os_family == ' | + | |
- | + | ||
- | - name: install jre (CentOS) | + | |
- | package: name=java-1.8.0-openjdk state=present | + | |
- | when: ansible_os_family == ' | + | |
</ | </ | ||
- | Modifiez le fichier | + | Ajoutez |
< | < | ||
- | [trainee@centos8 roles]$ su - | + | [root@centos8 ~]# usermod -aG docker trainee |
- | Password: fenestros | + | |
- | [root@centos8 ~]# vi / | + | |
- | [root@centos8 ~]# cat / | + | |
- | 127.0.0.1 | + | |
- | ::1 | + | |
- | 10.0.2.45 centos8.ittraining.loc centos8 | + | |
- | 10.0.2.54 web01.i2tch.loc web01 | + | |
- | 10.0.2.55 web02.i2tch.loc web02 | + | |
- | 10.0.2.56 web03.i2tch.loc web03 | + | |
- | 10.0.2.57 web04.i2tch.loc web04 | + | |
- | 10.0.2.52 targeta.i2tch.loc targeta | + | |
- | 10.0.2.53 targetb.i2tch.loc targetb | + | |
[root@centos8 ~]# exit | [root@centos8 ~]# exit | ||
logout | logout | ||
Ligne 252: | Ligne 187: | ||
</ | </ | ||
- | Connectez-vous | + | Rejoignez le groupe **docker** |
< | < | ||
- | [trainee@centos8 roles]$ | + | [trainee@centos8 roles]$ |
- | The authenticity of host ' | + | </code> |
- | ECDSA key fingerprint is SHA256: | + | |
- | Are you sure you want to continue connecting (yes/ | + | |
- | Warning: Permanently added ' | + | |
- | Debian GNU/Linux 9 | + | |
- | Linux targeta.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | + | |
- | The programs included with the Debian GNU/Linux system are free software; | + | ====1.3 - La Connexion à Docker==== |
- | the exact distribution terms for each program are described in the | + | |
- | individual files in / | + | |
- | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | + | Créez maintenant le Rôle **docker** |
- | permitted by applicable law. | + | |
- | Last login: Wed Mar 9 16:52:16 2022 from 10.0.2.45 | + | |
- | + | ||
- | trainee@targeta: | + | |
- | Réception de:1 http:// | + | |
- | Ign:2 http:// | + | |
- | Réception de:3 http:// | + | |
- | Réception de:4 http:// | + | |
- | Réception de:5 http:// | + | |
- | Réception de:6 http:// | + | |
- | Réception de:7 http:// | + | |
- | Réception de:8 http:// | + | |
- | Réception de:9 http:// | + | |
- | Réception de:10 http:// | + | |
- | Réception de:11 http:// | + | |
- | 21,0 Mo réceptionnés en 7s (2 753 ko/s) | + | |
- | Lecture des listes de paquets... Fait | + | |
- | Construction de l' | + | |
- | Lecture des informations d' | + | |
- | 333 packages can be upgraded. Run 'apt list --upgradable' | + | |
- | + | ||
- | trainee@targeta: | + | |
- | déconnexion | + | |
- | Connection to targeta closed. | + | |
- | </ | + | |
- | + | ||
- | Connectez-vous en ssh à targetb et testez la configuration de sudo : | + | |
< | < | ||
- | [trainee@centos8 roles]$ | + | [trainee@centos8 roles]$ |
- | The authenticity of host ' | + | |
- | ECDSA key fingerprint is SHA256: | + | |
- | Are you sure you want to continue connecting (yes/ | + | |
- | Warning: Permanently added ' | + | |
- | Last login: Wed Mar 9 16:56:33 2022 from 10.0.2.45 | + | |
- | + | ||
- | [trainee@targetb ~]$ yum clean all | + | |
- | Loaded plugins: fastestmirror, | + | |
- | Cleaning repos: base extras updates | + | |
- | Other repos take up 190 M of disk space (use --verbose for details) | + | |
- | + | ||
- | [trainee@targetb ~]$ sudo yum -y makecache | + | |
- | Loaded plugins: fastestmirror, | + | |
- | Loading mirror speeds from cached hostfile | + | |
- | * base: centos.mirror.ate.info | + | |
- | * extras: mirror.plusserver.com | + | |
- | * updates: mirror.plusserver.com | + | |
- | base | 3.6 kB 00: | + | |
- | extras | + | |
- | updates | + | |
- | (1/6): extras/ | + | |
- | (2/6): base/ | + | |
- | (3/6): base/ | + | |
- | (4/6): extras/ | + | |
- | (5/6): updates/ | + | |
- | (6/6): updates/ | + | |
- | Metadata Cache Created | + | |
- | + | ||
- | [trainee@targetb ~]$ exit | + | |
- | logout | + | |
- | Connection to targetb closed. | + | |
- | [trainee@centos8 roles]$ | + | |
</ | </ | ||
- | Exécutez **ansible-playbook** et constatez | + | Modifiez ensuite |
< | < | ||
- | [trainee@centos8 roles]$ | + | [trainee@centos8 roles]$ |
- | + | [trainee@centos8 roles]$ cat playbook.yaml | |
- | PLAY [all] ******************************************************************************************************************************************************************************************************* | + | --- |
- | + | - hosts: all | |
- | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | + | tasks: |
- | ok: [targeta] | + | - name: message |
- | ok: [targetb] | + | debug: msg=" |
- | + | ||
- | TASK [exemple01.java : install jre (Debian)] ********************************************************************************************************************************************************************* | + | |
- | skipping: [targetb] | + | |
- | changed: [targeta] | + | |
- | + | ||
- | TASK [exemple01.java | + | |
- | skipping: [targeta] | + | |
- | changed: [targetb] | + | |
- | + | ||
- | PLAY RECAP ******************************************************************************************************************************************************************************************************* | + | |
- | targeta | + | |
- | targetb | + | |
</ | </ | ||
- | Les conditions peuvent être combinées grâce à **and** et **or**. En voici un exemple : | + | Modifiez |
- | + | ||
- | < | + | |
- | tasks: | + | |
- | - name: " | + | |
- | command: / | + | |
- | when: (ansible_distribution == " | + | |
- | (ansible_distribution == " | + | |
- | </ | + | |
- | + | ||
- | =====LAB #2 - La Commande ansible-vault===== | + | |
- | + | ||
- | La commande **ansible-vault** permet de créer et d' | + | |
- | + | ||
- | Pour illustrer son utilisation, | + | |
< | < | ||
- | [trainee@centos8 roles]$ | + | [trainee@centos8 roles]$ |
+ | [trainee@centos8 roles]$ vi inventory | ||
+ | [trainee@centos8 roles]$ cat inventory | ||
+ | postgresql ansible_connection=docker | ||
</ | </ | ||
- | Éditez | + | Supprimez |
< | < | ||
- | [trainee@centos8 roles]$ | + | [trainee@centos8 roles]$ |
- | [trainee@centos8 roles]$ cat / | + | |
- | --- | + | |
- | secret: gardezmoisecret | + | |
- | </ | + | |
- | + | ||
- | Modifiez le fichier **/ | + | |
- | + | ||
- | < | + | |
- | [trainee@centos8 roles]$ vi playbook.yaml | + | |
- | [trainee@centos8 roles]$ cat playbook.yaml | + | |
- | --- | + | |
- | - hosts: all | + | |
- | tasks: | + | |
- | - debug: | + | |
- | msg: "Le secret est {{ secret }}" | + | |
</ | </ | ||
Ligne 400: | Ligne 231: | ||
< | < | ||
- | [trainee@centos8 roles]$ ansible-playbook -i inventory playbook.yaml -l localhost | + | [trainee@centos8 roles]$ ansible-playbook -i inventory playbook.yaml |
+ | [DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Sep 10 2021, 09:13:53) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]. | ||
+ | This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | ||
PLAY [all] ******************************************************************************************************************************************************************************************************* | PLAY [all] ******************************************************************************************************************************************************************************************************* | ||
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | ||
- | ok: [localhost] | + | ok: [postgresql] |
- | TASK [debug] ***************************************************************************************************************************************************************************************************** | + | TASK [message] *************************************************************************************************************************************************************************************************** |
- | ok: [localhost] => { | + | ok: [postgresql] => { |
- | " | + | " |
} | } | ||
PLAY RECAP ******************************************************************************************************************************************************************************************************* | PLAY RECAP ******************************************************************************************************************************************************************************************************* | ||
- | localhost | + | postgresql |
</ | </ | ||
- | <WRAP center round important 60%> | + | =====LAB #2 - Préparer Windows 10===== |
- | **Important** : L' | + | |
- | </ | + | |
- | ====2.1 - Crypter le Fichier==== | + | Ansible est capable de travailler avec les versions de Windows(tm) suivantes : |
- | Cryptez maintenant le fichier | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | * Windows(tm) Server 2016, | ||
+ | * Windows(tm) Server 2019, | ||
+ | * Windows(tm) Server 2022. | ||
- | < | + | Ansible nécessite sur chaque hôte : |
- | [trainee@centos8 roles]$ ansible-vault encrypt group_vars/ | + | |
- | New Vault password: fenestros | + | |
- | Confirm New Vault password: fenestros | + | |
- | Encryption successful | + | |
- | [trainee@centos8 roles]$ | + | |
- | </ | + | |
- | <WRAP center round important 60%> | + | * PowerShell 3.0 ou supérieur |
- | **Important** : Notez que le mot de passe **fenestros** ne sera pas en clair. | + | * Au moins .NET 4.0. |
- | </ | + | |
- | <WRAP center round important 60%> | + | ====2.1 |
- | **Important** : Notez que le mot de passe est pour la commande **ansible-vault** | + | |
- | </ | + | |
- | Constatez maintenant le contenu du fichier | + | Afin de mettre à jour les versions de PowerShell et .NET, Ansible fournit un script appelé |
< | < | ||
- | [trainee@centos8 roles]$ cat /home/trainee/.ansible/roles/group_vars/all.yaml | + | Windows PowerShell |
- | $ANSIBLE_VAULT; | + | Copyright (C) Microsoft Corporation. Tous droits réservés. |
- | 33343664333931323331346338346439613439633633396262393733663463363438663163383761 | + | |
- | 6566653230323032396434356132653262313962633265630a366436666261363933343663623131 | + | Testez le nouveau système multiplateforme PowerShell https://aka.ms/pscore6 |
- | 63373230663530313864373236316465333464323131643933363664303332336261353732623064 | + | |
- | 3538303864633035320a376235333637656534376638613661303765373165383936653336646562 | + | PS C: |
- | 31376535333861616165346433306230366231333139323062366432333033386366 | + | PS C: |
+ | PS C: | ||
+ | PS C: | ||
+ | PS C: | ||
+ | PS C: | ||
+ | PS C: | ||
+ | COMMENTAIRES : | ||
+ | COMMENTAIRES : | ||
+ | COMMENTAIRES : | ||
</ | </ | ||
- | Exécutez | + | Au cas où, vous pouvez enlever l' |
< | < | ||
- | [trainee@centos8 roles]$ ansible-playbook | + | PS C: |
- | + | PS C: | |
- | PLAY [all] ******************************************************************************************************************************************************************************************************* | + | PS C: |
- | ERROR! Attempting to decrypt but no vault secrets found | + | PS C: |
+ | PS C: | ||
+ | PS C: | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | ====2.2 - Configurer WinRM==== |
- | **Important** : Notez l' | + | |
- | </ | + | |
- | Pour indiquer à la commande | + | Pour mettre en place un **listener** WinRM en HTTP et un **listener** WinRM en HTTPS, créer un certificat auto-signé et activer |
< | < | ||
- | [trainee@centos8 roles]$ ansible-playbook | + | PS C: |
+ | PS C: | ||
+ | PS C: | ||
+ | PS C: | ||
+ | Self-signed SSL certificate generated; thumbprint: 17502EEEAC259F4C76D0F199A4B803E94E980CAD | ||
- | PLAY [all] ******************************************************************************************************************************************************************************************************* | ||
- | ERROR! Attempting to decrypt but no vault secrets found | ||
- | [trainee@centos8 roles]$ ansible-playbook -i inventory playbook.yaml -l localhost --ask-vault-pass | ||
- | Vault password: fenestros | ||
- | PLAY [all] ******************************************************************************************************************************************************************************************************* | + | wxf : http:// |
+ | a : http:// | ||
+ | w : http:// | ||
+ | lang : fr-FR | ||
+ | Address | ||
+ | ReferenceParameters : ReferenceParameters | ||
- | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | + | Ok. |
- | ok: [localhost] | + | |
- | TASK [debug] ***************************************************************************************************************************************************************************************************** | ||
- | ok: [localhost] => { | ||
- | " | ||
- | } | ||
- | PLAY RECAP ******************************************************************************************************************************************************************************************************* | ||
- | localhost | ||
- | </ | ||
- | <WRAP center round important 60%> | + | PS C:\Windows\system32> |
- | **Important** | + | |
- | </WRAP> | + | |
- | + | ||
- | ====2.2 - Editer le Fichier==== | + | |
- | + | ||
- | Pour éditer le fichier, utilisez la sous-commande **edit** de la commande **ansible-vault** : | + | |
- | + | ||
- | < | + | |
- | [trainee@centos8 roles]$ ansible-vault edit group_vars/ | + | |
- | Vault password: fenestros | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | ====2.3 - Consulter les Informations sur WinRM==== |
- | **Important** : Notez que le mot de passe **fenestros** ne sera pas en clair. | + | |
- | </ | + | |
- | Le fichier est chargé en mémoire pour édition | + | Pour voir la liste des **listeners** ainsi créés, utilisez la commande suivante |
< | < | ||
- | --- | + | PS C:\Windows\system32> |
- | secret: gardezlesecret | + | Listener |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | Port = 5985 |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | -- INSERT -- | + | |
- | </ | + | |
- | Modifiez le secret et sauvegardez le fichier | + | Listener |
+ | Address = * | ||
+ | Transport = HTTPS | ||
+ | Port = 5986 | ||
+ | Hostname = DESKTOP-1OV5NMP | ||
+ | Enabled = true | ||
+ | URLPrefix = wsman | ||
+ | CertificateThumbprint = 17502EEEAC259F4C76D0F199A4B803E94E980CAD | ||
+ | ListeningOn = 10.0.2.58, 10.29.0.34, 127.0.0.1, | ||
- | <code> | + | PS C: |
- | --- | + | |
- | secret: gardezlesecret | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | :x | + | |
</ | </ | ||
- | Constatez que le contenu | + | Pour obtenir les informations concernant le certificat, exécutez les commandes suivantes en remplacant |
< | < | ||
- | [trainee@centos8 roles]$ cat / | + | PS C: |
- | $ANSIBLE_VAULT; | + | PS C: |
- | 36633861376466313363373336643832646663666334633931663262666361306236386232316461 | + | |
- | 3331633863386666626230663038653136653830303465660a353337316634363465663962336365 | + | |
- | 61396430313965653666333738376663336139613566636437353935653232306264336235333538 | + | |
- | 6439366539653436310a666361313237623137666634663439343132393532623962353163303364 | + | |
- | 37626635363832333934363930383265313932663230356234343235643935353535 | + | |
- | </ | + | |
- | Exécutez de nouveau la commande **ansible-playbook** avec l' | ||
- | < | + | PSPath |
- | [trainee@centos8 roles]$ ansible-playbook | + | E980CAD |
- | Vault password: fenestros | + | 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 | ||
- | PLAY [all] ******************************************************************************************************************************************************************************************************* | ||
- | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | ||
- | ok: [localhost] | ||
- | TASK [debug] ***************************************************************************************************************************************************************************************************** | + | PS C:\Windows\system32> |
- | ok: [localhost] => { | + | |
- | " | + | |
- | } | + | |
- | + | ||
- | PLAY RECAP ******************************************************************************************************************************************************************************************************* | + | |
- | localhost | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | Dernièrement pour obtenir des informations concernant |
- | **Important** : Notez que le mot de passe **fenestros** ne sera pas en clair. | + | |
- | </ | + | |
- | ====2.3 - Décrypter le Fichier==== | + | < |
+ | PS C: | ||
+ | Service | ||
+ | RootSDDL | ||
+ | MaxConcurrentOperations | ||
+ | MaxConcurrentOperationsPerUser | ||
+ | EnumerationTimeoutms | ||
+ | MaxConnections | ||
+ | MaxPacketRetrievalTimeSeconds | ||
+ | AllowUnencrypted | ||
+ | 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 | ||
- | Il est possible de décrypter le fichier en utilisant la sous-commande **decrypt** de la commande **ansible-vault** | + | PS C:\Windows\system32> |
+ | Winrs | ||
+ | AllowRemoteShellAccess = true | ||
+ | IdleTimeout = 7200000 | ||
+ | MaxConcurrentUsers = 2147483647 | ||
+ | MaxShellRunTime = 2147483647 | ||
+ | MaxProcessesPerShell = 2147483647 | ||
+ | MaxMemoryPerShellMB = 2147483647 | ||
+ | MaxShellsPerUser = 2147483647 | ||
- | < | + | PS C:\Windows\system32> |
- | [trainee@centos8 roles]$ ansible-vault decrypt group_vars/ | + | |
- | Vault password: fenestros | + | |
- | Decryption successful | + | |
</ | </ | ||
- | <WRAP center round important 60%> | + | ====2.4 - Créer un Utilisateur Local pour Ansible==== |
- | **Important** : Notez que le mot de passe **fenestros** ne sera pas en clair. | + | |
- | </ | + | |
- | Constatez que le contenu du fichier **/ | + | Exécutez ensuite la commande suivante |
< | < | ||
- | [trainee@centos8 roles]$ cat / | + | PS C: |
- | --- | + | Service |
- | secret: gardezlesecret | + | RootSDDL = O: |
+ | MaxConcurrentOperations = 4294967295 | ||
+ | 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:\Windows\system32> | ||
</ | </ | ||
- | ====2.4 - Utilisation de Mots de Passe Aléatoires==== | + | Dans la fenêtre **Autorisations pour Default**, ajoutez l' |
- | Installez le paquet **pwgen** | + | {{ :elearning: |
- | < | + | =====LAB |
- | [trainee@centos8 roles]$ su - | + | |
- | Password: fenestros | + | |
- | [root@centos8 ~]# | + | |
- | [root@centos8 ~]# dnf install https:// | + | ====3.1 - Installer pywinrm==== |
- | Last metadata expiration check: 1:30:37 ago on Wed 09 Mar 2022 10:10:01 EST. | + | |
- | epel-release-latest-8.noarch.rpm | + | |
- | Dependencies resolved. | + | |
- | ================================================================================================================================================================================================================== | + | |
- | | + | |
- | ================================================================================================================================================================================================================== | + | |
- | Installing: | + | |
- | | + | |
- | Transaction Summary | + | Dans la machine virtuelle **centos8**, |
- | ================================================================================================================================================================================================================== | + | |
- | Install | + | |
- | Total size: 22 k | + | < |
- | Installed size: 32 k | + | [trainee@centos8 ~]$ su - |
- | Is this ok [y/N]: y | + | Password: fenestros |
- | Downloading Packages: | + | |
- | Running transaction check | + | |
- | Transaction check succeeded. | + | |
- | Running transaction test | + | |
- | Transaction test succeeded. | + | |
- | Running transaction | + | |
- | Preparing | + | |
- | Installing | + | |
- | | + | |
- | Verifying | + | |
- | Installed products updated. | + | |
- | Installed: | + | [root@centos8 ~]# pip3 install " |
- | | + | Collecting pywinrm> |
+ | Downloading pywinrm-0.4.2-py2.py3-none-any.whl (44 kB) | ||
+ | | ||
+ | Collecting xmltodict | ||
+ | Downloading xmltodict-0.12.0-py2.py3-none-any.whl (9.2 kB) | ||
+ | Requirement already satisfied: requests> | ||
+ | Requirement already satisfied: six in / | ||
+ | Collecting requests-ntlm> | ||
+ | | ||
+ | Requirement already satisfied: chardet< | ||
+ | Requirement already satisfied: idna<2.8,>=2.5 in / | ||
+ | Requirement already satisfied: urllib3< | ||
+ | Collecting ntlm-auth> | ||
+ | Downloading ntlm_auth-1.5.0-py2.py3-none-any.whl (29 kB) | ||
+ | Requirement already satisfied: cryptography> | ||
+ | Requirement already satisfied: cffi> | ||
+ | Requirement already satisfied: pycparser in / | ||
+ | Installing collected packages: ntlm-auth, xmltodict, requests-ntlm, | ||
+ | Successfully installed ntlm-auth-1.5.0 pywinrm-0.4.2 requests-ntlm-1.1.0 xmltodict-0.12.0 | ||
+ | WARNING: Running pip as the ' | ||
+ | </ | ||
- | Complete! | + | Modifiez ensuite le fichier **/ |
- | [root@centos8 ~]# dnf install pwgen | + | < |
- | Extra Packages for Enterprise Linux 8 - x86_64 | + | [trainee@centos8 ~]$ su - |
- | Extra Packages for Enterprise Linux Modular 8 - x86_64 | + | Password: fenestros |
- | Last metadata expiration check: 0:00:01 ago on Wed 09 Mar 2022 11:41:14 EST. | + | [root@centos8 ~]# vi /etc/hosts |
- | Dependencies resolved. | + | [root@centos8 ~]# cat /etc/hosts |
- | ================================================================================================================================================================================================================== | + | 127.0.0.1 |
- | Package | + | ::1 |
- | ================================================================================================================================================================================================================== | + | 10.0.2.45 centos8.ittraining.loc centos8 |
- | Installing: | + | 10.0.2.54 web01.i2tch.loc web01 |
- | pwgen x86_64 | + | 10.0.2.55 web02.i2tch.loc web02 |
+ | 10.0.2.56 web03.i2tch.loc web03 | ||
+ | 10.0.2.57 web04.i2tch.loc web04 | ||
+ | 10.0.2.52 targeta.i2tch.loc targeta | ||
+ | 10.0.2.53 targetb.i2tch.loc targetb | ||
+ | 10.0.2.58 windows10 | ||
+ | </ | ||
- | Transaction Summary | + | ====3.2 - Tester la Configuration==== |
- | ================================================================================================================================================================================================================== | + | |
- | Install | + | |
- | Total download size: 31 k | + | Pour tester la configuration, |
- | Installed size: 46 k | + | |
- | Is this ok [y/N]: y | + | |
+ | < | ||
[root@centos8 ~]# exit | [root@centos8 ~]# exit | ||
logout | logout | ||
- | [trainee@centos8 | + | [trainee@centos8 |
+ | [trainee@centos8 ~]$ cat inventory | ||
+ | [windows] | ||
+ | windows10 | ||
+ | |||
+ | [windows: | ||
+ | ansible_user=trainee | ||
+ | ansible_password=a39dae707d | ||
+ | ansible_connection=winrm | ||
+ | ansible_winrm_server_cert_validation=ignore | ||
</ | </ | ||
- | Utilisez maintenant la commande **pwgen** pour générer un mot de passe aléatoire | + | Procédez au test : |
< | < | ||
- | [trainee@centos8 | + | [trainee@centos8 |
- | di3Be1AiPayeehai | + | windows10 | SUCCESS => { |
+ | " | ||
+ | " | ||
+ | } | ||
</ | </ | ||
- | Utilisez pwgen pour créer un mot de passe aléatoire contenu dans un fichier : | + | =====LAB #4 - Travailler avec Ansible et Windows===== |
- | < | + | ====4.1 - Obtenir les Informations sur Windows 10==== |
- | [trainee@centos8 roles]$ pwgen 16 1 > vault-password | + | |
- | [trainee@centos8 roles]$ ls | + | De la même façon qu' |
- | backend.j2 | + | |
- | [trainee@centos8 | + | < |
- | oo3aeph5PaiVeiBu | + | [trainee@centos8 |
+ | windows10 | SUCCESS => { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | } | ||
</ | </ | ||
- | Utilisez maintenant le mot de passe aléatoire contenu dans le fichier **vault-password** pour crypter le fichier **/ | + | ====4.2 |
- | < | + | Créez |
- | [trainee@centos8 roles]$ ansible-vault encrypt group_vars/ | + | |
- | Encryption successful | + | |
- | </ | + | |
- | + | ||
- | Constatez | + | |
< | < | ||
- | [trainee@centos8 | + | [trainee@centos8 |
- | $ANSIBLE_VAULT; | + | [trainee@centos8 ~]$ cat command.yml |
- | 61326364653334653935643735623863353362333536396638356362376631633732306332316661 | + | --- |
- | 6662333436336237346433363637393666623165643438620a343436366136386637343238303063 | + | - name: ipconfig |
- | 38383866386631363834623461323334313030623136333334646335626165363263373966373663 | + | hosts: windows |
- | 3137333330653635620a396133346264656335633530353966383930613731626639393631623066 | + | |
- | 31323331383563373830306331653166326563333135326631363461313666313864 | + | - name: run ipconfig |
+ | | ||
+ | | ||
+ | - debug: var=ipconfig | ||
</ | </ | ||
- | Exécutez | + | Exécutez |
< | < | ||
- | [trainee@centos8 | + | [trainee@centos8 |
- | PLAY [all] ******************************************************************************************************************************************************************************************************* | + | PLAY [ipconfig] ************************************************************************************************************************************************************************************************** |
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | ||
- | ok: [localhost] | + | ok: [windows10] |
+ | |||
+ | TASK [run ipconfig] ********************************************************************************************************************************************************************************************** | ||
+ | changed: [windows10] | ||
TASK [debug] ***************************************************************************************************************************************************************************************************** | TASK [debug] ***************************************************************************************************************************************************************************************************** | ||
- | ok: [localhost] => { | + | ok: [windows10] => { |
- | "msg": "Le secret est gardezlesecret" | + | "ipconfig": |
+ | | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | "", | ||
+ | " | ||
+ | "", | ||
+ | "", | ||
+ | "Carte Ethernet Ethernet 2 :", | ||
+ | "", | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ] | ||
+ | } | ||
} | } | ||
PLAY RECAP ******************************************************************************************************************************************************************************************************* | PLAY RECAP ******************************************************************************************************************************************************************************************************* | ||
- | localhost | + | windows10 |
</ | </ | ||
- | =====LAB #3 - Ansible et Docker===== | + | ====4.3 - Exécuter un script PowerShell==== |
- | ====3.1 - Présentation de Docker==== | + | Créez |
- | + | ||
- | Docker est une application de virtualisation légère qui utilise des **images** et des **conteneurs**. | + | |
- | + | ||
- | Une **image** est un paquet exécutable contenant tout ce qu'il est nécessaire afin d' | + | |
- | + | ||
- | * le code | + | |
- | * un runtime | + | |
- | * des bibliothèques, | + | |
- | * des variables d' | + | |
- | * des fichiers de configuration | + | |
- | + | ||
- | Un **conteneur** est une instance de l' | + | |
- | + | ||
- | Les conteneurs exécutent des applications nativement en utilisant le noyau de la machine hôte. De ce fait les performances d'un conteneur sont supérieures à celles d'une machine virtuelle qui doit passer par un hyperviseur | + | |
- | + | ||
- | Docker existe en deux versions **Docker-CE** (Docker Community Edition) et **Docker-EE** (Docker Enterprise Edition). Pour consulter les différences entre les deux versions, consultez le lien **[[https:// | + | |
- | + | ||
- | ====3.2 - Installer docker==== | + | |
- | + | ||
- | Docker n'est pas dans le dépôts de CentOS. Afin de l' | + | |
< | < | ||
- | [trainee@centos8 | + | [trainee@centos8 |
- | Password: fenestros | + | [trainee@centos8 ~]$ cat script1.ps1 |
- | [root@centos8 ~]# dnf config-manager --add-repo=https:// | + | Start-Service |
- | Adding repo from: https:// | + | |
- | + | ||
- | [root@centos8 ~]# dnf list docker-ce | + | |
- | Docker CE Stable - x86_64 | + | |
- | Last metadata expiration check: 0:00:01 ago on Wed 09 Mar 2022 12:38:58 EST. | + | |
- | Available Packages | + | |
- | docker-ce.x86_64 | + | |
</ | </ | ||
- | Installez | + | Créez |
< | < | ||
- | [root@centos8 ~]# dnf install https:// | + | [trainee@centos8 ~]$ vi winupdate.yml |
- | Last metadata expiration check: 0:06:03 ago on Wed 09 Mar 2022 12:38:58 EST. | + | [trainee@centos8 ~]$ cat winupdate.yml |
- | containerd.io-1.2.10-3.2.el7.x86_64.rpm | + | - name: " |
- | Dependencies resolved. | + | hosts: " |
- | ================================================================================================================================================================================================================== | + | |
- | | + | |
- | ================================================================================================================================================================================================================== | + | - name: " |
- | Installing: | + | |
- | containerd.io | + | |
- | | + | |
- | + | ||
- | Transaction Summary | + | |
- | ================================================================================================================================================================================================================== | + | |
- | Install | + | |
- | + | ||
- | Total size: 23 M | + | |
- | Is this ok [y/N]: y | + | |
</ | </ | ||
- | Installez maintenant | + | Exécutez |
< | < | ||
- | [root@centos8 ~]# dnf install docker-ce --nobest -y | + | [trainee@centos8 ~]$ ansible-playbook winupdate.yml |
- | </ | + | |
- | Dernièrement, | + | PLAY [PowerShell script] ***************************************************************************************************************************************************************************************** |
- | < | + | TASK [Windows Update] ******************************************************************************************************************************************************************************************** |
- | [root@centos8 ~]# systemctl status docker | + | changed: [windows10] |
- | ● docker.service - Docker Application Container Engine | + | |
- | | + | |
- | | + | |
- | Docs: https:// | + | |
- | Main PID: 59410 (dockerd) | + | |
- | Tasks: 16 | + | |
- | | + | |
- | | + | |
- | | + | |
- | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: | + | PLAY RECAP ******************************************************************************************************************************************************************************************************* |
- | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: | + | windows10 |
- | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: | + | |
- | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: | + | |
- | Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: | + | |
- | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | + | |
- | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | + | |
- | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | + | |
- | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | + | |
- | Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: | + | |
- | [root@centos8 ~]# docker --version | + | |
- | Docker version 20.10.12, build e91ed57 | + | |
- | [root@centos8 ~]# docker version | + | |
- | Client: Docker Engine - Community | + | |
- | | + | |
- | API version: | + | |
- | Go version: | + | |
- | Git commit: | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | Server: Docker Engine - Community | + | |
- | | + | |
- | Version: | + | |
- | API version: | + | |
- | Go version: | + | |
- | Git commit: | + | |
- | Built: | + | |
- | OS/ | + | |
- | Experimental: | + | |
- | | + | |
- | Version: | + | |
- | GitCommit: | + | |
- | | + | |
- | Version: | + | |
- | GitCommit: | + | |
- | | + | |
- | Version: | + | |
- | GitCommit: | + | |
</ | </ | ||
- | <WRAP center round important> | + | ====4.4 |
- | **Important** | + | |
- | </ | + | |
- | Démarrez un conteneur dénommé | + | **[[https:// |
+ | |||
+ | Créez le PlayBook | ||
< | < | ||
- | [root@centos8 ~]# docker run -d --name | + | [trainee@centos8 ~]$ vi firefox.yml |
- | Unable to find image ' | + | [trainee@centos8 ~]$ cat firefox.yml |
- | latest: Pulling from library/ | + | --- |
- | a1d0c7532777: Pull complete | + | - name: Install Firefox using Chocolatey |
- | Digest: sha256: | + | hosts: all |
- | Status: Downloaded newer image for centos: | + | tasks: |
- | 1028e25f81d14d685678794902cd599aa618eb283d80e274526d71ec9708e69d | + | - name: Install Firefox |
+ | | ||
+ | name: firefox | ||
+ | | ||
</ | </ | ||
- | Vérifiez que le conteneur fonctionne | + | Exécutez |
< | < | ||
- | [root@centos8 ~]# docker ps -a | + | [trainee@centos8 ~]$ ansible-playbook firefox.yml -i inventory |
- | CONTAINER ID | + | |
- | 1028e25f81d1 | + | |
- | [root@centos8 ~]# exit | + | |
- | logout | + | |
- | [trainee@centos8 roles]$ | + | |
- | </ | + | |
- | ====3.3 - La Connexion à Docker==== | + | PLAY [Install Firefox using Chocolatey] ************************************************************************************************************************************************************************** |
- | Créez maintenant le Rôle **docker** : | + | TASK [Gathering Facts] |
+ | ok: [windows10] | ||
- | < | + | TASK [Install Firefox] ******************************************************************************************************************************************************************************************* |
- | trainee@ansible:~/.ansible/ | + | [WARNING]: Chocolatey was missing from this system, so it was installed during this task run. |
+ | changed: [windows10] | ||
+ | |||
+ | PLAY RECAP ******************************************************************************************************************************************************************************************************* | ||
+ | windows10 | ||
</ | </ | ||
- | Modifiez ensuite | + | ====4.5 - Créer un Utilisateur Local==== |
+ | |||
+ | Créez | ||
< | < | ||
- | [trainee@centos8 | + | [trainee@centos8 |
- | [trainee@centos8 | + | [trainee@centos8 |
--- | --- | ||
- | - hosts: | + | - name: Create a user |
+ | | ||
tasks: | tasks: | ||
- | - name: message | + | - name: Create Jean |
- | | + | |
+ | name: jean | ||
+ | password: P@$$w0rd | ||
+ | state: present | ||
+ | groups: | ||
+ | | ||
</ | </ | ||
- | Modifiez | + | Exécutez |
< | < | ||
- | [trainee@centos8 | + | [trainee@centos8 |
- | [trainee@centos8 roles]$ vi inventory | + | |
- | [trainee@centos8 roles]$ cat inventory | + | |
- | postgresql ansible_connection=docker | + | |
- | </ | + | |
- | Supprimez le fichier **/ | + | PLAY [Create a user] ********************************************************************************************************************************************************************************************* |
- | + | ||
- | < | + | |
- | [trainee@centos8 roles]$ rm -rf / | + | |
- | </ | + | |
- | + | ||
- | Exécutez la commande **ansible-playbook** en tant que **root** : | + | |
- | + | ||
- | < | + | |
- | [root@centos8 roles]# ansible-playbook -i inventory playbook.yaml | + | |
- | [DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Sep 10 2021, 09:13:53) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]. | + | |
- | This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. | + | |
- | + | ||
- | PLAY [all] ******************************************************************************************************************************************************************************************************* | + | |
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | ||
- | ok: [postgresql] | + | ok: [windows10] |
- | TASK [message] *************************************************************************************************************************************************************************************************** | + | TASK [Create Jean] *********************************************************************************************************************************************************************************************** |
- | ok: [postgresql] => { | + | changed: [windows10] |
- | " | + | |
- | } | + | |
PLAY RECAP ******************************************************************************************************************************************************************************************************* | PLAY RECAP ******************************************************************************************************************************************************************************************************* | ||
- | postgresql | + | windows10 |
</ | </ | ||
+ | |||
+ | Vérifiez que le compte a été créé : | ||
+ | |||
+ | {{ : | ||
----- | ----- | ||
- | Copyright © 2022 Hugh Norris. | + | Copyright © 2023 Hugh Norris. |