Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
elearning:workbooks:centos:8:lcf900:l704 [2022/05/20 16:22] adminelearning:workbooks:centos:8:lcf900:l704 [2024/12/03 14:37] (Version actuelle) admin
Ligne 1: Ligne 1:
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
  
-Version : **2022.02**+Version : **2024.01**
  
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
  
-======LCF804 - Utilisation d'Ansible avec Docker et Windows======+======LDF904 - Utilisation d'Ansible avec Docker et Windows======
  
 =====Contenu du Module===== =====Contenu du Module=====
  
-  * **LCF804 - Utilisation d'Ansible avec Docker et Windows**+  * **LDF904 - Utilisation d'Ansible avec Docker et Windows**
     * Contenu du Module     * Contenu du Module
     * LAB #1 - Ansible et Docker     * LAB #1 - Ansible et Docker
Ligne 52: Ligne 52:
 ====1.2 - Installer docker==== ====1.2 - Installer docker====
  
-Docker n'est pas dans le dépôts de CentOS. Afin de l'installer il convient d'ajouter le dépôt de docker :+Docker n'est pas dans le dépôts de Debian. Afin de l'installer il convient d'ajouter le dépôt de docker. Premièrement, il est nécessaire d'installer les paquets permettant à Debian d'utiliser un dépôt en https :
  
 <code> <code>
-[trainee@centos8 roles]$ su +root@debian11:~# apt-get update 
-Password: fenestros +... 
-[root@centos8 ~]dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo +root@debian11:~# apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common 
-Adding repo fromhttps://download.docker.com/linux/centos/docker-ce.repo+Reading package lists... Done 
 +Building dependency tree... Done 
 +Reading state information... Done 
 +ca-certificates is already the newest version (20210119). 
 +gnupg2 is already the newest version (2.2.27-2+deb11u2). 
 +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' to remove them. 
 +The following additional packages will be installed: 
 +  python3-distro-info python3-software-properties unattended-upgrades 
 +Suggested packages: 
 +  bsd-mailx default-mta | mail-transport-agent needrestart powermgmt-base 
 +The following NEW packages will be installed: 
 +  apt-transport-https curl python3-distro-info python3-software-properties 
 +  software-properties-common unattended-upgrades 
 +0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded. 
 +Need to get 661 kB of archives. 
 +After this operation, 1,567 kB of additional disk space will be used. 
 +Do you want to continue? [Y/n] y 
 +</code>
  
-[root@centos8 ~]dnf list docker-ce +Téléchargez la clef GPG officielle de docker : 
-Docker CE Stable x86_64                                                                                                                                                          83 kB/ 20 kB     00:00     + 
-Last metadata expiration check0:00:01 ago on Wed 09 Mar 2022 12:38:58 EST. +<code> 
-Available Packages +root@debian11:~# curl -fsSL https://download.docker.com/linux/debian/gpg apt-key add - 
-docker-ce.x86_64                                                                                 3:20.10.12-3.el8                                                                                 docker-ce-stable+Warningapt-key is deprecatedManage keyring files in trusted.gpg.d instead (see apt-key(8)). 
 +OK
 </code> </code>
  
-Installez ensuite la dépendance **containerd** de docker-ce :+Vérifiez que l'ID de la clef est **9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88** :
  
 <code> <code>
-[root@centos8 ~]dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.10-3.2.el7.x86_64.rpm +root@debian11:~# apt-key fingerprint 0EBFCD88 
-Last metadata expiration check: 0:06:03 ago on Wed 09 Mar 2022 12:38:58 EST. +Warningapt-key is deprecatedManage keyring files in trusted.gpg.d instead (see apt-key(8))
-containerd.io-1.2.10-3.2.el7.x86_64.rpm                                                                                                                                            13 MB/s |  23 MB     00:01     +pub   rsa4096 2017-02-22 [SCEA] 
-Dependencies resolved+      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88 
-================================================================================================================================================================================================================== +uid           [ unknown] Docker Release (CE deb) <docker@docker.com> 
- Package                                             Architecture                                 Version                                                Repository                                          Size +sub   rsa4096 2017-02-22 [S] 
-================================================================================================================================================================================================================== +</code>
-Installing: +
- containerd.io                                       x86_64                                       1.2.10-3.2.el7                                         @commandline                                        23 M +
-     replacing  runc.x86_64 1.0.2-1.module_el8.5.0+911+f19012f9+
  
-Transaction Summary +Ajoutez le dépôt **stable** de docker :
-================================================================================================================================================================================================================== +
-Install  1 Package+
  
-Total size: 23 M +<code> 
-Is this ok [y/N]: y+root@debian11:~# add-apt-repository "deb [arch=amd64https://download.docker.com/linux/debian $(lsb_release -cs) stable"
 </code> </code>
 +
 +<WRAP center round important 50%>
 +**Important** - Notez que la commande **lsb_release -cs** retourne le nom de la distribution Debian, à savoir dans ce cas **stretch**.
 +</WRAP>
  
 Installez maintenant le paquet **docker-ce** : Installez maintenant le paquet **docker-ce** :
  
 <code> <code>
-[root@centos8 ~]dnf install docker-ce --nobest -y+root@debian11docker:~# apt-get update 
 +... 
 +root@debian11:~# apt-get install docker-ce 
 +Reading package lists... Done 
 +Building dependency tree... Done 
 +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' to remove them. 
 +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? [Y/n] y
 </code> </code>
  
-Dernièrement, vérifiez le statut et la version de Docker client et serveur :+Dernièrement, vérifiez la version de Docker client et serveur :
  
 <code> <code>
-[root@centos8 ~]# systemctl status docker +root@debian11:~# docker version
-● docker.service - Docker Application Container Engine +
-   Loadedloaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) +
-   Active: activating (start) since Wed 2022-03-09 12:48:23 EST; 51s ago +
-     Docs: https://docs.docker.com +
- Main PID: 59410 (dockerd) +
-    Tasks: 16 +
-   Memory: 37.7M +
-   CGroup: /system.slice/docker.service +
-           └─59410 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock +
- +
-Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:23.125986199-05:00" level=info msg="Starting up" +
-Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:23.128455293-05:00" level=info msg="parsed scheme: \"unix\"" module=grpc +
-Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:23.128518502-05:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc +
-Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:23.128568972-05:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <> +
-Mar 09 12:48:23 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:23.128603681-05:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc +
-Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:28.105356011-05:00" level=info msg="parsed scheme: \"unix\"" module=grpc +
-Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:28.105423457-05:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc +
-Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:28.105455755-05:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <> +
-Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:28.105470536-05:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc +
-Mar 09 12:48:28 centos8.ittraining.loc dockerd[59410]: time="2022-03-09T12:48:28.106759173-05:00" level=error msg="Failed to built-in GetDriver graph btrfs /var/lib/docker" +
-[root@centos8 ~]# docker --version +
-Docker version 20.10.12, build e91ed57 +
-[root@centos8 ~]# docker version+
 Client: Docker Engine - Community Client: Docker Engine - Community
- Version:           20.10.12 + Version:           24.0.5 
- API version:       1.40 + API version:       1.43 
- Go version:        go1.16.12 + Go version:        go1.20.6 
- Git commit:        e91ed57 + Git commit:        ced0996 
- Built:             Mon Dec 13 11:45:22 2021+ Built:             Fri Jul 21 20:35:45 2023
  OS/Arch:           linux/amd64  OS/Arch:           linux/amd64
  Context:           default  Context:           default
- Experimental:      true 
  
 Server: Docker Engine - Community Server: Docker Engine - Community
  Engine:  Engine:
