# Setting Ansible pull for the first time.

**URL:** <https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881>\
**Category:** Ansible Project\
**Tags:** ansible-project, ubuntu\
**Created:** [September 11, 2012, 12:30pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881 "2012-09-11T12:30:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 11, 2012, 12:30pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/1 "2012-09-11T12:30:38Z")

</div>

> ( is a bit  
> confusing to need to run a playbook that will install ansible and install  
> the cron for you and the doc doesn't really say that you need the playbook  
> to be local.yml and that you need to run it with --conection=local for the  
> initial setup and then you don't need anymore that playbook and some other  
> details).

Which file are you referring to, the online docs or the example playbook file?

> Anyhow the question that I have is that I get this error every time that I  
> update the local.yml in the git repo :
> 
> Sep 11 06:21:09 ubuntu-oneiric ansible-apt: Invoked with pkg=nginx  
> state=removed  
> cmd=ansible all -c local -m git -a  
> "repo=git://github.com/jamengual/ansible-vagrant.git  
> dest=/var/lib/ansible/local version=HEAD"  
> localhost | FAILED \>\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"failed": true,  
> &nbsp;&nbsp;&nbsp;&nbsp;"msg": "fatal: destination path '/var/lib/ansible/local' already exists  
> and is not an empty directory.\n"  
> }

What version of ansible are you using? I do not see this string  
"(already exists and)" in 0.8 or the latest 0.7.

---

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [September 11, 2012, 7:04pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/2 "2012-09-11T19:04:57Z")

</div>

> > ( is a bit  
> > confusing to need to run a playbook that will install ansible and install  
> > the cron for you and the doc doesn’t really say that you need the playbook  
> > to be local.yml and that you need to run it with --conection=local for the  
> > initial setup and then you don’t need anymore that playbook and some other  
> > details).
> 
> Which file are you referring to, the online docs or the example playbook file?

The online docs do not say anything about that.

> > Anyhow the question that I have is that I get this error every time that I  
> > update the local.yml in the git repo :
> > 
> > Sep 11 06:21:09 ubuntu-oneiric ansible-apt: Invoked with pkg=nginx  
> > state=removed  
> > cmd=ansible all -c local -m git -a  
> > “repo=git://[github.com/jamengual/ansible-vagrant.git](http://github.com/jamengual/ansible-vagrant.git)  
> > dest=/var/lib/ansible/local version=HEAD”  
> > localhost | FAILED \>\> {  
> > “failed”: true,  
> > “msg”: “fatal: destination path ‘/var/lib/ansible/local’ already exists  
> > and is not an empty directory.\n”  
> > }
> 
> What version of ansible are you using? I do not see this string  
> “(already exists and)” in 0.8 or the latest 0.7.

Good question, :  
vagrant@ubuntu-oneiric:~$ ansible --version  
ansible 0.7

vagrant@ubuntu-oneiric:~$ ansible-playbook --version  
ansible-playbook 0.7

But there is no such option on ansible-pull command.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 11, 2012, 7:48pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/3 "2012-09-11T19:48:57Z")

</div>

Ah, this error message is coming from the git binary.

Looks like we have some fixing to do with the git module to make it  
run repeatably, please make sure there is a bug filed on github.

It's not specific to ansible-pull, just the git module. Maybe it's  
not forcing by default or isn't updating and is trying to clone. Need  
to look.

Though others should be using the git module, which makes me a bit curious.

---

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [September 11, 2012, 8:26pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/4 "2012-09-11T20:26:17Z")

</div>

So I guess that I shout not worry about it.

No I have some other questions :

I’m using the apt module and I see in the docs this :

```auto
apt pkg=foo update-cache=yes
apt pkg=foo state=removed
apt pkg=foo state=installed
apt pkg=foo=1.00 state=installed
apt pkg=nginx state=latest default-release=squeeze-backports update-cache=yes
apt pkg=openjdk-6-jdk state=latest install-recommends=no

```

But above of those examples it says :

> state | no | present | ‘absent’, ‘present’, or ‘latest’.  
> |
> 
> - | - | - | - |

so I should asume that the apt module has the states : absent, present, latest, removed, installed ?

I try with adding nginx and then remove it and it installed this :

