Voir :
Dépendances :
Exemple
/data/ansible/collections/ansible_collections/acme_it/test
.ansible.cfg
collections_path = /data/ansible/collections, $HOME/.ansible/collections, /usr/share/ansible/collections
Voir aussi la variable d’environnement ANSIBLE_COLLECTIONS_PATHS
collections/requirements.yml
--- collections: - name: https://git.acme.local/ansible_collections/my_collection # type: git scm: git version: master
ansible-galaxy collection install -r collections/requirements.yml -p /home/ansible/.ansible/collections/
- name: Install collections community.general.ansible_galaxy_install: type: collection requirements_file: collections/requirements.yml dest: ~/.ansible/collections/ changed_when: false
Les collections les plus utilisées
Dépôts distants :
Collection path
$ ansible --version | grep collection ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections $ ansible-config dump | grep -i collection $ ansible-config init --disabled | grep -i collection | grep -v ^#
Lister les collections installées
ansible-galaxy collection list
Rechercher une collection distante
ansible-galaxy search plop
collections/requirements.yml
--- collections: - name: https://acme.fr/plop/acme-plop.tar.gz version: X.Y.Z - name: git+https://git.acme.local/acme/plop.git#ansible_collections/acme/plop version: master
Rapatrier les collections distantes en local
ansible-galaxy collection install -r collections/requirements.yml
play.yml
#!/usr/bin/env ansible-playbook --- - name: exemple hosts: localhost collections: - acme.plop roles: - install_plop
Ou
git clone ssh://git@git.acme.fr/plop/plop.git cd plop/ mkdir ~/.ansible/ cp -a collection/ ~/.ansible/ ls -l ~/.ansible/collections/ansible_collections/awx ansible-doc acme.awx.tower_credential
roles/requirements.yml
--- - src: ssh://git@git.acme.local:2222/ansible/ansible-role-test_jb.git scm: git version: master
collections/requirements.yml
--- collections: - name: https://git.acme.fr/ansible-automation-platform/PlaybooksGroupe/dns_cache_enable # type: git scm: git
git.acme.fr/ansible-automation-platform/PlaybooksGroupe/dns_cache_enable
dns_cache_enable/
galaxy.yml
--- namespace: acme name: dns version: 1.0.0 license: BSD readme: README.md authors: - Jean <jean@acme.fr> description: DNS client collection
tasks/main.yml
- name: Enable local cache DNS include_role: name: acme.dns.enable_local_cache_dns
Chemin possible
Exemple d'arborescence :
git clone ssh://git@git.acme.fr/plop/projet1.git cd projet1/ mkdir ~/.ansible/ cp -a collection/ ~/.ansible/ ln -s ~/.ansible/collections/ansible_collections/acme ~/.ansible/collections/ansible_collections/awx ansible-doc acme.awx.tower_credential