ansible-plugin icon indicating copy to clipboard operation
ansible-plugin copied to clipboard

group_vars not loaded

Open camaer opened this issue 6 years ago • 7 comments

Hello,

I'm not sure if this is related to our config but when the playbook is ran manually using ansible-playbook the group_vars are loaded fine but when the same playbook is launched from rundeck they are not loaded properly. Our ansible path is already under /etc/ansible. Should this work ? Is there a way to make it work without a having to copy all the variables in the rundeck job ?

Here's our structure: /etc/ansible/inventories/production/hosts /etc/ansible/inventories/production/group_vars/*

Thanks

camaer avatar May 03 '18 19:05 camaer

I'd suggest making sure you have an ansible.cfg file at /etc/ansible with your inventory details configured. I'd also suggest making sure you use the Ansible base directory path option, setting it to /etc/ansible.

mcassaniti avatar May 06 '18 23:05 mcassaniti

I'd suggest making sure you have an ansible.cfg file at /etc/ansible with your inventory details configured. I'd also suggest making sure you use the Ansible base directory path option, setting it to /etc/ansible.

Thanks for the recommendation. Unfortunately, I have already set everything mentioned in your post correctly to no avail.

camaer avatar May 07 '18 17:05 camaer

I have a similar issue and it seems that rundeck is passing --limit argument to ansible-playbook whats ignore the inventory and group_vars. It is possible to check Ignore limit option in job settings but it doesn't resolve the issue in every case

linlinas avatar Jul 24 '18 13:07 linlinas

@linlinas @camaer Can you run in debug mode and paste the logs? @linlinas Have you also followed the recommendations above about the Ansible base directory path?

mcassaniti avatar Jul 24 '18 22:07 mcassaniti

I think the issue is that group_vars are loaded relative to your inventory. However it seems its not picking up the inventory location in project.ansible-inventory but instead using a file in /tmp. Since the group vars aren't in /tmp/group_vars you don't get inventory

1: Workflow step executing: StepExecutionItem{type='com.batix.rundeck.plugins.AnsiblePlaybookWorkflowStep', keepgoingOnSuccess=false, hasFailureHandler=false}
 procArgs: [ansible-playbook, plays/operations/catalyst/get-catalyst-enabled-companies.yml, --inventory-file=/tmp/ansible-inventory8067836361491163995.json, -vvv, --vault-password-file=/tmp/ansible-runner1499314992005221382vault, -vvvvvv]

jhawkesworth avatar Oct 07 '18 03:10 jhawkesworth

Well whatever is going on, the above is not the full story, as I rsync'ed my group_vars into /tmp but it still fails in the same way.

Is there a way to make it use my actual (ini format) inventory, rather than generating a json inventory?

jhawkesworth avatar Oct 07 '18 04:10 jhawkesworth

Well to answer my own question, there is... Since ansible allows multiple sources of inventory, you can just add -i /path/to/your/actual/inventory and magically your group_vars are loaded.

jhawkesworth avatar Oct 07 '18 04:10 jhawkesworth