sudo dpkg -l|grep nginx  
ii nginx 1.1.19-1 small, but very powerful and efficient web server and mail proxy  
ii nginx-common 1.1.19-1 small, but very powerful and efficient web server (common files)  
ii nginx-full

But when I used the removed it just removed the nginx package so I guess that I need another option to remove all toghether ?

and with the absent option that package was marked as “to be removed” so it didn’t actually remove it.

Sorry, this could more a question for “Apt 101” but I don’t know if it’s related to the apt module.

Thanks Again.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 11, 2012, 10:16pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/5 "2012-09-11T22:16:30Z")

</div>

Bug filed to track this:

[https://github.com/ansible/ansible/issues/1034](https://github.com/ansible/ansible/issues/1034)

If someone wants to beat me to it, that would be awesome 🙂

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 11, 2012, 10:19pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/6 "2012-09-11T22:19:54Z")

</div>

> I'm using the apt module and I see in the docs this :
> 
> apt pkg=foo update-cache=yes  
> apt pkg=foo state=removed  
> apt pkg=foo state=installed  
> apt pkg=foo=1.00 state=installed  
> apt pkg=nginx state=latest default-release=squeeze-backports update-cache=yes  
> apt pkg=openjdk-6-jdk state=latest install-recommends=no
> 
> But above of those examples it says :
> 
> statenopresent‘absent’, ‘present’, or ‘latest’.  
> so I should asume that the apt module has the states : absent, present,  
> latest, removed, installed ?

Yes.

'absent' is the same as 'removed', 'present' is the same as  
'installed'

> I try with adding nginx and then remove it and it installed this :
> 
> sudo dpkg -l|grep nginx  
> ii nginx 1.1.19-1 small, but  
> very powerful and efficient web server and mail proxy  
> ii nginx-common 1.1.19-1 small, but  
> very powerful and efficient web server (common files)  
> ii nginx-full
> 
> But when I used the removed it just removed the nginx package so I guess  
> that I need another option to remove all toghether ?

IMHO, this is really the way it should work, because you never know if  
a user has come to rely on a package that was installed as a  
dependency. So you should then specify that all three packages are  
removed.

Most of the time, with config management systems, you are not  
specifying removal, though since Ansible has uses as an add hoc tool,  
it can be useful.

"with\_items" in a playbook is helpful for this, or if running from /  
usr/bin/ansible, you can just do this:

ansible groupname -m apt -a "name=nginx,nginx-common,nginx-full  
state=removed"

And it will do it all in one hop.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 11, 2012, 10:21pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/7 "2012-09-11T22:21:58Z")

</div>

Actually this sounds like the deps on the package are kind of weird.

Someone with apt-foo please check it out and make sure we're not doing  
something wrong, please 🙂

Disclaimer: I am mostly a CentOS guy lately.

---

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [September 11, 2012, 10:43pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/8 "2012-09-11T22:43:51Z")

</div>

Thanks for that too!!! maybe should be added to the doc for clarification ?

And for the propert steps of setting the pull nodes this is what I understand :

1.- setup git repo with local.yml playbook with the needed tasks  
2.- install ansible in the node  
3.- download and modify ansible\_pull.yml ( change repo url and maybe sudo: True etc).  
4.- Run ansible-playbook using\_the\_example\_modified\_paybook.yml

and that will be all ?

Thanks.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 11, 2012, 10:50pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/9 "2012-09-11T22:50:48Z")

</div>

You've got it.

You can do step 2 with ansible if you want 🙂

---

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [September 11, 2012, 11:24pm UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/10 "2012-09-11T23:24:41Z")

</div>

Wait, how do I install ansible with ansible ? you got me confused…

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [September 12, 2012, 1:53am UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/11 "2012-09-12T01:53:59Z")

</div>

Use the yum or apt resource with the proper repos configured.

---

<div class="post-metadata">

**Author:** ![PePe\_Amengual](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PePe\_Amengual](https://forum.ansible.com/u/PePe_Amengual)\
**Post date:** [September 12, 2012, 2:19am UTC](https://forum.ansible.com/t/setting-ansible-pull-for-the-first-time/11881/12 "2012-09-12T02:19:49Z")

</div>

Ohh ok, that is what I did, I just used the repos from the docs.

Thanks a lot for the help.
