Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
elearning:workbooks:debian:6:avance:l129:part3 [2019/11/03 11:28] – admin | elearning:workbooks:debian:6:avance:l129:part3 [2022/06/12 14:07] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
+ | |||
+ | Version : **2022.01** | ||
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======DOF503 | + | ======DOF403 |
+ | |||
+ | =====Contenu du Module===== | ||
+ | |||
+ | * **DOF403 - Variables, Expressions, | ||
+ | * Contenu du Module | ||
+ | * LAB #1 - Variables | ||
+ | * Variables Simples | ||
+ | * Tableaux | ||
+ | * Hashes | ||
+ | * LAB #2 - Expressions | ||
+ | * Expressions Mathématiques | ||
+ | * Expression Booléennes | ||
+ | * Expressions Régulières | ||
+ | * Expressions Conditionnelles | ||
+ | * LAB #3 - Facts | ||
+ | * Facts dans un Hash | ||
+ | * Facts dans une Expression | ||
+ | * Facts Externes | ||
+ | * Facts Exécutables | ||
+ | * LAB #4 - Itérations | ||
+ | * Itération et Tableaux | ||
+ | * Itération et Hashes | ||
- | =====LAB #16 - Variables===== | + | =====LAB #1 - Variables===== |
====Variables Simples==== | ====Variables Simples==== | ||
Ligne 19: | Ligne 43: | ||
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
- | **Important** - Le nom d'une variable doit commencer par le caractère **$** puis par une lettre | + | **Important** - Le nom d'une variable doit commencer par le caractère **$** puis par une lettre |
</ | </ | ||
Ligne 35: | Ligne 59: | ||
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
**Important** - La valeur d'un variable booléenne doit être **true** ou **false**. | **Important** - La valeur d'un variable booléenne doit être **true** ou **false**. | ||
</ | </ | ||
Ligne 46: | Ligne 70: | ||
$my_name = ' | $my_name = ' | ||
notice(" | notice(" | ||
+ | |||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.07 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.07 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
**Important** - Notez l' | **Important** - Notez l' | ||
</ | </ | ||
Ligne 93: | Ligne 118: | ||
< | < | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
- | Get:1 http:// | + | Hit:1 http:// |
- | Hit:2 http:// | + | Get:2 http:// |
- | Get:3 http:// | + | Get:3 http://security.ubuntu.com/ |
- | Ign:4 http:// | + | Get:4 http:// |
- | Hit:5 http:// | + | Hit:5 http://apt.puppetlabs.com xenial |
- | Get:6 http://archive.ubuntu.com/ | + | Fetched |
- | Get:7 http:// | + | |
- | Get:9 http://archive.ubuntu.com/ | + | |
- | Get:10 http:// | + | |
- | Fetched | + | |
Reading package lists... Done | Reading package lists... Done | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 1.52 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.48 seconds |
Notice: / | Notice: / | ||
Notice: / | Notice: / | ||
Ligne 112: | Ligne 133: | ||
Notice: / | Notice: / | ||
Notice: / | Notice: / | ||
- | Notice: Applied catalog in 91.09 seconds | + | Notice: Applied catalog in 16.33 seconds |
</ | </ | ||
Ligne 130: | Ligne 151: | ||
< | < | ||
+ | vagrant@ubuntu-xenial: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
$heights = { | $heights = { | ||
Ligne 147: | Ligne 169: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.07 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.07 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 168: | Ligne 190: | ||
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
**Important** - Le caractère ***** informe Puppet d' | **Important** - Le caractère ***** informe Puppet d' | ||
</ | </ | ||
Ligne 176: | Ligne 198: | ||
< | < | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.06 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
Notice: / | Notice: / | ||
- | Notice: Applied catalog in 0.08 seconds | + | Notice: Applied catalog in 0.01 seconds |
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
- | -rw-r--r-- 1 ubuntu ubuntu 0 May 28 15:59 /tmp/test | + | -rw-r--r-- 1 ubuntu ubuntu 0 Feb 11 13:42 /tmp/test |
</ | </ | ||
- | =====LAB #17 - Expressions===== | + | =====LAB #2 - Expressions===== |
====Expressions Mathématiques==== | ====Expressions Mathématiques==== | ||
- | Puppet peut gérer des expressions mathématiques. | + | Puppet peut gérer des expressions mathématiques. |
< | < | ||
Ligne 202: | Ligne 224: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.08 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.07 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
====Expression Booléennes==== | ====Expression Booléennes==== | ||
- | Puppet sait aussi gérer des expression booléennes, | + | Puppet sait aussi gérer des expression booléennes, |
< | < | ||
Ligne 228: | Ligne 250: | ||
Les opérateurs utilisés dans le fichier **expression_boolean.pp** sont les suivants : | Les opérateurs utilisés dans le fichier **expression_boolean.pp** sont les suivants : | ||
- | ^ Operateur | + | ^ Opérateur |
- | | == | Egal | | + | | == | Égal | |
| != | Pas égal | | | != | Pas égal | | ||
- | | >, >=, < et %%<=%% | Sauvegarde le document entier et non uniquement le script | + | | >, >=, < et %%<=%% | Supérieur, supérieur ou égal, inférieur, inférieur ou égal | |
| A in B | A est une sous-chaîne de B, A est un élément du tableau B ou A est une clef du Hash B | | | A in B | A est une sous-chaîne de B, A est un élément du tableau B ou A est une clef du Hash B | | ||
| A =~ B | A correspond à l' | | A =~ B | A correspond à l' | ||
Ligne 252: | Ligne 274: | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.09 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.08 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 275: | Ligne 297: | ||
< | < | ||
- | vagrant@ubuntu-xenial: | + | vagrant@ubuntu-xenial: |
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
Ligne 282: | Ligne 304: | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.08 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.08 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
**Important** - La syntaxe des expressions régulières Puppet est la même que celle de **Ruby**. Vous pouvez trouver plus d' | **Important** - La syntaxe des expressions régulières Puppet est la même que celle de **Ruby**. Vous pouvez trouver plus d' | ||
</ | </ | ||
Ligne 313: | Ligne 335: | ||
< | < | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 1.55 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.55 seconds |
- | Notice: Applied catalog in 0.17 seconds | + | Notice: Applied catalog in 0.04 seconds |
</ | </ | ||
Ligne 354: | Ligne 376: | ||
< | < | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 1.56 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.46 seconds |
Notice: / | Notice: / | ||
- | Notice: Applied catalog in 11.00 seconds | + | Notice: Applied catalog in 2.03 seconds |
</ | </ | ||
Ligne 374: | Ligne 396: | ||
</ | </ | ||
- | Une expression conditionnelle | + | HERE |
+ | |||
+ | Une expression conditionnelle | ||
< | < | ||
Ligne 399: | Ligne 423: | ||
< | < | ||
- | vagrant@ubuntu-xenial: | + | vagrant@ubuntu-xenial: |
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.07 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.07 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
- | =====LAB #18 - Facts===== | + | =====LAB #3 - Facts===== |
Les manifests de Puppet ont souvent besoin de connaître quelque chose concernant le système, par exemple : | Les manifests de Puppet ont souvent besoin de connaître quelque chose concernant le système, par exemple : | ||
Ligne 425: | Ligne 449: | ||
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
**Important** - Dans ce manifest est utilisé la variable **$facts**. Le fact recherché est fourni en tant que clef - dans notre exemple **kernel**. | **Important** - Dans ce manifest est utilisé la variable **$facts**. Le fact recherché est fourni en tant que clef - dans notre exemple **kernel**. | ||
</ | </ | ||
Ligne 434: | Ligne 458: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.06 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.08 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 442: | Ligne 466: | ||
< | < | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
- | ... | + | { |
- | " | + | architecture |
- | " | + | distro |
- | " | + | codename |
- | " | + | description |
- | " | + | id => " |
- | " | + | release |
- | " | + | full => " |
- | " | + | major => " |
- | " | + | } |
- | " | + | }, |
- | " | + | family |
- | " | + | hardware |
- | } | + | name => " |
- | }, | + | release |
- | " | + | full => " |
- | " | + | major => " |
- | " | + | }, |
- | " | + | selinux |
- | " | + | enabled |
- | " | + | } |
- | }, | + | } |
- | " | + | |
- | " | + | |
- | } | + | |
- | }, | + | |
- | ... | + | |
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
**Important** - Comme vous pouvez constater, la sortie est sous forme de Hashs multiples. | **Important** - Comme vous pouvez constater, la sortie est sous forme de Hashs multiples. | ||
</ | </ | ||
Ligne 486: | Ligne 505: | ||
< | < | ||
- | vagrant@ubuntu-xenial: | + | vagrant@ubuntu-xenial: |
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.07 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.08 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 503: | Ligne 522: | ||
< | < | ||
- | vagrant@ubuntu-xenial: | + | vagrant@ubuntu-xenial: |
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.06 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.07 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 522: | Ligne 541: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.06 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.07 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Pour obtenir le nom d' | Pour obtenir le nom d' | ||
+ | |||
< | < | ||
+ | vagrant@ubuntu-xenial: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
notice(" | notice(" | ||
Ligne 537: | Ligne 558: | ||
< | < | ||
- | vagrant@ubuntu-xenial: | + | vagrant@ubuntu-xenial: |
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.07 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.08 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 562: | Ligne 583: | ||
< | < | ||
- | vagrant@ubuntu-xenial: | + | vagrant@ubuntu-xenial: |
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.06 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.07 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 580: | Ligne 601: | ||
< | < | ||
- | vagrant@ubuntu-xenial: | + | vagrant@ubuntu-xenial: |
- | Notice: Scope(Class[main]): | + | Notice: Scope(Class[main]): |
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.07 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.08 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 627: | Ligne 648: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.07 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.01 seconds |
- | Notice: Applied catalog in 0.08 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 636: | Ligne 657: | ||
< | < | ||
+ | vagrant@ubuntu-xenial: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
#!/bin/bash | #!/bin/bash | ||
Ligne 647: | Ligne 669: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
vagrant@ubuntu-xenial: | vagrant@ubuntu-xenial: | ||
- | 2018-06-01 | + | 2020-02-11 |
</ | </ | ||
- | =====LAB #19 - Iteration===== | + | =====LAB #4 - Itérations===== |
- | Iteration | + | Itération |
- | ====Iteration | + | ====Itération |
- | Créez le fichier **iteration_simple;pp** | + | Créez le fichier **iteration_simple.pp** |
< | < | ||
Ligne 677: | Ligne 699: | ||
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
- | **Important** - Dans ce manifest il y a trois ressources | + | **Important** - Dans ce manifest il y a trois ressources |
</ | </ | ||
Ligne 684: | Ligne 706: | ||
< | < | ||
+ | vagrant@ubuntu-xenial: | ||
+ | vagrant@ubuntu-xenial: | ||
$tasks = [' | $tasks = [' | ||
$tasks.each | $task | { | $tasks.each | $task | { | ||
Ligne 693: | Ligne 717: | ||
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
**Important** - Dans ce manifest la fonction **each** crée une boucle qui prend pour chaque exécution une des valeurs du tableau **$tasks** ( **task1**, **task2**, **task3** ). | **Important** - Dans ce manifest la fonction **each** crée une boucle qui prend pour chaque exécution une des valeurs du tableau **$tasks** ( **task1**, **task2**, **task3** ). | ||
</ | </ | ||
Ligne 705: | Ligne 729: | ||
</ | </ | ||
- | <WRAP center round important | + | <WRAP center round important> |
**Important** - Ici ARRAY est un tableau et ELEMENT est le nom d'une variable qui contiendra chaque valeur du tableau à tour de rôle. BLOCK est du code Puppet qui appelle l' | **Important** - Ici ARRAY est un tableau et ELEMENT est le nom d'une variable qui contiendra chaque valeur du tableau à tour de rôle. BLOCK est du code Puppet qui appelle l' | ||
</ | </ | ||
Ligne 725: | Ligne 749: | ||
< | < | ||
- | vagrant@ubuntu-xenial: | + | vagrant@ubuntu-xenial: |
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
Notice: Scope(Class[main]): | Notice: Scope(Class[main]): | ||
- | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.10 seconds | + | Notice: Compiled catalog for ubuntu-xenial in environment production in 0.02 seconds |
- | Notice: Applied catalog in 0.08 seconds | + | Notice: Applied catalog in 0.01 seconds |
</ | </ | ||
Ligne 735: | Ligne 759: | ||
---- | ---- | ||
- | < | + | |
- | <DIV ALIGN=" | + | Copyright © 2022 Hugh Norris. |
- | Copyright © 2019 Hugh Norris.< | + | |
- | </ | + | |
- | </ | + |