Différences

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

Lien vers cette vue comparative

Prochaine révision
Révision précédente
elearning:workbooks:centos:8:lcf1000:l1004 [2023/11/02 17:16] – created adminelearning:workbooks:centos:8:lcf1000:l1004 [2023/11/12 11:47] (Version actuelle) admin
Ligne 22: Ligne 22:
     * LAB #3 - Configuration des Clients en fonction de l'Environnement     * LAB #3 - Configuration des Clients en fonction de l'Environnement
       * 3.1 - Préparation       * 3.1 - Préparation
-      * 3.2 - Installation +      * 3.2 - Création des Cookbooks  
 +      * 3.3 - Ajout de Clients au Chef Infra Server 
 +      * 3.4 - Configuration des Environnements 
 +      * 3.5 - Exécution avec Environnements
  
 =====Infrastructure===== =====Infrastructure=====
  
 L'infrastructure utilisée dans ce module est la suivante. L'infrastructure utilisée dans ce module est la suivante.
- 
-Stagiaires **11**, **12**, **14**, **15**, **16** et **17** : 
  
 ^ Type Machine ^ FQDN ^ IP ^  OS  ^  Version  ^  CPUs  ^  RAM (Mo)  ^  HDD (Go)  ^  User  ^  MdP  ^  MdP root  ^ ^ Type Machine ^ FQDN ^ IP ^  OS  ^  Version  ^  CPUs  ^  RAM (Mo)  ^  HDD (Go)  ^  User  ^  MdP  ^  MdP root  ^
-| VM | workstation.ittraining.loc | 10.0.2.111 |  Ubuntu  |  18.04  |  8  |  8192  |  50  |  trainee  |  trainee  |  S/O  | +| VM | workstation.ittraining.loc | 10.0.2.111 |  Ubuntu  |  18.04.6 LTS   8  |  8192  |  50  |  trainee  |  trainee  |  S/O  | 
-| VM | client.ittraining.loc | 10.0.2.112 |  Ubuntu  |  18.04  |  4  |  4096  |  50  |  trainee  |  trainee  |  S/O  | +| VM | client.ittraining.loc | 10.0.2.112 |  Ubuntu  |  18.04.6 LTS   4  |  4096  |  50  |  trainee  |  trainee  |  S/O  | 
-| VM | web01.i2tch.loc | 10.0.2.54 |  Debian  |  9  |  2  |  256  |  20  |  trainee  |  trainee  |  fenestros +| VM | web01.i2tch.loc | 10.0.2.54 |  Debian  |  9.7   2  |  256  |  20  |  trainee  |  trainee  |  fenestros 
-| VM | web02.i2tch.loc | 10.0.2.55 |  Debian  |  9  |  2  |  256  |  20  |  trainee  |  trainee  |  fenestros +| VM | web02.i2tch.loc | 10.0.2.55 |  Debian  |  9.7   2  |  256  |  20  |  trainee  |  trainee  |  fenestros 
-| VM | web02.i2tch.loc | 10.0.2.56 |  Debian  |  9  |  2  |  256  |  20  |  trainee  |  trainee  |  fenestros  |+| VM | web03.i2tch.loc | 10.0.2.56 |  Debian  |  9.7   2  |  256   20  |  trainee  |  trainee  |  fenestros 
 +| VM | targeta.i2tch.loc | 10.0.2.52 |  Debian  |  9.7  |  2  |  2048  |  20  |  trainee  |  trainee  |  fenestros 
 +| VM | targetb.i2tch.loc | 10.0.2.53 |  CentOS  |  7.6.1810  |  2  |  2048   20  |  trainee  |  trainee  |  fenestros  |
  
-Stagiaires **18**, **19**, **20**, **21**, **22** et **23** :+=====LAB #1 - La Commande chef-run=====
  
-^ Type Machine ^ FQDN ^ IP ^  OS  ^  Version  ^  CPUs  ^  RAM (Mo)  ^  HDD (Go)  ^  User  ^  MdP  ^  MdP root  ^ +====1.1 - Présentation====
-| VM | workstation.ittraining.loc | 10.0.3.111 |  Ubuntu  |  18.04  |  8  |  8192  |  50  |  trainee  |  trainee  |  S/O  | +
-| VM | client.ittraining.loc | 10.0.3.112 |  Ubuntu  |  18.04  |  4  |  4096  |  50  |  trainee  |  trainee  |  S/O  | +
-| VM | web01.i2tch.loc | 10.0.3.54 |  Debian  |  9  |  2  |  256  |  20  |  trainee  |  trainee  |  fenestros +
-| VM | web02.i2tch.loc | 10.0.3.55 |  Debian  |  9  |  2  |  256  |  20  |  trainee  |  trainee  |  fenestros +
-| VM | web02.i2tch.loc | 10.0.3.56 |  Debian  |  9  |  2  |  256  |  20  |  trainee  |  trainee  |  fenestros  |+
  
-Commencez donc par modifier le fichier **/etc/hosts** de votre VM **workstation.ittraining.loc**.+La commande **chef-run** permet d'exécuter des commandes ad-hoc localement ou sur des clients
  
-Stagiaires **11**, **12**, **14**, **15**, **16** et **17** :+Cette commande : 
 + 
 +  ne nécessite pas de Chef Infra Server, 
 +  ne nécessite pas de pré-installation de Chef Client sur le(s) client(s), 
 +  peut aussi exécuter une Recette ou un Cookbook, 
 +  peut configurer de multiples clients dans la même commande. 
 + 
 +====1.2 - Utiliser chef-run sur un Client Unique==== 
 + 
 +Commencez par modifier le fichier **/etc/hosts** de votre VM **workstation.ittraining.loc** :
  
 <code> <code>
