Outils pour utilisateurs

Outils du site


informatique: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
informatique:ansible [11/11/2017 17:38] – créée cyrilleinformatique:ansible [05/10/2023 18:41] (Version actuelle) – [Vagrant] cyrille
Ligne 2: Ligne 2:
  
   * http://docs.ansible.com   * http://docs.ansible.com
 +  * [[https://lightcode.fr/article/ansible-conseils-organisation/|Ansible : conseils d'organisation]]
 +
 +Installer ''ansible''
 +
 +<code bash>
 +sudo apt-add-repository ppa:ansible/ansible
 +
 +sudo apt install ansible
 +Les NOUVEAUX paquets suivants seront installés :
 +  ansible ansible-core python-babel-localedata python3-babel python3-jinja2 python3-jmespath python3-kerberos
 +  python3-ntlm-auth python3-requests-kerberos python3-requests-ntlm python3-resolvelib python3-winrm python3-xmltodict
 +  sshpass
 +</code>
 +
 +Définir le user ssh, changer le port :
 +
 +<code>
 +$ ansible <all|the_host> -e "ansible_user=debian" -e "ansible_port=30001" -m ping
 +</code>
  
 ===== OpenStack ===== ===== OpenStack =====
 +
 +  * dynamic inventory via openstack [[http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html#example-openstack-external-inventory-script|http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html#example-openstack-external-inventory-script]]
 +  * [[https://community.runabove.com/kb/en/instances/use-openstack-command-line-tools.html|https://community.runabove.com/kb/en/instances/use-openstack-command-line-tools.html]]
 +
 +Voir aussi: [[:informatique:cloud_computing#openstack|]]
  
 Install Openstack python client Install Openstack python client
-<code bash>+ 
 +<code>
 sudo apt-get install python-os-client-config python-shade sudo apt-get install python-os-client-config python-shade
 </code> </code>
  
-Get the Openstack.rc file+Get the ''Openstack.rc''  file 
 + 
 +{{:informatique:openstack-rc_in_horizon_at_ovh.png?nolink&520}} 
 + 
 +Then source it (api password will be asked), and give a try 
 + 
 +<code> 
 +$ wget https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/openstack.py 
 +$ chmod +x openstack.py 
 +$ source xxxxxxxxxxx-openrc.sh 
 +$ ./openstack.py --list 
 +</code> 
 + 
 +===== Docker ===== 
 + 
 +Pratique d'utiliser Docker pour tester des playbooks. 
 + 
 +Attention, on ne peut pas tout faire car il manque la gestion des services, mais pour des manipulations de fichiers ça le fait. Il y a des images avec systemd mais quid des nouveaux ports à exposer ? Je n'ai pas //encore// trouvé de solution toute simple :-(. 
 + 
 +Une image docker à partir de Debian pour faire tourner un serveur OpenSSH 
 +  * https://gitlab.com/Artefacts/docker-openssh-hosts/-/tree/main 
 + 
 +Aperçu de l'idée de la Dockerfile: 
 +<code> 
 +
 +# Run an OpenSSH server 
 +
 +# Build: 
 +# docker build -t "cyrille37/openssh-server" -f openssh.dockerfile . 
 +# Run: 
 +# docker run -p 22:22 --name "sshd" --rm cyrille37/openssh-server 
 +# Stop: 
 +# docker stop sshd 
 +
 + 
 +FROM debian:12-slim 
 + 
 +LABEL MAINTAINER Cyrille37 
 + 
 +RUN apt -y update && apt -y install openssh-server sudo locales \ 
 +    && rm -rf /var/lib/apt/lists/
 + 
 +# set locale to fr_FR to allow french accented characters 
 +RUN localedef -i fr_FR -c -f UTF-8 -A /usr/share/locale/locale.alias fr_FR.UTF-8 
 +ENV LANG fr_FR.utf8 
 + 
 +# create user "milou" with password "secret" and permits `sudo` without password 
 +RUN useradd -m -s /bin/bash -G sudo -u 1000 milou 
 +RUN usermod -aG sudo milou 
 +RUN  echo 'milou:secret' | chpasswd 
 +RUN echo "milou ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers 
 + 
 +# Mandatory to avoid "Missing privilege separation directory: /run/sshd" 
 +RUN service ssh start 
 + 
 +EXPOSE 22 
 + 
 +CMD ["/usr/sbin/sshd","-D"
 +</code> 
 + 
 +Pour aller plus loin: 
 +  * https://www.ansible.com/blog/testing-ansible-roles-with-docker 
 +  * https://github.com/chrismeyersfsu/provision_docker/ 
 + 
 +===== Vagrant =====
  
 +  * [[/informatique/vagrant|/informatique/vagrant]]
 +  * https://symfonycasts.com/screencast/ansible/vagrant-ansible
  
informatique/ansible.1510418298.txt.gz · Dernière modification : 11/11/2017 17:38 de cyrille

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki