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/20 16:22] – admin | elearning:workbooks:centos:8:lcf900:l704 [2024/12/03 14:37] (Version actuelle) – admin | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ~~PDF: | ~~PDF: | ||
| - | Version : **2022.02** | + | Version : **2024.01** |
| Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
| - | ======LCF804 | + | ======LDF904 |
| =====Contenu du Module===== | =====Contenu du Module===== | ||
| - | * **LCF804 | + | * **LDF904 |
| * 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' | + | Docker n'est pas dans le dépôts de Debian. Afin de l' |
| < | < | ||
| - | [trainee@centos8 roles]$ su - | + | root@debian11:~# apt-get update |
| - | Password: fenestros | + | ... |
| - | [root@centos8 | + | root@debian11:~# apt-get install apt-transport-https |
| - | Adding repo from: https://download.docker.com/linux/centos/ | + | 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 | ||
| + | Use 'apt autoremove' | ||
| + | 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 | + | Téléchargez la clef GPG officielle de docker : |
| - | Docker CE Stable | + | |
| - | Last metadata expiration check: 0:00:01 ago on Wed 09 Mar 2022 12:38:58 EST. | + | < |
| - | Available Packages | + | root@debian11:~# curl -fsSL https:// |
| - | docker-ce.x86_64 | + | Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). |
| + | OK | ||
| </ | </ | ||
| - | Installez ensuite | + | Vérifiez que l'ID de la clef est **9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88** : |
| < | < | ||
| - | [root@centos8 | + | root@debian11:~# apt-key fingerprint 0EBFCD88 |
| - | Last metadata expiration check: 0:06:03 ago on Wed 09 Mar 2022 12:38:58 EST. | + | Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). |
| - | containerd.io-1.2.10-3.2.el7.x86_64.rpm | + | pub |
| - | Dependencies resolved. | + | 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 |
| - | ================================================================================================================================================================================================================== | + | uid [ unknown] Docker Release (CE deb) < |
| - | | + | sub |
| - | ================================================================================================================================================================================================================== | + | </ |
| - | Installing: | + | |
| - | | + | |
| - | replacing | + | |
| - | Transaction Summary | + | Ajoutez le dépôt **stable** de docker : |
| - | ================================================================================================================================================================================================================== | + | |
| - | Install | + | |
| - | Total size: 23 M | + | < |
| - | Is this ok [y/N]: y | + | root@debian11: |
| </ | </ | ||
| + | |||
| + | <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**. | ||
| + | </ | ||
| Installez maintenant le paquet **docker-ce** : | Installez maintenant le paquet **docker-ce** : | ||
| < | < | ||
| - | [root@centos8 | + | root@debian11docker: |
| + | ... | ||
| + | root@debian11: | ||
| + | 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' | ||
| + | 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 | ||
| </ | </ | ||
| - | Dernièrement, | + | Dernièrement, |
| < | < | ||
| - | [root@centos8 ~]# systemctl status docker | + | root@debian11:~# docker version |
| - | ● docker.service - Docker Application Container Engine | + | |
| - | | + | |
| - | | + | |
| - | Docs: https:// | + | |
| - | Main PID: 59410 (dockerd) | + | |
| - | Tasks: 16 | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | 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: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 | + | |
| Client: Docker Engine - Community | Client: Docker Engine - Community | ||
| - | | + | |
| - | API version: | + | API version: |
| - | Go version: | + | Go version: |
| - | Git commit: | + | Git commit: |
| - | | + | |
| | | ||
| | | ||
| - | | ||
| Server: Docker Engine - Community | Server: Docker Engine - Community | ||
| | | ||
| - | Version: | + | Version: |
| - | API version: | + | API version: |
| - | Go version: | + | Go version: |
| - | Git commit: | + | Git commit: |
| - | Built: | + | Built: |
| OS/ | OS/ | ||
| Experimental: | Experimental: | ||
| | | ||
| - | Version: | + | Version: |
| - | GitCommit: | + | GitCommit: |
| runc: | runc: | ||
| - | Version: | + | Version: |
| - | GitCommit: | + | GitCommit: |
| | | ||
| - | Version: | + | Version: |
| - | GitCommit: | + | GitCommit: |
| </ | </ | ||
| - | <WRAP center round important> | + | <WRAP center round important |
| - | **Important** - Docker est composé de trois éléments : un serveur, un client | + | **Important** - Notez que le paquet docker-ce a besoin des paquets **containerd.io** |
| </ | </ | ||
| - | Démarrez un conteneur | + | Dans le cas où vous souhaitez installer une version différente, |
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | Dans le cas où vous souhaiteriez installer la version **24.0.1** de Docker, la commande d’installation deviendrait : | ||
| + | |||
| + | < | ||
| + | # apt-get install docker-ce=5: | ||
| + | </ | ||
| + | |||
| + | Si vous préférez utiliser le script d' | ||
| + | |||
| + | <WRAP center round important 50%> | ||
| + | **Important** - Notez que ces scripts ne doivent pas être utilisés dans un environnement de production. | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | |||
| + | root@debian11: | ||
| + | get-docker.sh | ||
| + | </ | ||
| + | |||
| + | Ensuite, il convient d' | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | |||
| + | root@debian11: | ||
| + | # Executing docker install script, commit: c2de0811708b6d9015ed1a2c80f02c9b70c8ce7b | ||
| + | Warning: the " | ||
| + | |||
| + | 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 | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 50%> | ||
| + | **Important** - Notez l' | ||
| + | </ | ||
| + | |||
| + | Démarrez un conteneur | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | Unable to find image ' | ||
| + | latest: Pulling from library/ | ||
| + | 719385e32844: | ||
| + | Digest: sha256: | ||
| + | Status: Downloaded newer image for hello-world: | ||
| + | |||
| + | 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 " | ||
| + | (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: | ||
| + | | ||
| + | |||
| + | For more examples and ideas, visit: | ||
| + | | ||
| + | </ | ||
| + | |||
| + | <WRAP center round important 50%> | ||
| + | **Important** - Notez que si l' | ||
| + | </ | ||
| + | |||
| + | Lancez maintenant un conteneur postgresql : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | 7d948c33b2f42e1823ae22353815ea674695fa1dc9e6bd70acc49a80651845c5 | ||
| + | </ | ||
| + | |||
| + | Vérifiez l'état du conteneur : | ||
| + | |||
| + | < | ||
| + | root@debian11: | ||
| + | CONTAINER ID | ||
| + | 7d948c33b2f4 | ||
| + | </ | ||
| + | |||
| + | Ajoutez | ||
| < | < | ||
| - | [root@centos8 ~]# docker run -d --name postgresql centos sleep infinity | + | root@debian11:/ |
| - | Unable to find image ' | + | root@debian11:/home/ |
| - | latest: Pulling from library/centos | + | trainee |
| - | a1d0c7532777: Pull complete | + | |
| - | Digest: sha256: | + | |
| - | Status: Downloaded newer image for centos: | + | |
| - | 1028e25f81d14d685678794902cd599aa618eb283d80e274526d71ec9708e69d | + | |
| </ | </ | ||
| - | Vérifiez que le conteneur fonctionne | + | Redevenez l' |
| < | < | ||
| - | [root@centos8 ~]# docker ps -a | + | root@debian11:/ |
| - | CONTAINER ID | + | |
| - | 1028e25f81d1 | + | |
| - | [root@centos8 ~]# exit | + | |
| logout | logout | ||
| - | [trainee@centos8 | + | trainee@debian11: |
| + | trainee cdrom floppy audio dip video plugdev netdev lpadmin scanner vboxusers | ||
| + | trainee@debian11: | ||
| + | trainee@debian11: | ||
| + | docker cdrom floppy audio dip video plugdev netdev lpadmin scanner vboxusers trainee | ||
| + | trainee@debian11: | ||
| </ | </ | ||
| Ligne 184: | Ligne 333: | ||
| < | < | ||
| - | trainee@ansible: | + | trainee@debian11: |
| </ | </ | ||
| Ligne 190: | Ligne 339: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11: |
| - | [trainee@centos8 | + | trainee@debian11: |
| --- | --- | ||
| - hosts: all | - hosts: all | ||
| Ligne 202: | Ligne 351: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11: |
| - | [trainee@centos8 | + | trainee@debian11: |
| - | [trainee@centos8 | + | trainee@debian11: |
| postgresql ansible_connection=docker | postgresql ansible_connection=docker | ||
| </ | </ | ||
| Ligne 211: | Ligne 360: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11: |
| </ | </ | ||
| - | Exécutez la commande **ansible-playbook** en tant que **root** : | + | Exécutez la commande **ansible-playbook** : |
| < | < | ||
| - | [root@centos8 | + | trainee@debian11: |
| - | [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] => { | ||
| " | " | ||
| } | } | ||
| - | PLAY RECAP ******************************************************************************************************************************************************************************************************* | + | PLAY RECAP *************************************************************************************************************************************************************************************************** |
| - | postgresql | + | postgresql |
| </ | </ | ||
| Ligne 294: | Ligne 441: | ||
| < | < | ||
| - | PS C: | + | PS C: |
| PS C: | PS C: | ||
| PS C: | PS C: | ||
| Ligne 433: | Ligne 580: | ||
| ====2.4 - Créer un Utilisateur Local pour Ansible==== | ====2.4 - Créer un Utilisateur Local pour Ansible==== | ||
| - | Exécutez | + | Retournez à l' |
| + | |||
| + | Lancez PowerShell en tant que l' | ||
| < | < | ||
| Ligne 473: | Ligne 622: | ||
| ====3.1 - Installer pywinrm==== | ====3.1 - Installer pywinrm==== | ||
| - | Dans la machine virtuelle | + | Sous Debian 11, le paquet |
| + | |||
| + | Modifiez | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~/ |
| Password: fenestros | Password: fenestros | ||
| - | [root@centos8 | + | root@debian11:~# vi /etc/hosts |
| - | 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> | + | |
| - | Downloading requests_ntlm-1.1.0-py2.py3-none-any.whl (5.7 kB) | + | |
| - | Requirement already satisfied: chardet< | + | |
| - | Requirement already satisfied: idna< | + | |
| - | 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 ' | + | |
| - | </ | + | |
| - | + | ||
| - | Modifiez ensuite le fichier **/etc/hosts** : | + | |
| - | < | + | root@debian11:~# cat / |
| - | [trainee@centos8 ~]$ su - | + | 127.0.0.1 |
| - | Password: fenestros | + | 10.0.2.46 |
| - | [root@centos8 | + | |
| - | [root@centos8 ~]# cat / | + | |
| - | 127.0.0.1 | + | |
| - | ::1 | + | |
| - | 10.0.2.45 centos8.ittraining.loc | + | |
| 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 | ||
| + | ff02::1 ip6-allnodes | ||
| + | ff02::2 ip6-allrouters | ||
| </ | </ | ||
| Ligne 526: | Ligne 654: | ||
| < | < | ||
| - | [root@centos8 | + | root@debian11:~# exit |
| logout | logout | ||
| - | [trainee@centos8 | + | |
| - | [trainee@centos8 | + | trainee@debian11:~$ vi inventory |
| + | |||
| + | trainee@debian11:~$ cat inventory | ||
| [windows] | [windows] | ||
| windows10 | windows10 | ||
| Ligne 543: | Ligne 673: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ ansible windows -i inventory -m win_ping |
| windows10 | SUCCESS => { | windows10 | SUCCESS => { | ||
| " | " | ||
| Ligne 557: | Ligne 687: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ ansible windows -i inventory -m setup |
| windows10 | SUCCESS => { | windows10 | SUCCESS => { | ||
| " | " | ||
| Ligne 724: | Ligne 854: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ vi command.yml |
| - | [trainee@centos8 | + | trainee@debian11:~$ cat command.yml |
| --- | --- | ||
| - name: ipconfig | - name: ipconfig | ||
| Ligne 739: | Ligne 869: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ ansible-playbook command.yml -i inventory |
| PLAY [ipconfig] ************************************************************************************************************************************************************************************************** | PLAY [ipconfig] ************************************************************************************************************************************************************************************************** | ||
| Ligne 787: | Ligne 917: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ vi script1.ps1 |
| - | [trainee@centos8 | + | trainee@debian11:~$ cat script1.ps1 |
| Start-Service -Name wuauserv | Start-Service -Name wuauserv | ||
| </ | </ | ||
| Ligne 795: | Ligne 925: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ vi winupdate.yml |
| - | [trainee@centos8 | + | trainee@debian11:~$ cat winupdate.yml |
| - name: " | - name: " | ||
| hosts: " | hosts: " | ||
| Ligne 808: | Ligne 938: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ ansible-playbook winupdate.yml -i inventory |
| PLAY [PowerShell script] ***************************************************************************************************************************************************************************************** | PLAY [PowerShell script] ***************************************************************************************************************************************************************************************** | ||
| Ligne 826: | Ligne 956: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ vi firefox.yml |
| - | [trainee@centos8 | + | trainee@debian11:~$ cat firefox.yml |
| --- | --- | ||
| - name: Install Firefox using Chocolatey | - name: Install Firefox using Chocolatey | ||
| Ligne 841: | Ligne 971: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ ansible-playbook firefox.yml -i inventory |
| PLAY [Install Firefox using Chocolatey] ************************************************************************************************************************************************************************** | PLAY [Install Firefox using Chocolatey] ************************************************************************************************************************************************************************** | ||
| Ligne 861: | Ligne 991: | ||
| < | < | ||
| - | [trainee@centos8 | + | trainee@debian11:~$ vi users.yml |
| - | [trainee@centos8 | + | trainee@debian11:~$ cat users.yml |
| --- | --- | ||
| - name: Create a user | - name: Create a user | ||
| Ligne 879: | Ligne 1009: | ||
| < | < | ||
| - | [trainee@centos8 | + | 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. |