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

pass hosts to ansible module

Open marcheschi opened this issue 8 years ago • 7 comments

Hi,
I'm trying to pass ansible hosts file to job execution, i tried module execution or playbook but I get always:

No config file found; using defaults

15:18:54 |   |   | [WARNING]: Host file not found: /etc/ansible/hosts 15:18:54 |   |   | [WARNING]: provided hosts list is empty, only localhost is available 15:18:54 |   |   | [WARNING]: No hosts matched, nothing to do

in the project I can import correctly the nodes , actually I have only one node to make it simpler and it shows up, and also on job creation. Is there an example tutorial where I can find more information on how to pass hosts file to playbook or to module ? Thank you Paolo

marcheschi avatar Jul 21 '17 13:07 marcheschi

I forgot to say that also added an Ansible Resource Model Source with the path to the hosts file

marcheschi avatar Jul 21 '17 13:07 marcheschi

Have you tried executing a playbook/module as rundeck user? Does the su rundeck -s /bin/bash -c "ansible all -m ping" actually finds the hosts file and pings the host node?

Try also to disable "Gather Facts" option from Ansible Resource Model Source.

ioannisas avatar Jul 30 '17 19:07 ioannisas

When running a job or a command, the plugin does not take into account the inventory file specified in the resources model source. It takes in that order the inventory file specified in:

  1. The job configuration (no idea how this is set unfortunately as normal options are not passed)
  2. The node configuration
  3. The project configuration
  4. The framework configuration

I fixed a similar issue by adding project.ansible-inventory=/path/to/hosts to my project configuration. Unfortunately, I don't konw how to specify the host file at the job level yet.

bartdag avatar Aug 05 '17 10:08 bartdag

I ran into the same issue. Isn't it confusing to specify a hosts file/inventory in the resource model source, which is NOT used when actually using ansible? It would make sense to use the inventory specified consistently with every ansible action in the project.

FritsHoogland avatar Aug 08 '17 08:08 FritsHoogland

Yes, I noticed this too and took a quick look a while ago. The imported nodes need a reference to the resource model, which created them (as there can be multiple per project), so they can get the settings. Haven't found a reference in Rundeck yet, so maybe we'd need to save the ref on node import, if possible.

frozenice avatar Aug 08 '17 08:08 frozenice

@marcheschi @FritsHoogland Can you check this with the latest version please?

mcassaniti avatar Mar 06 '18 22:03 mcassaniti

I'm using 2.5.0 and it still has the same behaviour.

Nani-o avatar Feb 07 '19 09:02 Nani-o