Ligne 69: Ligne 76:
 ff02::2 ip6-allrouters ff02::2 ip6-allrouters
 </code> </code>
- 
-Stagiaires **18**, **19**, **20**, **21**, **22** et **23** : 
- 
-<code> 
-root@workstation:~/chef-repo/cookbooks# vi /etc/hosts 
-root@workstation:~/chef-repo/cookbooks# cat /etc/hosts 
-127.0.0.1       localhost 
-127.0.1.1       workstation 
-10.0.3.110      chefserver.ittraining.loc   chefserver 
-10.0.3.111      workstation.ittraining.loc  workstation 
-10.0.3.112      client.ittraining.loc       client 
-10.0.3.54       web01.i2tch.loc         web01 
-10.0.3.55       web02.i2tch.loc         web02 
-10.0.3.56       web03.i2tch.loc         web03 
- 
-# The following lines are desirable for IPv6 capable hosts 
-::1     ip6-localhost ip6-loopback 
-fe00::0 ip6-localnet 
-ff00::0 ip6-mcastprefix 
-ff02::1 ip6-allnodes 
-ff02::2 ip6-allrouters 
-</code> 
- 
-=====LAB #1 - La Commande chef-run===== 
- 
-====1.1 - Présentation==== 
- 
-La commande **chef-run** permet d'exécuter des commandes ad-hoc localement ou sur des clients.  
- 
-Cette commande : 
- 
-  * ne nécessite pas de Chef Infra Server, 
-  * ne nécessite pas de pré-installation de Chef Client sur le(s) client(s), 
-  * peut aussi exécuter une recipe ou un Cookbook, 
-  * peut configurer de multiples clients dans la même commande. 
- 
-====1.2 - Utiliser chef-run sur un Client Unique==== 
  
 Utilisez la commande **chef-run** pour arrêter le service apache2 sur la VM **web01.i2tch.loc** : Utilisez la commande **chef-run** pour arrêter le service apache2 sur la VM **web01.i2tch.loc** :
Ligne 131: Ligne 101:
 </code> </code>
  
-Connectez-vous à la VM **web01.i2tch.loc** à partir de votre VM **workstation.ittraining.loc**. +Connectez-vous à la VM **web01.i2tch.loc** à partir de votre VM **workstation.ittraining.loc** :
- +
-Stagiaires **11**, **12**, **14**, **15**, **16** et **17** :+
  
 <code> <code>
Ligne 152: Ligne 120:
 permitted by applicable law. permitted by applicable law.
 Last login: Thu Nov  2 13:35:52 2023 from 10.0.2.1 Last login: Thu Nov  2 13:35:52 2023 from 10.0.2.1
-</code> 
- 
-Stagiaires **18**, **19**, **20**, **21**, **22** et **23** : 
- 
-<code> 
-root@workstation:~/chef-repo/cookbooks# ssh -l trainee web01 
-The authenticity of host 'web01 (10.0.3.54)' can't be established. 
-ECDSA key fingerprint is SHA256:sEfHBv9azmK60cjqF/aJgUc9jg56slNaZQdAUcvBOvE. 
-Are you sure you want to continue connecting (yes/no)? yes 
-Warning: Permanently added 'web01,10.0.3.54' (ECDSA) to the list of known hosts. 
-Debian GNU/Linux 9 
-trainee@web01's password: trainee 
-Linux web01.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; 
-the exact distribution terms for each program are described in the 
-individual files in /usr/share/doc/*/copyright. 
- 
-Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent 
-permitted by applicable law. 
-Last login: Thu Nov  2 13:35:52 2023 from 10.0.3.1 
 </code> </code>
  
Ligne 334: Ligne 281:
  
 <code> <code>
-ot@workstation:~/chef-repo/cookbooks# tail /root/.chef-workstation/logs/default.log+root@workstation:~/chef-repo/cookbooks# tail /root/.chef-workstation/logs/default.log
 Recipe: cw_service::default Recipe: cw_service::default
   * service[apache2] action start   * service[apache2] action start
Ligne 454: Ligne 401:
 </code> </code>
  
-====1.4 - Utiliser chef-run avec un Cookbook==== +Dans le cas d'une erreur de l'exécution, des traces sont générées dans le fichier **/root/.chef-workstation/logs/errors.txt** :
  
