rundeck-plugins / ansible-plugin

Ansible Integration for Rundeck
MIT License
331 stars 100 forks source link

pass hosts to ansible module #124

Open marcheschi opened 7 years ago

marcheschi commented 7 years ago

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 commented 7 years ago

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

ioannisas commented 7 years ago

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.

bartdag commented 7 years ago

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.

FritsHoogland commented 7 years ago

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.

frozenice commented 7 years ago

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.

mcassaniti commented 6 years ago

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

Nani-o commented 5 years ago

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