Hello,
First of all, thanks for this nice software !
Current Ansible provisionner is able to download roles from Ansible Galaxy website during provisioning (option galaxy_role_file).
Since Ansible 2.8 and Galaxy 3.2, users can upload collections on Galaxy website.
Collections could be install using mazer tool and a collections lock file:
$ mazer install --collections-lock collections_lockfile.yml
collections_lockfile.yml (see format):
alikins.collection_inspect: "*"
alikins.collection_ntp: "*"
Have a dedicated option for Ansible provisionner to install collections from a collection lockfile if mazer is present on the host.
According to https://github.com/ansible/ansible/pull/57106, we will not need to support collections lockfile and mazer because support of ansible collections has been added to ansible-galaxy command starting from ansible 2.9.
I will made some tests when Ansible 2.9 will be released.
@nqb thank you very much! Please let us know when you have some Ansible 2.9+ results :+1:
Hello @gildegoma,
According to following documentations:
ansible-galaxy collection is now the command to manage collections, mazer has been deprecated.
A requirements file can be used to install collections and roles. Example:
---
roles:
- src: inverse_inc.gitlab_buildpkg_tools
collections:
- name: inverse_inc.packetfence
BUT:
While both roles and collections can be specified in one requirements file, they need to be installed separately. The ansible-galaxy role install -r requirements.yml will only install roles and ansible-galaxy collection install -r requirements.yml -p ./ will only install collections.
We can have same usage as for roles with following command:聽
ansible-galaxy collection install -r requirements.yml -p collections`
This will install collections in a relative collections directory which will be find by Ansible even if this path is not part of COLLECTIONS_PATHS (see https://docs.ansible.com/ansible/2.9/user_guide/collections_using.html#installing-collections-with-ansible-galaxy)
We certainly need to use a new compatibility mode for Ansible 2.9
+1
I did a test today with:
requirements.yml in my VAGRANT_CWD dir:---
roles:
- src: geerlingguy.nodejs
- src: inverse_inc.gitlab_buildpkg_tools
collections:
- name: inverse_inc.packetfence
- name: debops.debops
- name: inverse_inc.windows
- name: inverse_inc.cumulus
- name: inverse_inc.utils
config.vm.provision "ansible", type: 'ansible' do |ansible|
ansible.playbook = "site.yml"
ansible.config_file = "ansible.cfg"
ansible.inventory_path = "inventory"
ansible.galaxy_role_file = "requirements.yml"
end
ansible.cfg:[defaults]
inventory = inventory/
# change display of log
stdout_callback = yaml
# disable host key checking
host_key_checking = False
# forks
forks = 50
# Installs collections into [current dir]/ansible_collections/namespace/collection_name
collections_paths = ./
And due to changes related to ansible-galaxy command between 2.9 and 2.10, Vagrant Ansible provisioner installed roles and collections in my VAGRANT_CWD and everything works !
Trying to do ansible_local local provisioner, this doesn't work for me. So, as a hack I had to add the following to handle the installation of collections
ansible.galaxy_command = "sudo ansible-galaxy collection install -r %{role_file} --force && sudo ansible-galaxy role install -r %{role_file} --force"
which will just install it to the default collections location, but if people wanted to do the path as well ( like mentioned here: https://github.com/hashicorp/vagrant/issues/10958#issuecomment-558083915 ) then they should be able to add -p %{roles_path} like mentioned in this tips and tricks section: https://www.vagrantup.com/docs/provisioning/ansible_local#install-galaxy-roles-in-a-path-owned-by-root
Most helpful comment
Trying to do
ansible_locallocal provisioner, this doesn't work for me. So, as a hack I had to add the following to handle the installation of collectionswhich will just install it to the default collections location, but if people wanted to do the path as well ( like mentioned here: https://github.com/hashicorp/vagrant/issues/10958#issuecomment-558083915 ) then they should be able to add
-p %{roles_path}like mentioned in this tips and tricks section: https://www.vagrantup.com/docs/provisioning/ansible_local#install-galaxy-roles-in-a-path-owned-by-root