-Utilisez maintenant la commande **chef-run** pour exécuter la Recipe **default** du Cookbook **apache2** dans la VM **web01.i2tch.loc** :+<code> 
 +root@workstation:~/chef-repo/cookbooks# chef-run web0[2:3] service apache2 action=disbale --sudo --user trainee --password trainee 
 +[✔] Packaging cookbook... done! 
 +[✔] Generating local policyfile... exporting... done! 
 +[✖] Applying service[apache2] from resource to targets. 
 +├── [✖] [web02] Failed to converge service[apache2]. 
 +└── [✖] [web03] Failed to converge service[apache2]. 
 + 
 +One or more actions has failed. 
 + 
 +A complete list of failures and possible resolutions can 
 +be found in the file below: 
 + 
 +  /root/.chef-workstation/logs/errors.txt 
 + 
 +root@workstation:~/chef-repo/cookbooks# cat /root/.chef-workstation/logs/errors.txt 
 +Host: web02 Error: CHEFCCR003: The action 'disbale' is not valid. Valid actions are: :nothing, :enable, :disable, :start, :stop, :restart, :reload, :mask, :unmask For more information, please consult the documentation for this resource: https://docs.chef.io/resource_reference.html 
 +Host: web03 Error: CHEFCCR003: The action 'disbale' is not valid. Valid actions are: :nothing, :enable, :disable, :start, :stop, :restart, :reload, :mask, :unmask For more information, please consult the documentation for this resource: https://docs.chef.io/resource_reference.html 
 +</code> 
 + 
 +Corrigez l'erreur et désactivez le service **apache2** : 
 + 
 +<code> 
 +root@workstation:~/chef-repo/cookbooks# chef-run web0[2:3] service apache2 action=disable --sudo --user trainee --password trainee 
 +[✔] Packaging cookbook... done! 
 +[✔] Generating local policyfile... exporting... done! 
 +[✔] Applying service[apache2] from resource to targets. 
 +├── [✔] [web02] Successfully converged service[apache2]. 
 +└── [✔] [web03] Successfully converged service[apache2]. 
 +</code> 
 + 
 +====1.4 - Utiliser chef-run avec un Cookbook==== 
 + 
 +Installez le paquet **git** : 
 + 
 +<code> 
 +root@workstation:~/chef-repo/cookbooks# apt install git 
 +</code> 
 + 
 +Utilisez la commande **git init** pour initialiser le répertoire **/root/chef-repo/cookbooks** en tant que **repository** git : 
 + 
 +<code> 
 +root@workstation:~/chef-repo/cookbooks# git init 
 +</code> 
 + 
 +Utilisez maintenant la commande **chef-run** pour exécuter la Recette **default** du Cookbook **apache2** dans la VM **web01.i2tch.loc** :
  
 <code> <code>
Ligne 517: Ligne 509:
 ====2.1 - Présentation==== ====2.1 - Présentation====
  
-Un **Rôle** est une façon logique de regrouper des clients ou **noeuds**. Chaque Rôle possède des **run-lists** pour pouvoir configurer les noeuds associés avec le Rôle. Une Run-List est un groupement de Cookbooks ou de Recipes. Pour associer un noeud à un Rôle, Chef utilise des **tags**. La manipulation des Rôles s'effectue grâce à l'utilisation de la commande **knife**. +Un **Rôle** est une façon logique de regrouper des clients ou **noeuds**. Chaque Rôle possède des **run-lists** pour pouvoir configurer les noeuds associés avec le Rôle. Une Run-List est un groupement de Cookbooks ou de Recettes. Pour associer un noeud à un Rôle, Chef utilise des **tags**. La manipulation des Rôles s'effectue grâce à l'utilisation de la commande **knife**. 
  
 ====2.2 - Création de Rôles==== ====2.2 - Création de Rôles====
Ligne 580: Ligne 572:
 </code> </code>
  
-Connectez-vous ensuite à votre VM **ChefServer_10.0.2.110_VNC** ou **ChefServer_10.0.3.110_VNC** selon votre numéro de stagiaire.+Connectez-vous ensuite à votre VM **ChefServer_10.0.2.110_VNC**.
  
-Ouvrez le navigateur Web et naviguez à l'adresse **10.0.2.110** ou **10.0.3.110** selon le cas :+Ouvrez le navigateur Web et naviguez à l'adresse **10.0.2.110** :
  
 {{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-02_16-17-26.png?direct&600 |}} {{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-02_16-17-26.png?direct&600 |}}
Ligne 606: Ligne 598:
 {{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-02_16-33-35.png?direct&600 |}} {{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-02_16-33-35.png?direct&600 |}}
  
-Connectez-vous ensuite à votre VM **ChefServer_10.0.2.110_SSH** ou **ChefServer_10.0.3.110_SSH** selon votre numéro de stagiaire.+Connectez-vous ensuite à votre VM **ChefServer_10.0.2.110_SSH**.
  
 Modifiez maintenant la configuration du client **client.ittraining.loc** en référencant le Rôle dans le **run_list**. Sauvegardez et quittez le fichier : Modifiez maintenant la configuration du client **client.ittraining.loc** en référencant le Rôle dans le **run_list**. Sauvegardez et quittez le fichier :
Ligne 666: Ligne 658:
 ====3.1 - Présentation==== ====3.1 - Présentation====
  
-<code>+La gestion des **Environnements** est similaire à la gestion des Rôles. Un environnement est une phase de développement telle **Développement** ou **Production**. Tous les clients font partis de l'environnement par défaut, appelé **_default**. Il est possible d'appliquer des Recettes ou des Cookbooks différents en fonction de l'environnement.
  
