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:centos:8:lcf900:l704 [2022/05/17 08:05] – admin | elearning:workbooks:centos:8:lcf900:l704 [2024/12/03 14:37] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version | + | Version |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ====== | + | ======LDF904 |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **LCF704 | + | * **LDF904 |
* 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 Debian. Afin de l' |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | </ | + | |
- | + | ||
- | Modifiez le fichier **inventory** | + | |
< | < | ||
- | [trainee@centos8 roles]$ vi inventory | + | root@debian11:~# apt-get update |
- | [trainee@centos8 roles]$ cat inventory | + | ... |
- | [linux] | + | root@debian11:~# apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common |
- | targeta | + | Reading package lists... Done |
- | targetb | + | Building dependency tree... Done |
- | + | Reading state information... Done | |
- | [group1] | + | ca-certificates is already the newest version (20210119). |
- | localhost ansible_connection=local | + | gnupg2 is already the newest version (2.2.27-2+deb11u2). |
- | + | The following packages were automatically installed and are no longer required: | |
- | [basededonnees] | + | |
- | web01 | + | Use 'apt autoremove' |
- | + | The following additional packages will be installed: | |
- | [dotcms] | + | |
- | web02 | + | Suggested packages: |
- | web03 | + | |
- | + | The following NEW packages will be installed: | |
- | [equilibrage] | + | |
- | web04 | + | |
- | + | 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded. | |
- | [debian: | + | Need to get 661 kB of archives. |
- | basededonnees | + | After this operation, 1,567 kB of additional disk space will be used. |
- | dotcms | + | Do you want to continue? |
- | equilibrage | + | |
- | + | ||
- | [debian:vars] | + | |
- | ansible_user=trainee | + | |
</ | </ | ||
- | Modifiez le fichier **playbook.yaml** afin d' | + | Téléchargez la clef GPG officielle de docker |
< | < | ||
- | [trainee@centos8 roles]$ vi playbook.yaml | + | root@debian11:~# curl -fsSL https:// |
- | [trainee@centos8 roles]$ cat playbook.yaml | + | Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). |
- | --- | + | OK |
- | - hosts: all | + | |
- | become: true | + | |
- | roles: | + | |
- | | + | |
</ | </ | ||
- | Connectez-vous à la machine TargetA et supprimez le paquet | + | Vérifiez que l'ID de la clef est **9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88** : |
< | < | ||
- | [trainee@centos8 roles]$ ssh 10.0.2.52 | + | root@debian11:~# apt-key fingerprint 0EBFCD88 |
- | Debian GNU/Linux 9 | + | Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). |
- | Linux targeta.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 | + | pub |
- | + | 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 | |
- | The programs included with the Debian GNU/Linux system are free software; | + | uid [ unknown] Docker Release (CE deb) <docker@docker.com> |
- | the exact distribution terms for each program are described in the | + | sub |
- | individual files in / | + | |
- | + | ||
- | Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent | + | |
- | permitted by applicable law. | + | |
- | Last login: Wed Mar 9 11:29:25 2022 from 10.0.2.45 | + | |
- | trainee@targeta: | + | |
- | ... | + | |
- | trainee@targeta:~$ exit | + | |
- | déconnexion | + | |
- | Connection to 10.0.2.52 closed. | + | |
- | [trainee@centos8 roles]$ | + | |
</ | </ | ||
- | Utilisez la commande scp pour copier | + | Ajoutez |
< | < | ||
- | [trainee@centos8 roles]$ cd ~ | + | root@debian11:~# add-apt-repository " |
- | [trainee@centos8 ~]$ scp .ssh/ | + | |
- | trainee@10.0.2.53' | + | |
- | authorized_keys | + | |
- | [trainee@centos8 ~]$ cd - | + | |
- | / | + | |
- | [trainee@centos8 roles]$ | + | |
</ | </ | ||
- | Connectez-vous à la machine TargetB et supprimez le paquet | + | <WRAP center round important 50%> |
+ | **Important** | ||
+ | </ | ||
+ | |||
+ | Installez maintenant le paquet **docker-ce** : | ||
< | < | ||
- | [trainee@centos8 roles]$ ssh 10.0.2.53 | + | root@debian11docker:~# apt-get update |
- | Last login: Wed Mar 9 16:51:41 2022 from 10.0.2.45 | + | |
- | [trainee@targetb | + | |
... | ... | ||
- | [trainee@targetb | + | root@debian11:~# apt-get install docker-ce |
- | logout | + | Reading package lists... Done |
- | Connection to 10.0.2.53 closed. | + | Building dependency tree... Done |
- | [trainee@centos8 roles]$ | + | Reading state information... Done |
+ | The following packages were automatically installed and are no longer required: | ||
+ | libopengl0 linux-headers-5.10.0-15-amd64 linux-headers-5.10.0-15-common | ||
+ | Use 'apt autoremove' | ||
+ | The following additional packages will be installed: | ||
+ | containerd.io docker-buildx-plugin docker-ce-cli docker-ce-rootless-extras | ||
+ | docker-compose-plugin git git-man liberror-perl libslirp0 pigz slirp4netns | ||
+ | Suggested packages: | ||
+ | aufs-tools cgroupfs-mount | cgroup-lite git-daemon-run | git-daemon-sysvinit | ||
+ | git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn | ||
+ | The following NEW packages will be installed: | ||
+ | containerd.io docker-buildx-plugin docker-ce docker-ce-cli | ||
+ | docker-ce-rootless-extras docker-compose-plugin git git-man liberror-perl | ||
+ | libslirp0 pigz slirp4netns | ||
+ | 0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded. | ||
+ | Need to get 121 MB of archives. | ||
+ | After this operation, 452 MB of additional disk space will be used. | ||
+ | Do you want to continue? | ||
</ | </ | ||
- | Grâce au Fact **ansible_os_family** il est possible d' | + | Dernièrement, |
< | < | ||
- | [trainee@centos8 roles]$ vi exemple01.java/ | + | root@debian11:~# docker version |
- | [trainee@centos8 roles]$ cat exemple01.java/ | + | Client: Docker Engine - Community |
- | --- | + | |
- | - name: install jre (Debian) | + | API version: |
- | | + | Go version: |
- | when: ansible_os_family == ' | + | Git commit: |
+ | Built: Fri Jul 21 20:35:45 2023 | ||
+ | OS/Arch: linux/amd64 | ||
+ | Context: default | ||
- | - name: install jre (CentOS) | + | Server: Docker Engine |
- | | + | |
- | | + | Version: |
+ | API version: | ||
+ | | ||
+ | Git commit: | ||
+ | Built: | ||
+ | OS/ | ||
+ | Experimental: | ||
+ | | ||
+ | Version: | ||
+ | GitCommit: | ||
+ | | ||
+ | Version: | ||
+ | GitCommit: | ||
+ | | ||
+ | Version: | ||
+ | | ||
</ | </ | ||
- | Modifiez | + | <WRAP center round important 50%> |
+ | **Important** - Notez que le paquet docker-ce a besoin des paquets | ||
+ | </ | ||
+ | |||
+ | Dans le cas où vous souhaitez installer une version différente, | ||
< | < | ||
- | [trainee@centos8 roles]$ su - | + | root@debian11:~# apt-cache madison docker-ce |
- | Password: fenestros | + | docker-ce | 5:24.0.6-1~debian.11~bullseye | https:// |
- | [root@centos8 | + | docker-ce | 5:24.0.5-1~debian.11~bullseye | https://download.docker.com/ |
- | [root@centos8 | + | docker-ce | 5:24.0.4-1~debian.11~bullseye | https://download.docker.com/ |
- | 127.0.0.1 | + | docker-ce | 5:24.0.3-1~debian.11~bullseye | https:// |
- | ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 | + | |
- | 10.0.2.45 centos8.ittraining.loc centos8 | + | docker-ce | 5:24.0.1-1~debian.11~bullseye | https:// |
- | 10.0.2.54 web01.i2tch.loc web01 | + | |
- | 10.0.2.55 web02.i2tch.loc web02 | + | docker-ce | 5: |
- | 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 | + | docker-ce | 5: |
- | logout | + | |
- | [trainee@centos8 roles]$ | + | |
+ | | ||
+ | docker-ce | 5:20.10.22~3-0~debian-bullseye | https:// | ||
+ | | ||
+ | docker-ce | 5:20.10.20~3-0~debian-bullseye | https:// | ||
+ | | ||
+ | docker-ce | 5:20.10.18~3-0~debian-bullseye | https:// | ||
+ | | ||
+ | docker-ce | 5:20.10.16~3-0~debian-bullseye | https:// | ||
+ | | ||
+ | docker-ce | 5:20.10.14~3-0~debian-bullseye | https:// | ||
+ | | ||
+ | docker-ce | 5:20.10.12~3-0~debian-bullseye | https:// | ||
+ | docker-ce | 5: | ||
+ | docker-ce | 5: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
</ | </ | ||
- | Connectez-vous en ssh à targeta et testez | + | Dans le cas où vous souhaiteriez installer |
< | < | ||
- | [trainee@centos8 roles]$ ssh targeta | + | # apt-get install docker-ce=5: |
- | The authenticity of host ' | + | </ |
- | ECDSA key fingerprint is SHA256:sEfHBv9azmK60cjqF/ | + | |
- | 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; | + | Si vous préférez utiliser le script d' |
- | 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 | + | <WRAP center round important 50%> |
- | permitted by applicable law. | + | **Important** - Notez que ces scripts ne doivent pas être utilisés dans un environnement de production. |
- | Last login: Wed Mar 9 16:52:16 2022 from 10.0.2.45 | + | </ |
- | trainee@targeta:~$ sudo apt update | + | < |
- | Réception de:1 http:// | + | root@debian11:~# curl -fsSL https://get.docker.com -o get-docker.sh |
- | Ign:2 http://ftp.fr.debian.org/ | + | |
- | 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:~$ exit | + | root@debian11:~# ls |
- | déconnexion | + | get-docker.sh |
- | Connection to targeta closed. | + | |
</ | </ | ||
- | Connectez-vous en ssh à targetb et testez la configuration de sudo : | + | Ensuite, il convient d' |
< | < | ||
- | [trainee@centos8 roles]$ ssh targetb | + | root@debian11:~# chmod +x get-docker.sh |
- | The authenticity of host ' | + | |
- | ECDSA key fingerprint is SHA256:RgOsp/ | + | |
- | 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 | + | root@debian11:~# ./ |
- | Loaded plugins: fastestmirror, | + | # Executing docker install script, commit: c2de0811708b6d9015ed1a2c80f02c9b70c8ce7b |
- | Cleaning repos: base extras updates | + | Warning: the " |
- | Other repos take up 190 M of disk space (use --verbose for details) | + | |
- | [trainee@targetb ~]$ sudo yum -y makecache | + | If you already have Docker installed, this script can cause trouble, which is |
- | Loaded plugins: fastestmirror, langpacks | + | why we're displaying this warning and provide the opportunity to cancel the |
- | Loading mirror speeds from cached hostfile | + | installation. |
- | * 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 | + | If you installed the current Docker package using this script and are using it |
- | logout | + | again to update Docker, you can safely ignore this message. |
- | Connection | + | |
- | [trainee@centos8 roles]$ | + | You may press Ctrl+C now to abort this script. |
+ | + sleep 20 | ||
+ | ^C | ||
</ | </ | ||
- | Exécutez | + | <WRAP center round important 50%> |
+ | **Important** - Notez l' | ||
+ | </ | ||
+ | |||
+ | Démarrez un conteneur de l' | ||
< | < | ||
- | [trainee@centos8 roles]$ ansible-playbook | + | root@debian11:~# docker run hello-world |
+ | Unable to find image 'hello-world: | ||
+ | latest: Pulling from library/ | ||
+ | 719385e32844: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for hello-world: | ||
- | PLAY [all] ******************************************************************************************************************************************************************************************************* | + | Hello from Docker! |
+ | This message shows that your installation appears to be working correctly. | ||
- | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | + | To generate this message, Docker took the following steps: |
- | ok: [targeta] | + | 1. The Docker client contacted the Docker daemon. |
- | ok: [targetb] | + | 2. The Docker daemon pulled the " |
+ | (amd64) | ||
+ | 3. The Docker daemon created a new container from that image which runs the | ||
+ | executable that produces the output you are currently reading. | ||
+ | 4. The Docker daemon streamed that output to the Docker client, which sent it | ||
+ | to your terminal. | ||
- | TASK [exemple01.java | + | To try something more ambitious, you can run an Ubuntu container with: |
- | skipping: [targetb] | + | $ docker run -it ubuntu bash |
- | changed: [targeta] | + | |
- | TASK [exemple01.java | + | Share images, automate workflows, and more with a free Docker ID: |
- | skipping: [targeta] | + | https:// |
- | changed: [targetb] | + | |
- | PLAY RECAP ******************************************************************************************************************************************************************************************************* | + | For more examples and ideas, visit: |
- | targeta | + | https:// |
- | targetb | + | |
</ | </ | ||
- | Les conditions peuvent être combinées grâce | + | <WRAP center round important 50%> |
+ | **Important** - Notez que si l' | ||
+ | </ | ||
- | < | + | Lancez maintenant un conteneur postgresql |
- | tasks: | + | |
- | - name: " | + | |
- | command: / | + | |
- | when: (ansible_distribution == " | + | |
- | (ansible_distribution == " | + | |
- | </ | + | |
- | =====LAB | + | < |
+ | root@debian11: | ||
+ | 7d948c33b2f42e1823ae22353815ea674695fa1dc9e6bd70acc49a80651845c5 | ||
+ | </ | ||
- | La commande **ansible-vault** permet de créer et d'utiliser des fichiers cryptés, par exemple, ceux qui contiennent des mots de passe. | + | Vérifiez l'état du conteneur : |
- | Pour illustrer son utilisation, | + | < |
+ | root@debian11: | ||
+ | CONTAINER ID | ||
+ | 7d948c33b2f4 | ||
+ | </ | ||
+ | |||
+ | Ajoutez | ||
< | < | ||
- | [trainee@centos8 | + | root@debian11:/ |
+ | root@debian11:/ | ||
+ | trainee : trainee cdrom floppy audio dip video plugdev netdev lpadmin scanner vboxusers docker | ||
</ | </ | ||
- | Éditez le fichier | + | Redevenez l' |
< | < | ||
- | [trainee@centos8 roles]$ vi / | + | root@debian11:/ |
- | [trainee@centos8 roles]$ cat /home/ | + | logout |
- | --- | + | trainee@debian11:~/.ansible/roles$ groups |
- | secret: gardezmoisecret | + | trainee |
+ | trainee@debian11: | ||
+ | trainee@debian11: | ||
+ | docker cdrom floppy audio dip video plugdev netdev lpadmin scanner vboxusers trainee | ||
+ | trainee@debian11:~/ | ||
</ | </ | ||
- | Modifiez | + | ====1.3 - La Connexion à Docker==== |
+ | |||
+ | Créez maintenant | ||
< | < | ||
- | [trainee@centos8 | + | trainee@debian11: |
- | [trainee@centos8 | + | </ |
+ | |||
+ | Modifiez ensuite le fichier playbook.yaml : | ||
+ | |||
+ | < | ||
+ | trainee@debian11: | ||
+ | trainee@debian11: | ||
--- | --- | ||
- hosts: all | - hosts: all | ||
tasks: | tasks: | ||
- | | + | |
- | | + | |
+ | </ | ||
+ | |||
+ | Modifiez le fichier **inventory** : | ||
+ | |||
+ | < | ||
+ | trainee@debian11: | ||
+ | trainee@debian11: | ||
+ | trainee@debian11: | ||
+ | postgresql ansible_connection=docker | ||
+ | </ | ||
+ | |||
+ | Supprimez le fichier **/ | ||
+ | |||
+ | < | ||
+ | trainee@debian11: | ||
</ | </ | ||
Ligne 400: | Ligne 366: | ||
< | < | ||
- | [trainee@centos8 | + | trainee@debian11: |
- | 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 | + | PS C:\Windows\system32> |
</ | </ | ||
- | <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. | + | |
- | </ | + | |
- | ====2.2 - Editer le Fichier==== | + | Pour voir la liste des **listeners** ainsi créés, utilisez |
- | + | ||
- | Pour éditer le fichier, utilisez | + | |
< | < | ||
- | [trainee@centos8 roles]$ ansible-vault edit group_vars/all.yaml | + | PS C: |
- | Vault password: fenestros | + | Listener |
- | </ | + | |
+ | Transport = HTTP | ||
+ | Port = 5985 | ||
+ | Hostname | ||
+ | Enabled = true | ||
+ | URLPrefix = wsman | ||
+ | CertificateThumbprint | ||
+ | ListeningOn = 10.0.2.58, 10.29.0.34, 127.0.0.1, ::1 | ||
- | <WRAP center round important 60%> | + | Listener |
- | **Important** : Notez que le mot de passe **fenestros** ne sera pas en clair. | + | |
- | </ | + | |
+ | Port = 5986 | ||
+ | Hostname = DESKTOP-1OV5NMP | ||
+ | Enabled = true | ||
+ | URLPrefix = wsman | ||
+ | CertificateThumbprint = 17502EEEAC259F4C76D0F199A4B803E94E980CAD | ||
+ | ListeningOn = 10.0.2.58, 10.29.0.34, 127.0.0.1, ::1 | ||
- | Le fichier est chargé en mémoire pour édition | + | PS C:\Windows\system32> |
- | + | ||
- | <code> | + | |
- | --- | + | |
- | secret: gardezlesecret | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | |
- | -- INSERT -- | + | |
</ | </ | ||
- | Modifiez | + | Pour obtenir les informations concernant |
< | < | ||
- | --- | + | PS C: |
- | secret: gardezlesecret | + | PS C: |
- | ~ | + | |
- | ~ | + | |
- | ~ | + | PSPath |
- | ~ | + | E980CAD |
- | ~ | + | PSParentPath |
- | ~ | + | PSChildName |
- | ~ | + | PSDrive |
- | ~ | + | PSProvider |
- | :x | + | PSIsContainer |
- | </code> | + | 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 | ||
- | Constatez que le contenu du fichier **/ | ||
- | <code> | + | PS C: |
- | [trainee@centos8 roles]$ cat / | + | |
- | $ANSIBLE_VAULT; | + | |
- | 36633861376466313363373336643832646663666334633931663262666361306236386232316461 | + | |
- | 3331633863386666626230663038653136653830303465660a353337316634363465663962336365 | + | |
- | 61396430313965653666333738376663336139613566636437353935653232306264336235333538 | + | |
- | 6439366539653436310a666361313237623137666634663439343132393532623962353163303364 | + | |
- | 37626635363832333934363930383265313932663230356234343235643935353535 | + | |
</ | </ | ||
- | Exécutez de nouveau la commande **ansible-playbook** avec l' | + | Dernièrement pour obtenir des informations concernant le service, exécutez les deux commandes suivantes |
< | < | ||
- | [trainee@centos8 roles]$ ansible-playbook -i inventory playbook.yaml -l localhost --ask-vault-pass | + | PS C: |
- | Vault password: fenestros | + | Service |
+ | RootSDDL = O:NSG: | ||
+ | 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 | ||
- | PLAY [all] ******************************************************************************************************************************************************************************************************* | + | PS C: |
+ | Winrs | ||
+ | AllowRemoteShellAccess = true | ||
+ | IdleTimeout = 7200000 | ||
+ | MaxConcurrentUsers = 2147483647 | ||
+ | MaxShellRunTime = 2147483647 | ||
+ | MaxProcessesPerShell = 2147483647 | ||
+ | MaxMemoryPerShellMB = 2147483647 | ||
+ | MaxShellsPerUser = 2147483647 | ||
- | TASK [Gathering Facts] ******************************************************************************************************************************************************************************************* | + | PS C:\Windows\system32> |
- | ok: [localhost] | + | |
- | + | ||
- | TASK [debug] ***************************************************************************************************************************************************************************************************** | + | |
- | ok: [localhost] => { | + | |
- | " | + | |
- | } | + | |
- | + | ||
- | PLAY RECAP ******************************************************************************************************************************************************************************************************* | + | |
- | localhost | + | |
</ | </ | ||
- | <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. | + | |
- | </ | + | |
- | ====2.3 - Décrypter le Fichier==== | + | Retournez à l' |
- | Il est possible de décrypter le fichier | + | Lancez PowerShell |
< | < | ||
- | [trainee@centos8 roles]$ ansible-vault decrypt group_vars/ | + | PS C: |
- | Vault password: fenestros | + | Service |
- | Decryption successful | + | RootSDDL = O:NSG: |
+ | | ||
+ | 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: | ||
</ | </ | ||
- | <WRAP center round important 60%> | + | Dans la fenêtre |
- | **Important** : Notez que le mot de passe **fenestros** ne sera pas en clair. | + | |
- | </ | + | |
- | Constatez que le contenu du fichier **/ | + | {{ :elearning: |
- | < | + | =====LAB #3 - Préparer le Contrôleur Ansible===== |
- | [trainee@centos8 roles]$ cat / | + | |
- | --- | + | |
- | secret: gardezlesecret | + | |
- | </ | + | |
- | ====2.4 - Utilisation de Mots de Passe Aléatoires==== | + | ====3.1 - Installer pywinrm==== |
- | Installez | + | Sous Debian 11, le paquet **python3-winrm** est déjà installé. |
+ | |||
+ | Modifiez le fichier **/ | ||
< | < | ||
- | [trainee@centos8 | + | trainee@debian11: |
Password: fenestros | Password: fenestros | ||
- | [root@centos8 ~]# | ||
- | [root@centos8 | + | root@debian11:~# vi /etc/hosts |
- | 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 | + | root@debian11: |
- | ================================================================================================================================================================================================================== | + | 127.0.0.1 localhost |
- | Install | + | 10.0.2.46 |
+ | 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 | ||
+ | 10.0.2.58 windows10 | ||
- | Total size: 22 k | + | # The following lines are desirable for IPv6 capable hosts |
- | Installed size: 32 k | + | ::1 |
- | Is this ok [y/N]: y | + | ff02::1 ip6-allnodes |
- | Downloading Packages: | + | ff02::2 ip6-allrouters |
- | Running transaction check | + | </code> |
- | Transaction check succeeded. | + | |
- | Running transaction test | + | |
- | Transaction test succeeded. | + | |
- | Running transaction | + | |
- | Preparing | + | |
- | Installing | + | |
- | | + | |
- | | + | |
- | Installed products updated. | + | |
- | Installed: | + | ====3.2 |
- | epel-release-8-14.el8.noarch | + | |
- | Complete! | + | Pour tester la configuration, |
- | [root@centos8 | + | < |
- | Extra Packages for Enterprise Linux 8 - x86_64 | + | root@debian11:~# exit |
- | Extra Packages for Enterprise Linux Modular 8 - x86_64 | + | logout |
- | Last metadata expiration check: 0:00:01 ago on Wed 09 Mar 2022 11:41:14 EST. | + | |
- | Dependencies resolved. | + | |
- | ================================================================================================================================================================================================================== | + | |
- | | + | |
- | ================================================================================================================================================================================================================== | + | |
- | Installing: | + | |
- | pwgen x86_64 | + | |
- | Transaction Summary | + | trainee@debian11: |
- | ================================================================================================================================================================================================================== | + | |
- | Install | + | |
- | Total download size: 31 k | + | trainee@debian11:~$ cat inventory |
- | Installed size: 46 k | + | [windows] |
- | Is this ok [y/N]: y | + | windows10 |
- | [root@centos8 ~]# exit | + | [windows: |
- | logout | + | ansible_user=trainee |
- | [trainee@centos8 roles]$ | + | 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 roles]$ pwgen 16 1 | + | trainee@debian11:~$ ansible windows -i inventory -m win_ping |
- | 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 roles]$ cat vault-password | + | < |
- | oo3aeph5PaiVeiBu | + | trainee@debian11:~$ ansible windows |
+ | 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 roles]$ cat group_vars/ | + | trainee@debian11:~$ vi command.yml |
- | $ANSIBLE_VAULT; | + | trainee@debian11: |
- | 61326364653334653935643735623863353362333536396638356362376631633732306332316661 | + | --- |
- | 6662333436336237346433363637393666623165643438620a343436366136386637343238303063 | + | - name: ipconfig |
- | 38383866386631363834623461323334313030623136333334646335626165363263373966373663 | + | hosts: windows |
- | 3137333330653635620a396133346264656335633530353966383930613731626639393631623066 | + | |
- | 31323331383563373830306331653166326563333135326631363461313666313864 | + | - name: run ipconfig |
+ | | ||
+ | | ||
+ | - debug: var=ipconfig | ||
</ | </ | ||
- | Exécutez | + | Exécutez |
< | < | ||
- | [trainee@centos8 roles]$ ansible-playbook -i inventory | + | trainee@debian11:~$ ansible-playbook |
- | 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 roles]$ su - | + | trainee@debian11:~$ vi script1.ps1 |
- | Password: fenestros | + | trainee@debian11:~$ cat script1.ps1 |
- | [root@centos8 | + | Start-Service |
- | Adding repo from: https:// | + | |
- | + | ||
- | [root@centos8 | + | |
- | 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 | + | trainee@debian11:~$ vi winupdate.yml |
- | Last metadata expiration check: 0:06:03 ago on Wed 09 Mar 2022 12:38:58 EST. | + | trainee@debian11:~$ 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 | + | trainee@debian11:~$ 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 | + | trainee@debian11:~$ vi firefox.yml |
- | Unable to find image ' | + | trainee@debian11: |
- | 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 | + | trainee@debian11:~$ 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 roles]$ vi playbook.yaml | + | trainee@debian11:~$ vi users.yml |
- | [trainee@centos8 roles]$ cat playbook.yaml | + | trainee@debian11:~$ cat users.yml |
--- | --- | ||
- | - 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 roles]$ cp inventory inventory.old | + | trainee@debian11:~$ ansible-playbook users.yml -i inventory |
- | [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 © 2024 Hugh Norris. |