Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 842ae5079a | |||
| a8264d2939 | |||
| bd8bf9711b | |||
| a3bff9a4ff | |||
| 2ebe8fb39c | |||
| 6f7cc0da89 | |||
| be3bb4199c | |||
| 37d26ae236 |
61
Readme.md
61
Readme.md
@@ -1,61 +0,0 @@
|
|||||||
## 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,7 +10,6 @@ fact_caching = jsonfile
|
|||||||
fact_caching_connection = /etc/ansible/facts
|
fact_caching_connection = /etc/ansible/facts
|
||||||
fact_caching_timeout = 86400
|
fact_caching_timeout = 86400
|
||||||
retry_files_enabled = False
|
retry_files_enabled = False
|
||||||
strategy = free
|
|
||||||
ansible_managed = Ansible managed : {file} modified on %Y-%m-%d by {uid} on {host}
|
ansible_managed = Ansible managed : {file} modified on %Y-%m-%d by {uid} on {host}
|
||||||
[inventory]
|
[inventory]
|
||||||
[privilege_escalation]
|
[privilege_escalation]
|
||||||
|
|||||||
45
solution.md
Normal file
45
solution.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
```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