theforeman / foreman_ansible_inventory

Foreman dynamic inventory script for ansible - Now merged into Ansible itself
GNU General Public License v3.0
70 stars 31 forks source link

Can't access my hostGroup in my playbook #48

Closed AlexisLessard closed 7 years ago

AlexisLessard commented 7 years ago

So i've just installed a test installation of foreman. Really basic, nothing fancy. We just wanted to test the ansible plugin to see its viability (so far so good). Now I'm trying out the foreman dynamic inventory. While I can access all my hosts when i write hosts: all in my playbook. However, I can't seem to access a host in a simple group. I've got a host foo in the group ansibleManaged. But I never receive anything whatever I put in the hosts setting. I've tried:

I always receive image

How do I select a simple group? I don't have any environment setup, and I know that I can connect to the foreman server because I can connect to my hosts with the hosts: all setting. Any idea on what I'm doing wrong?

EDIT: I'm using ansible 2.3

AlexisLessard commented 7 years ago

The groups also exists, as I've made a test in postman and got this result image image

agx commented 7 years ago

On Fri, May 12, 2017 at 10:58:52AM -0700, AlexisLessard wrote:

So i've just installed a test installation of foreman. Really basic, nothing fancy. We just wanted to test the ansible plugin to see its viability (so far so good). Now I'm trying out the foreman dynamic inventory. While I can access all my hosts when i write hosts: all in my playbook. However, I can't seem to access a host in a simple group. I've got a host foo in the group ansibleManaged. But I never receive anything whatever I put in the hosts setting. I've tried:

  • foreman_ansibleManaged
  • ansibleManaged
  • foreman_hostgroups_ansibleManaged
  • foreman_hostgroup_ansibleManaged

I always receive image

How do I select a simple group? I don't have any environment setup, and I know that I can connect to the foreman server because I can connect to my hosts with the hosts: all setting. Any idea on what I'm doing wrong?

Check the generated cache file. It has a list of all the available host groups.

AlexisLessard commented 7 years ago

Well, in the cache file, I can certainly see the group name image

However, that's not different from what is shown by the api...wait...let me check the .index file...

image

The name of the group is reduced in minuscules? Ok... let me try that

AlexisLessard commented 7 years ago

Aaaaaaaaand it works! Awesome! Thanks for the tip. Altoug I propose to write this in the README file, please.