-</code>+====3.2 - Création des Cookbooks==== 
 + 
 +Téléchargez le fichier **nginx.tar** :
  
 <code> <code>
 +root@workstation:~/chef-repo/cookbooks# wget https://files-accl.zohoexternal.com/public/workdrive-external/download/p9zfo77176af8ccf44e4a9cff3dc316a00cf0
 +--2023-11-03 13:37:07--  https://files-accl.zohoexternal.com/public/workdrive-external/download/p9zfo77176af8ccf44e4a9cff3dc316a00cf0
 +Resolving files-accl.zohoexternal.com (files-accl.zohoexternal.com)... 169.148.154.32, 169.62.46.83, 169.148.154.31, ...
 +Connecting to files-accl.zohoexternal.com (files-accl.zohoexternal.com)|169.148.154.32|:443... connected.
 +HTTP request sent, awaiting response... 200 OK
 +Length: 30720 (30K) [application/x-unknown]
 +Saving to: ‘p9zfo77176af8ccf44e4a9cff3dc316a00cf0’
 +
 +p9zfo77176af8ccf44e4a9cff3dc316a00cf0                100%[====================================================================================================================> 30,00K  --.-KB/   in 0,08s   
  
 +2023-11-03 13:37:08 (372 KB/s) - ‘p9zfo77176af8ccf44e4a9cff3dc316a00cf0’ saved [30720/30720]
 </code> </code>
  
-<code>+Renommez le fichier téléchargé et désarchivez-le :
  
 +<code>
 +root@workstation:~/chef-repo/cookbooks# mv p9zfo77176af8ccf44e4a9cff3dc316a00cf0 nginx.tar
 +root@workstation:~/chef-repo/cookbooks# tar xvf nginx.tar
 +nginx/
 +nginx/.gitignore
 +nginx/.delivery/
 +nginx/.delivery/project.toml
 +nginx/Policyfile.rb
 +nginx/kitchen.yml
 +nginx/chefignore
 +nginx/recipes/
 +nginx/recipes/default.rb
 +nginx/CHANGELOG.md
 +nginx/spec/
 +nginx/spec/spec_helper.rb
 +nginx/spec/unit/
 +nginx/spec/unit/recipes/
 +nginx/spec/unit/recipes/default_spec.rb
 +nginx/metadata.rb
 +nginx/files/
 +nginx/files/default/
 +nginx/files/default/index.html
 +nginx/LICENSE
 +nginx/test/
 +nginx/test/integration/
 +nginx/test/integration/default/
 +nginx/test/integration/default/default_test.rb
 +nginx/README.md
 </code> </code>
  
-<code>+Modifiez le fichier **/root/chef-repo/cookbooks/nginx/files/default/index.html** :
  
 +<code>
 +root@workstation:~/chef-repo/cookbooks# vi nginx/files/default/index.html 
 +root@workstation:~/chef-repo/cookbooks# cat nginx/files/default/index.html 
 +<html>
 +  <head>
 +    <title>Hello from chef</title>
 +  </head>
 +  <body>
 +    <h1>This is a nginx server</h1>
 +    <p>Happy Production!</p>
 +  </body>
 +</html>
 </code> </code>
  
-<code>+Téléversez maintenant le Cookbook vers le Chef Infra Server :
  
 +<code>
 +root@workstation:~/chef-repo/cookbooks# knife cookbook upload nginx
 +Uploading nginx          [0.1.0]
 +Uploaded 1 cookbook.
 </code> </code>
  
-<code>+Modifiez de nouveau le fichier **/root/chef-repo/cookbooks/nginx/files/default/index.html** :
  
 +<code>
 +root@workstation:~/chef-repo/cookbooks# vi nginx/files/default/index.html 
 +root@workstation:~/chef-repo/cookbooks# cat nginx/files/default/index.html 
 +<html>
 +  <head>
 +    <title>Hello from chef</title>
 +  </head>
 +  <body>
 +    <h1>This is a nginx server</h1>
 +    <p>Happy Development!</p>
 +  </body>
 +</html>
 </code> </code>
 +
 +Afin de ne pas écraser le Cookbook déjà téléversé, créez une nouvelle vesrion de celiu-ci en éditant le fichier **/root/chef-repo/cookbooks/metadat.rb** :
  
 <code> <code>
 +root@workstation:~/chef-repo/cookbooks# vi nginx/metadata.rb 
 +root@workstation:~/chef-repo/cookbooks# cat nginx/metadata.rb 
 +name 'nginx'
 +maintainer 'The Authors'
 +maintainer_email 'you@example.com'
 +license 'All Rights Reserved'
 +description 'Installs/Configures nginx'
 +version '0.1.1'
 +chef_version '>= 14.0'
  
 +# The `issues_url` points to the location where issues for this cookbook are
 +# tracked.  A `View Issues` link will be displayed on this cookbook's page when
 +# uploaded to a Supermarket.
 +#
 +# issues_url 'https://github.com/<insert_org_here>/nginx/issues'
 +
 +# The `source_url` points to the development repository for this cookbook.  A
 +# `View Source` link will be displayed on this cookbook's page when uploaded to
 +# a Supermarket.
 +#
 +# source_url 'https://github.com/<insert_org_here>/nginx'
 </code> </code>
 +
 +Téléversez ensuite le nouveau Cookbook vers le Chef Infra Server :
  
 <code> <code>
 +root@workstation:~/chef-repo/cookbooks# knife cookbook upload nginx 
 +Uploading nginx          [0.1.1] 
 +Uploaded 1 cookbook.
 </code> </code>
  
-<code>+====3.3 - Ajout de Clients au Chef Infra Server====
  
-</code>+Configurez deux nouveaux clients **targeta** et **targetb** :
  
 <code> <code>
 +root@workstation:~/chef-repo/cookbooks# ssh -l trainee 10.0.2.52
 +The authenticity of host '10.0.2.52 (10.0.2.52)' can't be established.
 +ECDSA key fingerprint is SHA256:sEfHBv9azmK60cjqF/aJgUc9jg56slNaZQdAUcvBOvE.
 +Are you sure you want to continue connecting (yes/no)? yes
 +Warning: Permanently added '10.0.2.52' (ECDSA) to the list of known hosts.
 +Debian GNU/Linux 9
 +trainee@10.0.2.52's password: trainee
 +Linux targeta.i2tch.loc 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64
  
-</code>+The programs included with the Debian GNU/Linux system are free software; 
 +the exact distribution terms for each program are described in the 
 +individual files in /usr/share/doc/*/copyright.
  
-<code>+Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent 
 +permitted by applicable law. 
 +Last login: Sun Mar 21 08:47:45 2021 from 10.0.2.10
  
 +trainee@targeta:~$ su -
 +Mot de passe : fenestros
 </code> </code>
  
-<code> +Editez la directive **PermitRootLogin** du fichier **/etc/ssh/sshd_config** afin de permettre l'utilisateur **root** de se connecter au client :
- +
-</code>+
  
 <code> <code>
 +root@targeta:~# vi /etc/ssh/sshd_config
 +
 +root@targeta:~# cat /etc/ssh/sshd_config
 +...
 +PermitRootLogin yes 
 +...
  
 +root@targeta:~# systemctl restart ssh
 </code> </code>
 +
 +Editez ensuite le fichier **/etc/hosts** :
  
 <code> <code>
 +root@targeta:~# vi /etc/hosts
 +root@targeta:~# cat /etc/hosts
 +127.0.0.1       localhost
 +10.0.2.110      chefserver.ittraining.loc   chefserver
 +10.0.2.111      workstation.ittraining.loc  workstation
 +10.0.2.52       web02.i2tch.loc    web02 
 +10.0.2.53       web03.i2tch.loc    web03
  
 +
 +# 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>
  
-<code>+Modifiez le FQDN de la VM :
  
 +<code>
 +root@targeta:~# hostnamectl set-hostname web02.i2tch.loc
 </code> </code>
 +
 +Mettez à jour les dépôts des paquets :
  
 <code> <code>
 +root@targeta:~# sed -i s/ftp.fr.debian.org/archive.debian.org/g /etc/apt/sources.list
  
-</code>+root@targeta:~# sed -i '/debian-security/d' /etc/apt/sources.list
  
-<code>+root@targeta:~# sed -i '/stretch-updates/d' /etc/apt/sources.list
  
 +root@targeta:~# apt update
 +Ign:1 http://archive.debian.org/debian stretch InRelease
 +Réception de:2 http://archive.debian.org/debian stretch Release [118 kB]
 +Réception de:3 http://archive.debian.org/debian stretch Release.gpg [3 177 B]
 +Réception de:4 http://archive.debian.org/debian stretch/main Sources [6 736 kB]
 +Réception de:5 http://archive.debian.org/debian stretch/main amd64 Packages [7 080 kB]
 +Réception de:6 http://archive.debian.org/debian stretch/main Translation-fr [1 894 kB]
 +Réception de:7 http://archive.debian.org/debian stretch/main Translation-en [5 377 kB]
 +21,2 Mo réceptionnés en 6s (3 302 ko/s)                                                                                                                                                                      
 +Lecture des listes de paquets... Fait
 +Construction de l'arbre des dépendances       
 +Lecture des informations d'état... Fait
 +226 packages can be upgraded. Run 'apt list --upgradable' to see them.
 </code> </code>
 +
 +Créez le répertoire **/var/www/html** :
  
 <code> <code>
 +root@targeta:~# mkdir -p /var/www/html
 </code> </code>
  
-<code>+Quittez la VM **targeta** :
  
 +<code>
 +root@targeta:~# exit
 +déconnexion
 +trainee@targeta:~$ exit
 +déconnexion
 +Connection to 10.0.2.52 closed.
 </code> </code>
 +
 +Utilisez la commande **knife bootstrap** pour référencer le client avec le Chef Infra Server :
  
 <code> <code>
 +root@workstation:~/chef-repo/cookbooks# knife bootstrap 10.0.2.52 --ssh-user root --ssh-password fenestros --node-name web02
 +Connecting to 10.0.2.52
 +The authenticity of host '10.0.2.52 ()' can't be established.
 +fingerprint is SHA256:Tk/PXJFmWnE96DhFsYAaFqgHQXPJhw+ArPP/GG9IJTw.
  
 +Are you sure you want to continue connecting
 +? (Y/N) Y
 +Connecting to 10.0.2.52
 +Creating new client for web02
 +Creating new node for web02
 +Bootstrapping 10.0.2.52
 + [10.0.2.52] -----> Installing Chef Omnibus (stable/15)
 +downloading https://omnitruck.chef.io/chef/install.sh
 +  to file /tmp/install.sh.1340/install.sh
 +trying wget...
 + [10.0.2.52] debian 9 x86_64
 +Getting information for chef stable 15 for debian...
 +downloading https://omnitruck.chef.io/stable/chef/metadata?v=15&p=debian&pv=9&m=x86_64
 +  to file /tmp/install.sh.1344/metadata.txt
 + [10.0.2.52] trying wget...
 + [10.0.2.52] sha1       168e534c58f9e17394bc9ba7112ee2280fecdd79
 +sha256  a50884a3c0be26875c329de9a1cea854eacb0a0a1ed031301ee6c29aad0f19ed
 +url     https://packages.chef.io/files/stable/chef/15.17.4/debian/9/chef_15.17.4-1_amd64.deb
 +version 15.17.4
 + [10.0.2.52] 
 + [10.0.2.52] downloaded metadata file looks valid...
 + [10.0.2.52] downloading https://packages.chef.io/files/stable/chef/15.17.4/debian/9/chef_15.17.4-1_amd64.deb
 +  to file /tmp/install.sh.1344/chef_15.17.4-1_amd64.deb
 +...
 + [10.0.2.52] Chef Infra Client finished, 0/0 resources updated in 01 seconds
 + [10.0.2.52] 
 + [10.0.2.52] [2023-11-03T15:53:49+01:00] WARN: This release of Chef Infra Client became end of life (EOL) on May 1st 2021. Please update to a supported release to receive new features, bug fixes, and security updates.
 </code> </code>
  
-<code>+Connectez-vous à la VM **targetb** :
  
 +<code>
 +root@workstation:~/chef-repo/cookbooks# ssh -l trainee 10.0.2.53
 +The authenticity of host '10.0.2.53 (10.0.2.53)' can't be established.
 +ECDSA key fingerprint is SHA256:RgOsp/XI7JHNq+oIfHKw+jkHdtTnBIh+Dd7kVmHRxtU.
 +Are you sure you want to continue connecting (yes/no)? yes
 +Warning: Permanently added '10.0.2.53' (ECDSA) to the list of known hosts.
 +trainee@10.0.2.53's password: trainee
 +Last login: Sun Mar 21 08:53:18 2021 from 10.0.2.10
 +[trainee@targetb ~]$ su -
 +Password: fenestros
 +Last login: dim. mars 21 08:53:25 CET 2021 on pts/0
 </code> </code>
 +
 +Modifiez la directive **PermitRootLogin** du fichier **/etc/ssh/sshd_config** afin de permettre l'utilisateur **root** de se connecter au client :
  
 <code> <code>
 +[root@targetb ~]# vi /etc/ssh/sshd_config 
  
-</code>+[root@targetb ~]# cat /etc/ssh/sshd_config  
 +#       $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
  
-<code>+# This is the sshd server system-wide configuration file.  See 
 +# sshd_config(5) for more information.
  
-</code>+# This sshd was compiled with PATH=/usr/local/bin:/usr/bin
  
-<code>+# The strategy used for options in the default sshd_config shipped with 
 +# OpenSSH is to specify options with their default value where 
 +# possible, but leave them commented.  Uncommented options override the 
 +# default value.
  
 +# If you want to change the port on a SELinux system, you have to tell
 +# SELinux about this change.
 +# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
 +...
 +PermitRootLogin yes
 +...
 +
 +[root@targetb ~]# systemctl restart sshd
 </code> </code>
 +
 +Editez ensuite le fichier **/etc/hosts** :
  
 <code> <code>
 +[root@targetb ~]# vi /etc/hosts
  
 +[root@targetb ~]# cat /etc/hosts
 +127.0.0.1               localhost.localdomain localhost
 +::1             localhost6.localdomain6 localhost6
 +10.0.2.110      chefserver.ittraining.loc   chefserver
 +10.0.2.111      workstation.ittraining.loc  workstation
 +10.0.2.52       web02.i2tch.loc    web02
 +10.0.2.53       web03.i2tch.loc    web03
 </code> </code>
  
-<code>+Modifiez le FQDN de la VM :
  
 +<code>
 +[root@targetb ~]# hostnamectl set-hostname web03.i2tch.loc
 </code> </code>
  
-<code>+La VM **targetb** étant une CentOS 7, le paquet **nginx** est disponible dans le dépôt **epel-release**. Installez donc ce dépôt :
  
 +<code>
 +[root@targetb ~]# yum install epel-release
 </code> </code>
  
-<code>+Créez le répertoire **/var/www/html** :
  
 +<code>
 +[root@targetb ~]# mkdir -p /var/www/html
 </code> </code>
 +
 +Déconnectez-vous de la VM :
  
 <code> <code>
 +[root@targetb ~]# exit
 +déconnexion
  
 +trainee@targetb:~$ exit
 +déconnexion
 </code> </code>
  
-<code> +Utilisez maintenant la commande **knife bootstrap** pour référencer le client avec le Chef Infra Server :
- +
-</code>+
  
 <code> <code>
 +root@workstation:~/chef-repo/cookbooks# knife bootstrap 10.0.2.53 --ssh-user root --ssh-password fenestros --node-name web03
 +--ssh-user: This flag is deprecated. Use -U/--connection-user instead.
 +--ssh-password: This flag is deprecated. Use -P/--connection-password instead.
 +Connecting to 10.0.2.53
 +The authenticity of host '10.0.2.53 ()' can't be established.
 +fingerprint is SHA256:PokJEptX8i3G+Qdy2WFX9xWby1d+l/0FhVyN1onGXnQ.
  
 +Are you sure you want to continue connecting
 +? (Y/N) Y
 +Connecting to 10.0.2.53
 +Creating new client for web03
 +Creating new node for web03
 +Bootstrapping 10.0.2.53
 + [10.0.2.53] -----> Installing Chef Omnibus (stable/15)
 +downloading https://omnitruck.chef.io/chef/install.sh
 +  to file /tmp/install.sh.14275/install.sh
 +trying wget...
 + [10.0.2.53] el 7 x86_64
 +Getting information for chef stable 15 for el...
 +downloading https://omnitruck.chef.io/stable/chef/metadata?v=15&p=el&pv=7&m=x86_64
 +  to file /tmp/install.sh.14285/metadata.txt
 + [10.0.2.53] trying wget...
 + [10.0.2.53] sha1       9e066d888611971a1dceb7c3eaf0375a6c61ebd0
 +sha256  0aaf56d149bdddc73b501322777ac378e2ffb63aa6eb714d93b16714e166e4f0
 +url     https://packages.chef.io/files/stable/chef/15.17.4/el/7/chef-15.17.4-1.el7.x86_64.rpm
 +version 15.17.4
 + [10.0.2.53] 
 + [10.0.2.53] downloaded metadata file looks valid...
 + [10.0.2.53] downloading https://packages.chef.io/files/stable/chef/15.17.4/el/7/chef-15.17.4-1.el7.x86_64.rpm
 +  to file /tmp/install.sh.14285/chef-15.17.4-1.el7.x86_64.rpm
 +...
 +Chef Infra Client finished, 0/0 resources updated in 03 seconds
 +[2023-11-03T16:07:23+01:00] WARN: This release of Chef Infra Client became end of life (EOL) on May 1st 2021. Please update to a supported release to receive new features, bug fixes, and security updates.
 </code> </code>
  
-<code>+====3.4 - Configuration des Environnements====
  
-</code>+Editez le fichier **/etc/hosts** de votre VM **workstation.ittraining.loc** :
  
 <code> <code>
 +root@workstation:~/chef-repo/cookbooks# vi /etc/hosts
 +root@workstation:~/chef-repo/cookbooks# cat /etc/hosts
 +127.0.0.1       localhost
 +127.0.1.1       workstation
 +10.0.2.110      chefserver.ittraining.loc   chefserver
 +10.0.2.111      workstation.ittraining.loc  workstation
 +10.0.2.112      client.ittraining.loc       client
 +10.0.2.52       web02.i2tch.loc    web02
 +10.0.2.53       web03.i2tch.loc    web03
  
 +# The following lines are desirable for IPv6 capable hosts
 +::1     ip6-localhost ip6-loopback
 +fe00::0 ip6-localnet
 +ff00::0 ip6-mcastprefix
 +ff02::1 ip6-allnodes
 +ff02::2 ip6-allrouters
 </code> </code>
  
-<code>+Connectez-vous ensuite à votre VM **ChefServer_10.0.2.110_VNC**.
  
-</code>+Ouvrez le navigateur Web et naviguez à l'adresse **10.0.2.110** :
  
-<code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_13-50-25.png?600 |}}
  