-  Version:          19.03.15 +  Version:          24.0.6 
-  API version:      1.40 (minimum version 1.12) +  API version:      1.43 (minimum version 1.12) 
-  Go version:       go1.13.15 +  Go version:       go1.20.7 
-  Git commit:       99e3ed8919 +  Git commit:       1a79695 
-  Built:            Sat Jan 30 03:15:19 2021+  Built:            Mon Sep  4 12:32:16 2023
   OS/Arch:          linux/amd64   OS/Arch:          linux/amd64
   Experimental:     false   Experimental:     false
  containerd:  containerd:
-  Version:          1.2.10 +  Version:          1.6.22 
-  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339+  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
  runc:  runc:
-  Version:          1.0.0-rc8+dev +  Version:          1.1.8 
-  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657+  GitCommit:        v1.1.8-0-g82f18fe
  docker-init:  docker-init:
-  Version:          0.18.0 +  Version:          0.19.0 
-  GitCommit:        fec3683+  GitCommit:        de40ad0
 </code> </code>
  
-<WRAP center round important> +<WRAP center round important 50%
-**Important** - Docker est composé de trois éléments : un serveur, un client et un ou plusieurs **Repositories** ou Dépôts en français.+**Important** - Notez que le paquet docker-ce a besoin des paquets **containerd.io** et **docker-ce-cli**. Notez aussi que la procédure ci-dessus installe la version la plus récente de Docker.
 </WRAP> </WRAP>
  
