Change the available role_path parameter with strollers

I have a bunch of indecisive galaxy roles and many custom roles.

The problem is that I cannot simultaneously load my own roles and the roles of galaxies using the Vagrantfile :ansible .

Without tramps, this command works well when I added the ANSIBLE_ROLES_PATH environment ANSIBLE_ROLES_PATH :

  ANSIBLE_ROLES_PATH=./custom_roles ansible-playbook project.yml --inventory dev.ini -vvvv --ask-sudo-pass 

My Vagrant configuration is as follows:

 config.vm.provision :ansible do |ansible| ansible.raw_arguments = ['--timeout=300'] ansible.playbook = "project.yml" ansible.verbose = "vvv" ansible.groups = { "env-dev:children" => ["app-web", "app-db"], "app-web" => ["my-app"], "app-db" => ["my-app"], } end 

I see that autoload supporting roles are inside ./roles , but I cannot add my own roles to this directory due to version control ( ./roles is in my .gitignore )

Here is the directory structure to better understand what is going on:

  - roles/ - postgresql/... - php/... - custom_roles/ - my-role-1/... - my-role-1/... - .gitignore <- ignore ./roles - project.yml - roles.yml - dev.ini - Vagrantfile 
+7
vagrant ansible
source share
1 answer

So, I had the same problem, and found a workaround by setting the environment variable ANSIBLE_ROLES_PATH .

In Vagrantfile :

 Vagrant.configure('2') do |config| vagrant_root = File.dirname(__FILE__) ENV['ANSIBLE_ROLES_PATH'] = "#{vagrant_root}/infrastructure/provisioning/ansible/roles:#{vagrant_root}/infrastructure/provisioning/ansible/galaxy-roles" # ansible provisioning config.vm.provision :ansible do |ansible| ansible.playbook = 'infrastructure/provisioning/ansible/playbook.yml' ansible.galaxy_role_file = 'infrastructure/provisioning/ansible/dependencies.yml' ansible.galaxy_roles_path = 'infrastructure/provisioning/ansible/galaxy-roles' end end 
+9
source share

All Articles