-</code>+Cliquez sur l'onglet **Policy** :
  
-<code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_13-50-57.png?600 |}}
  
-</code>+Cliquez sur la ligne **nginx** :
  
-<code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_13-51-28.png?600 |}}
  
-</code>+<WRAP center round important 50%> 
 +**Important** - Notez les deux versions présentes - **0.1.1** et **0.1.0** 
 +</WRAP>
  
-<code>+Cliquez sur **Environments** dans le menu de gauche :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_13-51-59.png?600 |}}
  
-<code>+Cliquez sur **Create** dans le menu de gauche et renseignez la création de l'environnement appelé **Dev**. Cliquez ensuite sur le bouton **Create Environment** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_13-53-39.png?600 |}}
  
-<code>+Vous obtiendrez :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_13-54-04.png?600 |}}
  
-<code>+Répétez le processus pour créer l'environnement appelé **Prod** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_13-54-55.png?600 |}}
  
-<code>+Vous obtiendrez :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_13-55-13.png?600 |}}
  
-<code>+Cliquez sur la ligne **Dev** puis sur le lien **Edit** dans le panneau **Cookbook Constraints** Renseignez une contrainte afin que l'environnement utilise la version **0.1.1** du Cookbook **nginx** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_13-58-31.png?600 |}}
  
