ansible-pull and group_vars

1,082 views
Skip to first unread message

Fred Badel

unread,
Apr 10, 2014, 9:38:36 AM4/10/14
to ansible...@googlegroups.com
Hello,

I am trying to set ansible-pull to provision ec2 instances ... with not much success so far ...

I tried using the ec2.py dynamic inventory:

ansible-pull -C feature/ci -d /home/ec2-user/ansible -i ansible/ec2.py tag_Name_qatest23  -U ssh://git@repo/infra/ansible-play.git local.yml

and I get the following error:
ansible-pull "ERROR: provided hosts list is empty"

When trying a static inventory file with :

[coyote]
127.0.0.1   ansible_connection=local

[eu-west-1:children]
coyote

ansible-pull -C feature/ci -d /home/ec2-user/ansible -i /home/ec2-user/ansible/inventories/QA.yml -U ssh://g...@stash.aws.onlotaris.com/infra/ansible-play.git local.yml

the playbook runs, but group_vars does not seem to be evaluated..

Is this a normal behavior?

Thanks.

Fred

James Tanner

unread,
Apr 10, 2014, 9:34:03 PM4/10/14
to ansible...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/234cae5a-45de-41b1-92fa-d0bfbcf2ff7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Correct me if I am wrong, but it seems like you are trying manage other ec2 hosts with ansible-pull?

ansible-pull is designed to only run plays against the current host and in fact limits the inventory to localhost/127.0.0.1.

If your intent is to execute playbooks when a git repo changes or from a git repo, you will need to combine git and ansible-playbook into a custom script.

#!/usr/bin/psuedo-code
cd $checkout
git pull --rebase
ansible-playbook -i inventory site.yml

You could also create a simple wrapper play ..

- hosts: localhost
  gather_facts: False
  tasks:
     - git:
       register: git_check <opts>
     - shell: ansible-playbook <opts>
       when: git_check.changed

Frédéric Badel

unread,
Apr 11, 2014, 4:41:14 AM4/11/14
to ansible...@googlegroups.com
On Apr 11, 2014, at 03:34 , James Tanner <tann...@gmail.com> wrote:

On 04/10/2014 09:38 AM, Fred Badel wrote:
Hello,

I am trying to set ansible-pull to provision ec2 instances ... with not much success so far ...

I tried using the ec2.py dynamic inventory:

ansible-pull -C feature/ci -d /home/ec2-user/ansible -i ansible/ec2.py tag_Name_qatest23  -U ssh://git@repo/infra/ansible-play.git local.yml

and I get the following error:
ansible-pull "ERROR: provided hosts list is empty"

When trying a static inventory file with :

[coyote]
127.0.0.1   ansible_connection=local

[eu-west-1:children]
coyote



Correct me if I am wrong, but it seems like you are trying manage other ec2 hosts with ansible-pull?

ansible-pull is designed to only run plays against the current host and in fact limits the inventory to localhost/127.0.0.1.

If your intent is to execute playbooks when a git repo changes or from a git repo, you will need to combine git and ansible-playbook into a custom script.

#!/usr/bin/psuedo-code
cd $checkout
git pull --rebase
ansible-playbook -i inventory site.yml

You could also create a simple wrapper play ..

- hosts: localhost
  gather_facts: False
  tasks:
     - git:
       register: git_check <opts>
     - shell: ansible-playbook <opts>
       when: git_check.changed

Hi James,

I am running the plays against the host running ansible-pull. But I was expecting ansible to be able to evaluate the group membership of localhost and load the proper group_vars files.

Thanks,

Fred

Jean-Sebastien Mouret

unread,
Apr 14, 2014, 6:02:25 AM4/14/14
to ansible...@googlegroups.com

This used to work fine but not anymore since a week or so.

Frédéric Badel

unread,
Apr 14, 2014, 10:40:28 AM4/14/14
to ansible...@googlegroups.com
Hi Jean-Sebastien,

Really? can you confirm that you’ve been using ansible-pull having the group_vars successfully evaluated?

How come is this not working anymore? is it an issue that no one raised so far ? or is it a documented new behavior?

Cheers,

Fred

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Jean-Sebastien Mouret

unread,
Apr 14, 2014, 11:26:44 AM4/14/14
to ansible...@googlegroups.com

Don't know if it is a documented behavior.
I was generating /etc/ansible/hosts with localhost belonging to a specific group.
Then ansible-pull from a repository with the corresponding group_vars/group defined.
It used to work fine and broke last week.
I'm using the ansible package from ubuntu trusty.

I have switched to git clone + ansible-playbook in the meantime.

Michael DeHaan

unread,
Apr 15, 2014, 5:07:12 PM4/15/14
to ansible...@googlegroups.com
FYI -- There's currently a ticket open on this one.



Rob Johnston

unread,
May 27, 2014, 6:59:31 PM5/27/14
to ansible...@googlegroups.com
Hi Michael

Could you please provide a link to the ticket for us future people?

This is the closest I found at around the right age, with my limited understanding of the problem: https://github.com/ansible/ansible/issues/6563
Reply all
Reply to author
Forward
0 new messages