Outils pour utilisateurs

Outils du site


infrastructure:ansible

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
infrastructure:ansible [2018/08/01 09:16] – créée ronaninfrastructure:ansible [2019/01/10 14:46] (Version actuelle) – [Windows support] rguyader
Ligne 147: Ligne 147:
 === Exemples === === Exemples ===
  
-  ansible-playbook -i production site.yml +  ansible-playbook -i production site.yml 
-  ansible-playbook -i production site.yml --tags ntp +  ansible-playbook -i production site.yml --tags ntp 
-  ansible-playbook -i production webservers.yml +  ansible-playbook -i production webservers.yml 
-  ansible-playbook -i production webservers.yml --limit boston +  ansible-playbook -i production webservers.yml --limit boston 
-  ansible-playbook -i production webservers.yml --limit boston[0-10] +  ansible-playbook -i production webservers.yml --limit boston[0-10] 
-  ansible-playbook -i production webservers.yml --limit boston[10-20] +  ansible-playbook -i production webservers.yml --limit boston[10-20] 
-  ansible boston -i production -m ping +  ansible boston -i production -m ping 
-  ansible boston -i production -m command -a '/sbin/reboot'+  ansible boston -i production -m command -a '/sbin/reboot'
  
 Confirm what task names would be run if I ran this command and said "just ntp tasks" Confirm what task names would be run if I ran this command and said "just ntp tasks"
  
-  ansible-playbook -i production webservers.yml --tags ntp --list-tasks+  ansible-playbook -i production webservers.yml --tags ntp --list-tasks
  
 Confirm what hostnames might be communicated with if I said "limit to boston" Confirm what hostnames might be communicated with if I said "limit to boston"
  
-  ansible-playbook -i production webservers.yml --limit boston --list-hosts+  ansible-playbook -i production webservers.yml --limit boston --list-hosts
  
 ===== Information préalable ===== ===== Information préalable =====
Ligne 181: Ligne 181:
 ===== Installation ===== ===== Installation =====
  
-  apt-get install ansible ansible-doc +  apt-get install ansible ansible-doc 
-  sudo sed --in-place "s/^remote_port/#remote_port/g" /etc/ansible/ansible.cfg +  sudo sed --in-place "s/^remote_port/#remote_port/g" /etc/ansible/ansible.cfg 
-  iceweasel /usr/share/doc/ansible-doc/html/index.html+  iceweasel /usr/share/doc/ansible-doc/html/index.html
  
 Par défaut, Ansible utilise l'authentification SSH par clef.\\ Par défaut, Ansible utilise l'authentification SSH par clef.\\
Ligne 247: Ligne 247:
 **Pinger les machines :** **Pinger les machines :**
  
-  ansible --inventory=${INVENTORY} --limit=${LIMIT} --forks=${PARALLELISM} --module-name=ping all+  ansible --inventory=${INVENTORY} --limit=${LIMIT} --forks=${PARALLELISM} --module-name=ping all
      
 **Voir si l'option UseDns est bien positionnee :** **Voir si l'option UseDns est bien positionnee :**
  
-  ansible --inventory=${INVENTORY} --limit=${LIMIT} --forks=${PARALLELISM} --module-name=command --args="bash -c 'cat /etc/ssh/sshd_config | grep -i dns'" all+  ansible --inventory=${INVENTORY} --limit=${LIMIT} --forks=${PARALLELISM} --module-name=command --args="bash -c 'cat /etc/ssh/sshd_config | grep -i dns'" all
    
  
Ligne 426: Ligne 426:
 Via powershell en natif. Requiert pywinrm sur la machine de contrôle :  Via powershell en natif. Requiert pywinrm sur la machine de contrôle : 
  
-  # pip install http://github.com/diyan/pywinrm/archive/master.zip#egg=pywinrm+<code bash> 
 +  pip install http://github.com/diyan/pywinrm/archive/master.zip#egg=pywinrm 
 +</code>
  
 Gestion de paquets via chocolatey : https://chocolatey.org\\ Gestion de paquets via chocolatey : https://chocolatey.org\\
Ligne 1458: Ligne 1460:
 (l'include ajoute le tag sur toutes les tashs inclues) (l'include ajoute le tag sur toutes les tashs inclues)
  
-  ansible-playbook example.yml --tags "configuration,packages" +  ansible-playbook example.yml --tags "configuration,packages" 
-  ansible-playbook example.yml --skip-tags "notification"+  ansible-playbook example.yml --skip-tags "notification"
  
 ===== Vault ===== ===== Vault =====
  
-  ansible-vault create foo.yml => demande un mot de passe +  ansible-vault create foo.yml => demande un mot de passe 
-  ansible-vault edit foo.yml +  ansible-vault edit foo.yml 
-  ansible-vault rekey foo.yml bar.yml baz.yml +  ansible-vault rekey foo.yml bar.yml baz.yml 
-  ansible-vault encrypt foo.yml bar.yml baz.yml +  ansible-vault encrypt foo.yml bar.yml baz.yml 
-  ansible-vault decrypt foo.yml bar.yml baz.yml +  ansible-vault decrypt foo.yml bar.yml baz.yml 
-  ansible-playbook site.yml --ask-vault-pass => lance un playbook qui appelle des fichiers chiffrés (avec le même mot de passe) +  ansible-playbook site.yml --ask-vault-pass => lance un playbook qui appelle des fichiers chiffrés (avec le même mot de passe) 
-  ansible-playbook site.yml --vault-password-file ~/.vault_pass.txt +  ansible-playbook site.yml --vault-password-file ~/.vault_pass.txt 
-  ansible-playbook site.yml --vault-password-file ~/.vault_pass.py+  ansible-playbook site.yml --vault-password-file ~/.vault_pass.py
  
 ===== Modules ===== ===== Modules =====
Ligne 1476: Ligne 1478:
 En ligne de commande : -m En ligne de commande : -m
  
-  ansible webservers -m service -a "name=httpd state=started" +  ansible webservers -m service -a "name=httpd state=started" 
-  ansible webservers -m ping +  ansible webservers -m ping 
-  ansible webservers -m command -a "/sbin/reboot -t now"+  ansible webservers -m command -a "/sbin/reboot -t now"
  
 En playbook : En playbook :
infrastructure/ansible.1533115005.txt.gz · Dernière modification : 2018/08/01 09:16 de ronan