-<code>+Cliquez sur le bouton **Add** puis sur le bouton **Save Constraints** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_14-01-16.png?600 |}}
  
-<code>+Répétez le processus pour créer une contrainte pour l'environnement **Prod** en spécifiant le version **0.1.0** du Cookbook :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_14-01-50.png?600 |}}
  
-<code>+Cliquez sur l'onglet **Nodes** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_17-32-07.png?600 |}}
  
-<code>+Cliquez sur la ligne **web02** et modifiez l'environnement à **Dev** puis cliquez sur le bouton **Save** : 
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_17-32-33.png?600 |}}
  
-<code>+Cliquez sur la ligne **web03** et modifiez l'environnement à **Prod** puis cliquez sur le bouton **Save** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_17-33-16.png?600 |}}
  
-<code>+Cliquez sur la roue dentée à dans la ligne **web03** puis cliquez sur le lien **Edit Run List**. Dans la fenêtre qui apparait, faites glisser **nginx** de **Available Recipes** vers **Current Run List**. Cliquez ensuite sur le bouton **Save Run List** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_17-37-40.png?600 |}}
  
-<code>+Utilisez le même processus pour affecter **nginx** à la **Current Run List** de **web02** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_17-38-18.png?600 |}}
  
-<code>+Cliquez sur la ligne **web03** et vérifiez que la **Run List** contient **nginx** versions **0.1.0** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_17-38-57.png?600 |}}
  
