Tools/Ansible/Best Practices : Différence entre versions
Sauter à la navigation
Sauter à la recherche
(Page créée avec « {{MediaWiki}} <br> {{FOND_BLEU|Ansible - '''Best Practices'''}} * Miser sur la simplicité * Faire preuve d'organisation * Tester régulièrement ») |
|||
| Ligne 2 : | Ligne 2 : | ||
<br> | <br> | ||
{{FOND_BLEU|Ansible - '''Best Practices'''}} | {{FOND_BLEU|Ansible - '''Best Practices'''}} | ||
| + | |||
| + | = Miser sur la simplicité = | ||
| + | == Lisibilité == | ||
| + | |||
| + | Il est préférable d'utiliser la syntaxe YAML "native". ex : | ||
| + | |||
| + | |||
| + | <syntaxhighlight lang="yaml"> | ||
| + | - name: Postfix is installed and updated | ||
| + | yum: | ||
| + | name: postfix | ||
| + | state: latest | ||
| + | notify: update_postfix | ||
| + | - name: Postfix is running | ||
| + | service: | ||
| + | name: postfix | ||
| + | state: started | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | et NON la forme suivante, moins lisible : | ||
| + | |||
| + | |||
| + | <syntaxhighlight lang="yaml"> | ||
| + | - name: Postfix is installed and updated | ||
| + | yum: name=postfix state=latest | ||
| + | notify: restart_postfix | ||
| + | - name: Postfix is running | ||
| + | service: name=postfix state=started | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | == Utilisation des modules == | ||
| + | |||
| + | == Adopter un style d'écriture YAML == | ||
| + | |||
| − | |||
* Faire preuve d'organisation | * Faire preuve d'organisation | ||
* Tester régulièrement | * Tester régulièrement | ||
Version du 6 mai 2020 à 17:55
Sommaire
Miser sur la simplicité
Lisibilité
Il est préférable d'utiliser la syntaxe YAML "native". ex :
- name: Postfix is installed and updated
yum:
name: postfix
state: latest
notify: update_postfix
- name: Postfix is running
service:
name: postfix
state: startedet NON la forme suivante, moins lisible :
- name: Postfix is installed and updated
yum: name=postfix state=latest
notify: restart_postfix
- name: Postfix is running
service: name=postfix state=startedUtilisation des modules
Adopter un style d'écriture YAML
- Faire preuve d'organisation
- Tester régulièrement