Best way to install ansible-galaxy requirements when using the Ansible Local provisioner?

584 views
Skip to first unread message

WowSuchMagic

unread,
Apr 26, 2017, 8:55:05 AM4/26/17
to Vagrant
We are using the Ansible Local provisioner to install the required software on our development Vagrant box. However, we want to use third party roles. The easiest solution to install those roles is using an ansible-galaxy requirements file: http://docs.ansible.com/ansible/galaxy.html#installing-multiple-roles-from-a-file

How can we execute ansible-galaxy before the playbook is run by Ansible Local? Is there a feature for this already that I have missed? You can't run ansible-galaxy as a task inside the playbook, because apparently the roles that a playbook requires are checked before its execution and if a role is not available the playbook is not run at all.

Alvaro Miranda Aguilera

unread,
Apr 26, 2017, 9:33:24 AM4/26/17
to vagra...@googlegroups.com
Hello

Perhaps you can avoid the vagrant ansible run, and use just an script that run ansible local ?

Alvaro

On Wed, Apr 26, 2017 at 2:55 PM, WowSuchMagic <florian....@gmail.com> wrote:
We are using the Ansible Local provisioner to install the required software on our development Vagrant box. However, we want to use third party roles. The easiest solution to install those roles is using an ansible-galaxy requirements file: http://docs.ansible.com/ansible/galaxy.html#installing-multiple-roles-from-a-file

How can we execute ansible-galaxy before the playbook is run by Ansible Local? Is there a feature for this already that I have missed? You can't run ansible-galaxy as a task inside the playbook, because apparently the roles that a playbook requires are checked before its execution and if a role is not available the playbook is not run at all.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/30a1a62c-27b4-4ff4-bf1b-af60b22742f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

WowSuchMagic

unread,
Apr 26, 2017, 10:52:16 AM4/26/17
to Vagrant
That is pretty much how we used to do it before the Ansible Local provider became available. We used a shell script which first installed the ansible-galaxy roles and then ran the Ansible playbook. We just thought that upgrading to the Ansible Local provider would clean up our provisioning scripts.

So am I right that there is no built-in functionality for running ansible-galaxy before running the playbook? Seems like a pretty essential feature is missing...


Hello

Perhaps you can avoid the vagrant ansible run, and use just an script that run ansible local ?

Alvaro
On Wed, Apr 26, 2017 at 2:55 PM, WowSuchMagic <florian....@gmail.com> wrote:
We are using the Ansible Local provisioner to install the required software on our development Vagrant box. However, we want to use third party roles. The easiest solution to install those roles is using an ansible-galaxy requirements file: http://docs.ansible.com/ansible/galaxy.html#installing-multiple-roles-from-a-file

How can we execute ansible-galaxy before the playbook is run by Ansible Local? Is there a feature for this already that I have missed? You can't run ansible-galaxy as a task inside the playbook, because apparently the roles that a playbook requires are checked before its execution and if a role is not available the playbook is not run at all.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Apr 27, 2017, 5:41:49 AM4/27/17
to vagra...@googlegroups.com
in Chef, when people want to use chef server, same for puppet of any service like spacewalk for authenticated os updated, a bootstraping is required.

Did you try the galaxy commands available? it seems per the documentation that will run before the actual playbook:

example i found







documentation

  • galaxy_command (template string) - The command pattern used to install Galaxy roles when galaxy_role_file is set.

    The following (optional) placeholders can be used in this command pattern:

    • %{role_file} is replaced by the absolute path to the galaxy_role_file option
    • %{roles_path} is
      • replaced by the absolute path to the galaxy_roles_path option when such option is defined, or
      • replaced by the absolute path to a roles subdirectory sitting in the playbook parent directory.

    By default, this option is set to

    ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force

  • galaxy_role_file (string) - The path to the Ansible Galaxy role file.

    By default, this option is set to nil and Galaxy support is then disabled.

    Note: if an absolute path is given, the ansible_local provisioner will assume that it corresponds to the exact location on the guest system.

  • galaxy_roles_path (string) - The path to the directory where Ansible Galaxy roles must be installed

    By default, this option is set to nil, which means that the Galaxy roles will be installed in a roles subdirectory located in the parent directory of the playbook file.


To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/ae9e41de-7db8-4fdf-82a0-96d7db8e2d3f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

WowSuchMagic

unread,
May 6, 2017, 5:23:47 AM5/6/17
to Vagrant
This was it... some time ago I had already added the galaxy_role_file setting to our Vagrantfile, but it didn't work at that time so I commented it out again. Most likely because we had an outdated version of Vagrant installed. However, when I now tried to improve our Vagrant configuration again, I must have assumed that this option didn't actually exist and that it had only been an experiment of mine, because it is not mentioned in the docs about ansible_local... I didn't notice the link to the common options...

After an update of Vagrant, everything works as expected now!




--
Alvaro

Reply all
Reply to author
Forward
0 new messages