-<code>+Cliquez sur la ligne **web02** et vérifiez que la **Run List** contient **nginx** versions **0.1.1** :
  
-</code>+{{ :elearning:workbooks:centos:8:lcf1000:capture_d_ecran_du_2023-11-03_17-39-17.png?600 |}}
  
-<code>+====3.5 - Exécution avec Environnements====
  
-</code>+Connectez-vous à la VM **web02.i2tch.loc** et devenez l'utilisateur **root** puis exécutez la commande **chef-client** :
  
 <code> <code>
 +root@web02:~# chef-client
 +Starting Chef Infra Client, version 15.17.4
 +resolving cookbooks for run list: ["nginx"]
 +Synchronizing Cookbooks:
 +  - nginx (0.1.1)
 +Installing Cookbook Gems:
 +Compiling Cookbooks...
 +Converging 3 resources
 +Recipe: nginx::default
 +  * apt_package[nginx] action install
 +    - install version 1.10.3-1+deb9u4 of package nginx
 +  * service[nginx] action enable (up to date)
 +  * service[nginx] action start (up to date)
 +  * cookbook_file[/var/www/html/index.html] action create
 +    - create new file /var/www/html/index.html
 +    - update content in file /var/www/html/index.html from none to bfe461
 +    --- /var/www/html/index.html        2023-11-04 13:17:29.520612571 +0100
 +    +++ /var/www/html/.chef-index20231104-5615-1pw0ng9.html     2023-11-04 13:17:29.520612571 +0100
 +    @@ -1 +1,10 @@
 +    +<html>
 +    +  <head>
 +    +    <title>Hello from chef</title>
 +    +  </head>
 +    +  <body>
 +    +    <h1>This is a nginx server</h1>
 +    +    <p>Happy Development!</p>
 +    +  </body>
 +    +</html>
 +    - change mode from '' to '0644'
  
 +Running handlers:
 +Running handlers complete
 +Chef Infra Client finished, 2/4 resources updated in 19 seconds
 +[2023-11-04T13:17:29+01:00] WARN: This release of Chef Infra Client became end of life (EOL) on May 1st 2021. Please update to a supported release to receive new features, bug fixes, and security updates.
 </code> </code>
  
