Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 60fdbf2894 | |||
| 7cf66dd251 | |||
| fb1e196dcf | |||
| cd79ce015c | |||
| 28cf59a071 | |||
| 0f48b2e04c | |||
| ebfec195ba | |||
| 8d7420a67c | |||
| 3214dc0a7f |
61
Readme.md
Normal file
61
Readme.md
Normal file
@@ -0,0 +1,61 @@
|
||||
## Installer et configurer ansible
|
||||
|
||||
**Tâche**: Installer et configurer ansible
|
||||
|
||||
**Condition**: Quand on souhaite utiliser ansible depuis son poste
|
||||
|
||||
**Norme**: gestionnaire de paquet, vim, ansible-config
|
||||
|
||||
### **Pratique:**
|
||||
|
||||
#### Installation
|
||||
|
||||
Installer ansible et cowsay avec le gestionnaire de paquet.
|
||||
|
||||
S'assurer de la présence des commandes ansible, ansible-playbook, ansible-inventory, etc...
|
||||
|
||||
#### Configuration
|
||||
|
||||
Faites une copie de sauvegarde de /etc/ansible/ansible.cfg
|
||||
|
||||
Récupérer le fichier ansible.cfg et installez le sur votre poste dans /etc/ansible
|
||||
|
||||
Dans le pad, en vous aidant de la documentation explicitez les directives suivantes:
|
||||
|
||||
* forks = 20
|
||||
* ask_pass = true *sera changée une fois les cibles correctement configurées*
|
||||
* host_key_checking = false
|
||||
* remote_user = formation *sera changé une fois les cibles correctement configurées*
|
||||
* become = true
|
||||
* become_ask_pass = true *sera changé ultérieurement*
|
||||
* retry_files_enabled = false
|
||||
* ansible_managed = Ansible managed : {file} modified on %Y-%m-%d by {uid} on {host}
|
||||
* gathering = smart
|
||||
* fact_caching = jsonfile
|
||||
* fact_caching_connection = /etc/ansible/facts
|
||||
* fact_caching_timeout = 86400
|
||||
* pipelining = True
|
||||
* callback_enabled = ansible.posix.timer, ansible.posix.profile_tasks
|
||||
|
||||
#### post configuration
|
||||
|
||||
Créer le répertoire **/etc/ansible/facts** (l'opérateur doit pouvoir écrire dedans)
|
||||
|
||||
Valider avec la commande ansible-config dump
|
||||
|
||||
Si vous utilisez **vi** pour l'édition de playbook, je vous invite à rajouter la ligne suivante dans votre fichier ~/.vimrc:
|
||||
|
||||
```
|
||||
set softtabstop=2 expandtab shiftwidth=2 smarttab autoindent
|
||||
```
|
||||
|
||||
Enfin, l'utilisation du plugin [identLine](https://github.com/Yggdroot/indentLine.git) peut également aider
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Yggdroot/indentLine.git ~/.vim/pack/vendor/start/indentLine
|
||||
vim -u NONE -c "helptags ~/.vim/pack/vendor/start/indentLine/doc" -c "q"
|
||||
```
|
||||
|
||||
**Performance**: On peut utiliser la commande *ansible-config
|
||||
|
||||
Proposition de solution: voir branche "solution"
|
||||
@@ -10,6 +10,7 @@ fact_caching = jsonfile
|
||||
fact_caching_connection = /etc/ansible/facts
|
||||
fact_caching_timeout = 86400
|
||||
retry_files_enabled = False
|
||||
strategy = free
|
||||
ansible_managed = Ansible managed : {file} modified on %Y-%m-%d by {uid} on {host}
|
||||
[inventory]
|
||||
[privilege_escalation]
|
||||
|
||||
45
solution.md
45
solution.md
@@ -1,45 +0,0 @@
|
||||
```bash
|
||||
sudo dnf install cowsay ansible # sur centos 8
|
||||
sudo yum install cowsay ansible # sur centos 7
|
||||
```
|
||||
|
||||
```bash
|
||||
grep -v -E '^(\s+#|#|$)' /etc/ansible/ansible.cfg
|
||||
```
|
||||
|
||||
```ini
|
||||
[defaults]
|
||||
forks = 20
|
||||
ask_pass = True
|
||||
gathering = smart
|
||||
host_key_checking = False
|
||||
callback_enabled = ansible.posix.timer, ansible.posix.profile_tasks
|
||||
remote_user = formation
|
||||
fact_caching = jsonfile
|
||||
fact_caching_connection = /etc/ansible/facts
|
||||
fact_caching_timeout = 86400
|
||||
retry_files_enabled = False
|
||||
[inventory]
|
||||
[privilege_escalation]
|
||||
become = True
|
||||
become_ask_pass = True
|
||||
[paramiko_connection]
|
||||
[ssh_connection]
|
||||
pipelining = True
|
||||
[persistent_connection]
|
||||
[accelerate]
|
||||
[selinux]
|
||||
[colors]
|
||||
[diff]
|
||||
```
|
||||
|
||||
```bash
|
||||
$ mkdir -m 1777 /etc/ansible/facts
|
||||
$ ansible-config dump
|
||||
```
|
||||
|
||||
```bash
|
||||
$ echo 'set softtabstop=2 expandtab shiftwidth=2 smarttab autoindent' >> ~/.vimrc
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user