-Démarrez un conteneur dénommé **postgresql** en mode détaché à partir d'une image **CentOS** :+Dans le cas où vous souhaitez installer une version différente, il convient d'abord de constater les versions disponibles : 
 + 
 +<code> 
 +root@debian11:~# apt-cache madison docker-ce 
 + docker-ce | 5:24.0.6-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:24.0.5-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:24.0.4-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:24.0.3-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:24.0.2-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:24.0.1-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:24.0.0-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:23.0.6-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:23.0.5-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:23.0.4-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:23.0.3-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:23.0.2-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:23.0.1-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:23.0.0-1~debian.11~bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.24~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.23~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.22~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.21~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.20~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.19~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.18~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.17~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.16~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.15~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.14~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.13~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.12~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.11~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.10~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.9~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.8~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.7~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 + docker-ce | 5:20.10.6~3-0~debian-bullseye | https://download.docker.com/linux/debian bullseye/stable amd64 Packages 
 +</code> 
 + 
 +Dans le cas où vous souhaiteriez installer la version **24.0.1** de Docker, la commande d’installation deviendrait : 
 + 
 +<code> 
 +# apt-get install docker-ce=5:24.0.1-1~debian.11~bullseye docker-ce-cli=5:24.0.1-1~debian.11~bullseye containerd.io 
 +</code> 
 + 
 +Si vous préférez utiliser le script d'installation de Docker, il convient d'abord de le télécharger : 
 + 
 +<WRAP center round important 50%> 
 +**Important** - Notez que ces scripts ne doivent pas être utilisés dans un environnement de production. 
 +</WRAP> 
 + 
 +<code> 
 +root@debian11:~# curl -fsSL https://get.docker.com -o get-docker.sh 
 + 
 +root@debian11:~# ls 
 +get-docker.sh 
 +</code> 
 + 
 +Ensuite, il convient d'exécuter le script : 
 + 
 +<code> 
 +root@debian11:~# chmod +x get-docker.sh  
 + 
 +root@debian11:~# ./get-docker.sh  
 +# Executing docker install script, commit: c2de0811708b6d9015ed1a2c80f02c9b70c8ce7b 
 +Warning: the "docker" command appears to already exist on this system. 
 + 
 +If you already have Docker installed, this script can cause trouble, which is 
 +why we're displaying this warning and provide the opportunity to cancel the 
 +installation. 
 + 
 +If you installed the current Docker package using this script and are using it 
 +again to update Docker, you can safely ignore this message. 
 + 
 +You may press Ctrl+C now to abort this script. 
 ++ sleep 20 
 +^C 
 +</code> 
 + 
 +<WRAP center round important 50%> 
 +**Important** - Notez l'utilisation de **^C** pour ne PAS continuer l'exécution du script. 
 +</WRAP> 
 + 
 +Démarrez un conteneur de l'image hello-world : 
 + 
 +<code> 
 +root@debian11:~# docker run hello-world 
 +Unable to find image 'hello-world:latest' locally 
 +latest: Pulling from library/hello-world 
 +719385e32844: Pull complete  
 +Digest: sha256:dcba6daec718f547568c562956fa47e1b03673dd010fe6ee58ca806767031d1c 
 +Status: Downloaded newer image for hello-world:latest 
 + 
 +Hello from Docker! 
 +This message shows that your installation appears to be working correctly. 
 + 
 +To generate this message, Docker took the following steps: 
 + 1. The Docker client contacted the Docker daemon. 
 + 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 
 +    (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. 
 + 
 +To try something more ambitious, you can run an Ubuntu container with: 
 + $ docker run -it ubuntu bash 
 + 
 +Share images, automate workflows, and more with a free Docker ID: 
 + https://hub.docker.com/ 
 + 
 +For more examples and ideas, visit: 
 + https://docs.docker.com/get-started/ 
 +</code> 
 + 
 +<WRAP center round important 50%> 
 +**Important** - Notez que si l'image servant à générer le conteneur n'est pas présente sur le système hôte, celle-ci est téléchargée automatiquement depuis un dépôt ( par défaut le dépôt **docker.io** ) en utilisant la commande **docker pull**. 
 +</WRAP> 
 + 
 +Lancez maintenant un conteneur postgresql : 
 + 
 +<code> 
 +root@debian11:~# docker run ---name postgresql centos sleep infinity 
 +7d948c33b2f42e1823ae22353815ea674695fa1dc9e6bd70acc49a80651845c5 
 +</code> 
 + 
 +Vérifiez l'état du conteneur : 
 + 
 +<code> 
 +root@debian11:~# docker ps  
 +CONTAINER ID   IMAGE     COMMAND            CREATED         STATUS         PORTS     NAMES 
 +7d948c33b2f4   centos    "sleep infinity"   2 minutes ago   Up 2 minutes             postgresql 
 +</code> 
 + 
 +Ajoutez **trainee** au groupe **docker** afin qu'il puisse gérer les conteneurs puis redevenir l'utilisateur trainee :
  
 <code> <code>
-[root@centos8 ~]docker run -d --name postgresql centos sleep infinity +root@debian11:/home/trainee/.ansible/rolesusermod -aG docker trainee 
-Unable to find image 'centos:latest' locally +root@debian11:/home/trainee/.ansible/roles# groups trainee 
-latest: Pulling from library/centos +trainee trainee cdrom floppy audio dip video plugdev netdev lpadmin scanner vboxusers docker
-a1d0c7532777Pull complete  +
-Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177 +
-Status: Downloaded newer image for centos:latest +
-1028e25f81d14d685678794902cd599aa618eb283d80e274526d71ec9708e69d+
 </code> </code>
  
-Vérifiez que le conteneur fonctionne :+Redevenez l'utilisateur **trainee** :
  
 <code> <code>
-[root@centos8 ~]# docker ps -a +root@debian11:/home/trainee/.ansible/roles# exit
-CONTAINER ID   IMAGE     COMMAND            CREATED              STATUS          PORTS     NAMES +
-1028e25f81d1   centos    "sleep infinity"   About a minute ago   Up 30 seconds             postgresql +
-[root@centos8 ~]# exit+
 logout logout
-[trainee@centos8 roles]$+trainee@debian11:~/.ansible/roles$ groups 
 +trainee cdrom floppy audio dip video plugdev netdev lpadmin scanner vboxusers 
 +trainee@debian11:~/.ansible/roles$ newgrp docker 
 +trainee@debian11:~/.ansible/roles$ groups 
 +docker cdrom floppy audio dip video plugdev netdev lpadmin scanner vboxusers trainee 
 +trainee@debian11:~/.ansible/roles$ 
 </code> </code>
  
Ligne 184: Ligne 333:
  
 <code> <code>
-trainee@ansible:~/.ansible/roles$ mkdir docker+trainee@debian11:~/.ansible/roles$ mkdir docker
 </code> </code>
  
Ligne 190: Ligne 339:
  
 <code> <code>
-[trainee@centos8 roles]$ vi playbook.yaml  +trainee@debian11:~/.ansible/roles$ vi playbook.yaml  
-[trainee@centos8 roles]$ cat playbook.yaml +trainee@debian11:~/.ansible/roles$ cat playbook.yaml 
 --- ---
 - hosts: all - hosts: all
Ligne 202: Ligne 351:
  
 <code> <code>
-[trainee@centos8 roles]$ cp inventory inventory.old +trainee@debian11:~/.ansible/roles$ cp inventory inventory.old 
-[trainee@centos8 roles]$ vi inventory +trainee@debian11:~/.ansible/roles$ vi inventory 
-[trainee@centos8 roles]$ cat inventory+trainee@debian11:~/.ansible/roles$ cat inventory
 postgresql ansible_connection=docker postgresql ansible_connection=docker
 </code> </code>
Ligne 211: Ligne 360:
  
 <code> <code>
-[trainee@centos8 roles]$ rm -rf /home/trainee/.ansible/roles/group_vars/all.yaml+trainee@debian11:~/.ansible/roles$ rm -rf /home/trainee/.ansible/roles/group_vars/all.yaml
 </code> </code>
  
-Exécutez la commande **ansible-playbook** en tant que **root** :+Exécutez la commande **ansible-playbook** :
  
 <code> <code>
-[root@centos8 roles]# ansible-playbook -i inventory playbook.yaml +trainee@debian11:~/.ansible/rolesansible-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: [postgresql] ok: [postgresql]
  
-TASK [message] ***************************************************************************************************************************************************************************************************+TASK [message] ***********************************************************************************************************************************************************************************************
 ok: [postgresql] => { ok: [postgresql] => {
     "msg": "Conteneur - postgresql sous CentOS"     "msg": "Conteneur - postgresql sous CentOS"
 } }
  
-PLAY RECAP ******************************************************************************************************************************************************************************************************* +PLAY RECAP *************************************************************************************************************************************************************************************************** 
-postgresql                 : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    +postgresql                 : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 </code> </code>
  
Ligne 294: Ligne 441:
  
 <code> <code>
-PS C:\Windows\system32> $url = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"+PS C:\Windows\system32> $url = "https://raw.githubusercontent.com/AlbanAndrieu/ansible-windows/master/files/ConfigureRemotingForAnsible.ps1"
 PS C:\Windows\system32> $file = "$env:temp\ConfigureRemotingForAnsible.ps1" PS C:\Windows\system32> $file = "$env:temp\ConfigureRemotingForAnsible.ps1"
 PS C:\Windows\system32> (New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file) PS C:\Windows\system32> (New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
Ligne 433: Ligne 580:
 ====2.4 - Créer un Utilisateur Local pour Ansible==== ====2.4 - Créer un Utilisateur Local pour Ansible====
  
-Exécutez ensuite la commande suivante :+Retournez à l'accueil de Guacamole et connectez-vous à la machine virtuelle **Windows_10.0.2.58_VNC**. 
 + 
 +Lancez PowerShell en tant que l'administrateur et exécutez ensuite la commande suivante :
  
 <code> <code>
Ligne 473: Ligne 622:
 ====3.1 - Installer pywinrm==== ====3.1 - Installer pywinrm====
  
-Dans la machine virtuelle **centos8**, installez le support python pour WinRM :+Sous Debian 11, le paquet **python3-winrm** est déjà installé. 
 + 
 +Modifiez le fichier **/etc/hosts** :
  
 <code> <code>
-[trainee@centos8 ~]$ su -+trainee@debian11:~/.ansible/roles$ su -
 Password: fenestros Password: fenestros
  
-[root@centos8 ~]pip3 install "pywinrm>=0.3.0" +root@debian11:~# vi /etc/hosts
-Collecting pywinrm>=0.3.0 +
-  Downloading pywinrm-0.4.2-py2.py3-none-any.whl (44 kB) +
-     |████████████████████████████████| 44 kB 250 kB/s              +
-Collecting xmltodict +
-  Downloading xmltodict-0.12.0-py2.py3-none-any.whl (9.2 kB) +
-Requirement already satisfied: requests>=2.9.1 in /usr/lib/python3.6/site-packages (from pywinrm>=0.3.0) (2.20.0) +
-Requirement already satisfied: six in /usr/lib/python3.6/site-packages (from pywinrm>=0.3.0) (1.11.0) +
-Collecting requests-ntlm>=0.3.0 +
-  Downloading requests_ntlm-1.1.0-py2.py3-none-any.whl (5.7 kB) +
-Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/lib/python3.6/site-packages (from requests>=2.9.1->pywinrm>=0.3.0) (3.0.4) +
-Requirement already satisfied: idna<2.8,>=2.5 in /usr/lib/python3.6/site-packages (from requests>=2.9.1->pywinrm>=0.3.0) (2.5) +
-Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/lib/python3.6/site-packages (from requests>=2.9.1->pywinrm>=0.3.0) (1.24.2) +
-Collecting ntlm-auth>=1.0.2 +
-  Downloading ntlm_auth-1.5.0-py2.py3-none-any.whl (29 kB) +
-Requirement already satisfied: cryptography>=1.3 in /usr/local/lib64/python3.6/site-packages (from requests-ntlm>=0.3.0->pywinrm>=0.3.0) (36.0.1) +
-Requirement already satisfied: cffi>=1.12 in /usr/local/lib64/python3.6/site-packages (from cryptography>=1.3->requests-ntlm>=0.3.0->pywinrm>=0.3.0) (1.15.0) +
-Requirement already satisfied: pycparser in /usr/local/lib/python3.6/site-packages (from cffi>=1.12->cryptography>=1.3->requests-ntlm>=0.3.0->pywinrm>=0.3.0) (2.21) +
-Installing collected packages: ntlm-auth, xmltodict, requests-ntlm, pywinrm +
-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 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv +
-</code> +
- +
-Modifiez ensuite le fichier **/etc/hosts** :+
  
-<code> +root@debian11:~# cat /etc/hosts 
-[trainee@centos8 ~]$ su - +127.0.0.1       localhost 
-Passwordfenestros +10.0.2.46       debian11.ittraining.loc debian11
-[root@centos8 ~]# vi /etc/hosts +
-[root@centos8 ~]# cat /etc/hosts +
-127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 +
-::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 +
-10.0.2.45 centos8.ittraining.loc centos8+
 10.0.2.54 web01.i2tch.loc web01 10.0.2.54 web01.i2tch.loc web01
 10.0.2.55 web02.i2tch.loc web02 10.0.2.55 web02.i2tch.loc web02
Ligne 519: Ligne 642:
 10.0.2.53 targetb.i2tch.loc targetb 10.0.2.53 targetb.i2tch.loc targetb
 10.0.2.58 windows10 10.0.2.58 windows10
 +
 +# The following lines are desirable for IPv6 capable hosts
 +::1     localhost ip6-localhost ip6-loopback
 +ff02::1 ip6-allnodes
 +ff02::2 ip6-allrouters
 </code> </code>
  
Ligne 526: Ligne 654:
  
 <code> <code>
-[root@centos8 ~]# exit+root@debian11:~# exit
 logout logout
-[trainee@centos8 ~]$ vi inventory + 
-[trainee@centos8 ~]$ cat inventory+trainee@debian11:~$ vi inventory 
 + 
 +trainee@debian11:~$ cat inventory
 [windows] [windows]
 windows10 windows10
Ligne 543: Ligne 673:
  
 <code> <code>
-[trainee@centos8 ~]$ ansible windows -i inventory -m win_ping+trainee@debian11:~$ ansible windows -i inventory -m win_ping
 windows10 | SUCCESS => { windows10 | SUCCESS => {
     "changed": false,     "changed": false,
Ligne 557: Ligne 687:
  
 <code> <code>
-[trainee@centos8 ~]$ ansible windows -i inventory -m setup+trainee@debian11:~$ ansible windows -i inventory -m setup
 windows10 | SUCCESS => { windows10 | SUCCESS => {
     "ansible_facts": {     "ansible_facts": {
Ligne 724: Ligne 854:
  
 <code> <code>
-[trainee@centos8 ~]$ vi command.yml +trainee@debian11:~$ vi command.yml 
-[trainee@centos8 ~]$ cat command.yml+trainee@debian11:~$ cat command.yml
 --- ---
 - name: ipconfig - name: ipconfig
Ligne 739: Ligne 869:
  
 <code> <code>
-[trainee@centos8 ~]$ ansible-playbook command.yml -i inventory+trainee@debian11:~$ ansible-playbook command.yml -i inventory
  
 PLAY [ipconfig] ************************************************************************************************************************************************************************************************** PLAY [ipconfig] **************************************************************************************************************************************************************************************************
Ligne 787: Ligne 917:
  
 <code> <code>
-[trainee@centos8 ~]$ vi script1.ps1 +trainee@debian11:~$ vi script1.ps1 
-[trainee@centos8 ~]$ cat script1.ps1+trainee@debian11:~$ cat script1.ps1
 Start-Service -Name wuauserv Start-Service -Name wuauserv
 </code> </code>
Ligne 795: Ligne 925:
  
 <code> <code>
-[trainee@centos8 ~]$ vi winupdate.yml +trainee@debian11:~$ vi winupdate.yml 
-[trainee@centos8 ~]$ cat winupdate.yml+trainee@debian11:~$ cat winupdate.yml
 - name: "PowerShell script" - name: "PowerShell script"
   hosts: "windows"   hosts: "windows"
Ligne 808: Ligne 938:
  
 <code> <code>
-[trainee@centos8 ~]$ ansible-playbook winupdate.yml -i inventory+trainee@debian11:~$ ansible-playbook winupdate.yml -i inventory
  
 PLAY [PowerShell script] ***************************************************************************************************************************************************************************************** PLAY [PowerShell script] *****************************************************************************************************************************************************************************************
Ligne 826: Ligne 956:
  
 <code> <code>
-[trainee@centos8 ~]$ vi firefox.yml +trainee@debian11:~$ vi firefox.yml 
-[trainee@centos8 ~]$ cat firefox.yml+trainee@debian11:~$ cat firefox.yml
 --- ---
 - name: Install Firefox using Chocolatey - name: Install Firefox using Chocolatey
Ligne 841: Ligne 971:
  
 <code> <code>
-[trainee@centos8 ~]$ ansible-playbook firefox.yml -i inventory+trainee@debian11:~$ ansible-playbook firefox.yml -i inventory
  
 PLAY [Install Firefox using Chocolatey] ************************************************************************************************************************************************************************** PLAY [Install Firefox using Chocolatey] **************************************************************************************************************************************************************************
Ligne 861: Ligne 991:
  
 <code> <code>
-[trainee@centos8 ~]$ vi users.yml +trainee@debian11:~$ vi users.yml 
-[trainee@centos8 ~]$ cat users.yml+trainee@debian11:~$ cat users.yml
 --- ---
 - name: Create a user - name: Create a user
Ligne 879: Ligne 1009:
  
 <code> <code>
-[trainee@centos8 ~]$ ansible-playbook users.yml -i inventory+trainee@debian11:~$ ansible-playbook users.yml -i inventory
  
 PLAY [Create a user] ********************************************************************************************************************************************************************************************* PLAY [Create a user] *********************************************************************************************************************************************************************************************
Ligne 899: Ligne 1029:
 ----- -----
  
-Copyright © 2022 Hugh Norris.+Copyright © 2024 Hugh Norris.
Menu