-<code>+<WRAP center round important 50%> 
 +**Important** - Notez la sortie **Synchronizing Cookbooks:** qui indique la version **nginx (0.1.1)**. 
 +</WRAP>
  
-</code>+Vérifiez le contenu du fichier **/var/www/html/index.html** :
  
 <code> <code>
 +root@web02:~# cat /var/www/html/index.html  
 +<html> 
 +  <head> 
 +    <title>Hello from chef</title> 
 +  </head> 
 +  <body> 
 +    <h1>This is a nginx server</h1> 
 +    <p>Happy Development!</p> 
 +  </body> 
 +</html>
 </code> </code>
  
-<code>+<WRAP center round important 50%> 
 +**Important** - Notez que vous êtes dans l'environnement **Dev**. 
 +</WRAP>
  
-</code>+Connectez-vous à la VM **web03.i2tch.loc** et devenez l'utilisateur **root** puis exécutez la commande **chef-client** :
  
 <code> <code>
 +[root@web03 ~]# chef-client
 +Starting Chef Infra Client, version 15.17.4
 +resolving cookbooks for run list: ["nginx"]
 +Synchronizing Cookbooks:
 +  - nginx (0.1.0)
 +Installing Cookbook Gems:
 +Compiling Cookbooks...
 +Converging 3 resources
 +Recipe: nginx::default
 +  * yum_package[nginx] action install (up to date)
 +  * service[nginx] action enable (up to date)
 +  * service[nginx] action start (up to date)
 +  * cookbook_file[/var/www/html/index.html] action create
 +    - update content in file /var/www/html/index.html from bfe461 to a89b2b
 +    --- /var/www/html/index.html        2023-11-04 12:40:57.072941692 +0100
 +    +++ /var/www/html/.chef-index20231104-19702-1kw3xch.html    2023-11-04 12:54:51.404871486 +0100
 +    @@ -4,7 +4,7 @@
 +       </head>
 +       <body>
 +         <h1>This is a nginx server</h1>
 +    -    <p>Happy Development!</p>
 +    +    <p>Happy Production!</p>
 +       </body>
 +     </html>
 +    - restore selinux security context
  
 +Running handlers:
 +Running handlers complete
 +Chef Infra Client finished, 1/4 resources updated in 04 seconds
 +[2023-11-04T12:54:51+01:00] WARN: This release of Chef Infra Client became end of life (EOL) on May 1st 2021. Please update to a supported release to receive new features, bug fixes, and security updates.
 </code> </code>
  
-<code>+<WRAP center round important 50%> 
 +**Important** - Notez la sortie **Synchronizing Cookbooks:** qui indique la version **nginx (0.1.0)**. 
 +</WRAP>
  
-</code>+Vérifiez le contenu du fichier **/var/www/html/index.html** :
  
 <code> <code>
 +[root@web03 ~]# cat /var/www/html/index.html 
 +<html> 
 +  <head> 
 +    <title>Hello from chef</title> 
 +  </head> 
 +  <body> 
 +    <h1>This is a nginx server</h1> 
 +    <p>Happy Production!</p> 
 +  </body> 
 +</html>
 </code> </code>
  
-<code>+<WRAP center round important 50%> 
 +**Important** - Notez que vous êtes dans l'environnement **Prod**. 
 +</WRAP>
  
-</code> 
 ----- -----
  
 Copyright © 2023 Hugh Norris. Copyright © 2023 Hugh Norris.
Menu