# ansible-pull configuration

**URL:** <https://forum.ansible.com/t/ansible-pull-configuration/28287>\
**Category:** Ansible Project\
**Created:** [August 8, 2018, 6:03am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287 "2018-08-08T06:03:45Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [August 8, 2018, 6:03am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/1 "2018-08-08T06:03:45Z")

</div>

Hi All,

I am trying to setup the ansible pull based on my vm server.

Is there any step-wise documentation for this?

Regards  
Sumit Sahay  
7044112109

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [August 8, 2018, 11:00am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/2 "2018-08-08T11:00:15Z")

</div>

Hi,

Ansible in pull mode is basically the same as regular ansible-playbook. The only difference is that you have to supply a repo URL from which the playbook and the roles are to be downloaded. The same directory structure works with both modes.

If you’re using ansible-pull to hydrate (bootstrap) the vm take the following things into consideration:

1. If you’re using git with ssh keys - you have to pre-populate .ssh/known\_hosts with the public ssh key of the git server
2. Generally - there’s not going to be an inventory, so consider using -i $(hostname), (note the colon at the end) and specifying hosts: all in your playbook.

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [August 8, 2018, 11:43am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/3 "2018-08-08T11:43:26Z")

</div>

Hi Pshem,

Thanks for your reply,

Could you please provide me the step wise process for this or any documents on this.

I am trying to get this but getting error like below

ansible-pull -U [https://github.com/sumitsahay-mca/jenkins-ansible](https://github.com/sumitsahay-mca/jenkins-ansible) -k user\_management\_test1.yml  
Starting Ansible Pull at 2018-08-07 06:08:24  
/usr/bin/ansible-pull -U [https://github.com/sumitsahay-mca/jenkins-ansible](https://github.com/sumitsahay-mca/jenkins-ansible) -k user\_management\_test1.yml  
[WARNING]: Could not match supplied host pattern, ignoring: centos  
[WARNING]: Could not match supplied host pattern, ignoring: [centos.techmahindra.com](http://centos.techmahindra.com)  
localhost | FAILED! =\> {  
“changed”: false,  
“msg”: “Failed to find required executable git in paths: /usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/test/bin”  
}

Am I doing anything wrong here, could you please navigate me to the correct direction.

Looking forward for your reply.

Thanks & Regards  
Sumit Sahay

---

<div class="post-metadata">

**Author:** ![balz.aschwanden](https://avatars.discourse-cdn.com/v4/letter/b/50afbb/32.png) [@balz.aschwanden](https://forum.ansible.com/u/balz.aschwanden)\
**Post date:** [August 8, 2018, 5:13pm UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/4 "2018-08-08T17:13:53Z")

</div>

Hi Sumit

We’re using a wrapper around ansible-pull. We use it mainly for clients but we’ve a step-by-step guide you might find helpful:  
[https://github.com/ANTS-Framework/ants](https://github.com/ANTS-Framework/ants)

Regards  
Balz

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [August 14, 2018, 7:07am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/5 "2018-08-14T07:07:40Z")

</div>

Thanks Balz, for your reply.

Could you help me with the command for ansible pull, I installed git and repository and I committed the ansible playbook there now I want to run this from my localhost server following command I am using but getting error,

ansible-pull -U [https://repourl.com/git/user\_name/git\_location](https://repourl.com/git/user_name/git_location) -k -i /home/test/hosts playbook.yml

getting error saying skipping the hosts.

Could you please navigate me to the correct command.

Looking forward for your reply.

Regards  
Sumit Sahay  
7044112109

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [August 14, 2018, 11:47am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/6 "2018-08-14T11:47:01Z")

</div>

what hosts are on your playbook? is it localhost?

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [August 14, 2018, 12:25pm UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/7 "2018-08-14T12:25:52Z")

</div>

Thanks Jonathan, for your reply.

No, I am not using localhost, I want to run my playbook on ubuntu host which I set up in my host file, and the host file is located in /home/test/sumit/

How to run this so that it will pick up the host and execute on ubuntu remote host.

Looking forward for your reply.

Thanks & Regards  
Sumit Sahay  
7044112109

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [August 14, 2018, 2:13pm UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/8 "2018-08-14T14:13:49Z")

</div>

usually ansible-pull its used on localhost and not other hosts. If you are trying to do other host then use regular ansible. Ansible-pull is a different use case.

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [August 14, 2018, 2:54pm UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/9 "2018-08-14T14:54:53Z")

</div>

Thanks for your reply Jonathan.  
localhost : from where we are triggering command.  
This is what you want to say?

Looking forward for your reply.

Regards  
Sumit Sahay  
07044112109

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [August 16, 2018, 10:26am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/10 "2018-08-16T10:26:09Z")

</div>

Hi,

That’s correct, in pull mode ansible modifies and sets things on the machine on which it runs. The easiest way of providing inventory in this case is via command line:

-i $(hostname),

Please note the comma at the end.

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [August 16, 2018, 10:36am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/11 "2018-08-16T10:36:39Z")

</div>

Thanks Pshem for your reply.

ansible-pull -U [git\_url] -k playbook.yml --limit localhost

I am using this command to run the ansible pull, while doing this I am getting one error, unable to resolve the error.

“msg”: “Failed to download remote objects and refs: Host key verification failed.\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n”

Can you please help me out on this

Looking forward for your reply

Thanks & Regards  
Sumit Sahay  
07044112109

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [August 16, 2018, 9:45pm UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/12 "2018-08-16T21:45:16Z")

</div>

There are two things here:

1. If you’re using SSH the public key of the remote server must be added to ‘known\_hosts’, for example like this:

ssh-keyscan -t rsa [github.com](http://github.com) | sed “s/\[1\]\* //” \>\> ~/.ssh/known\_hosts

(alternatively you can get ansible to just accept whatever key is offered with --accept-host-key)

1. Secondly you have to specify the private key associated with the repo with --private-key

kind regards  
Pshem

* * *

1. ^

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [August 21, 2018, 7:09am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/13 "2018-08-21T07:09:24Z")

</div>

Hi Pshem,

Thanks for your reply.  
I am getting following error, and not able to fix the issue,

“msg”: “Failed to download remote objects and refs: Ubuntu 16.04.3 LTS\nPermission denied (publickey,password,keyboard-interactive).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n”

Looking forward for your reply.

Regards  
Sumit Sahay  
7044112109

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [August 29, 2018, 5:29am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/14 "2018-08-29T05:29:48Z")

</div>

Thanks Pshem,

Ansible pull is working for me now, able to run the ansible pull for localhost.

I have one query, I want to run the ansible pull for 100nodes and in that case I am using below command,

ansible-pull -U repo\_url --inventory=hosts -k HelloWorld.yml

But it is not working for multiple nodes for localhost it is working fine.

I want to resolve this issue, could you please help me out on this.

Looking forward for your reply.

Regards  
Sumit Sahay  
7044112109

---

<div class="post-metadata">

**Author:** ![Pshem\_Kowalczyk](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@Pshem\_Kowalczyk](https://forum.ansible.com/u/Pshem_Kowalczyk)\
**Post date:** [August 29, 2018, 5:37am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/15 "2018-08-29T05:37:03Z")

</div>

Hi,

I have never attempted to use ansible in pull mode on anything than the localhost. I have ran the same playbook on multiple nodes at once but they were not ‘in-sync’ - each one of them run tasks independently.

If you need to run something on multiple machines I suggest you ‘nest’ the call to a standalone ansible (using command). If you could share your use-case than perhaps someone can offer a better solution.

kind regards  
Pshem

---

<div class="post-metadata">

**Author:** ![SUMIT\_SAHAY](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SUMIT\_SAHAY](https://forum.ansible.com/u/SUMIT_SAHAY)\
**Post date:** [August 29, 2018, 6:39am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/16 "2018-08-29T06:39:57Z")

</div>

Hi Pshem,

Thanks for your reply,

I managed to run the ansible pull for remote hosts below is the command I used for ansible pull,

ansible-pull -U repo\_url --inventory=hosts -k HelloWorld.yml --limit remote\_server

Thanks Pshem for your support.

Regards  
Sumit Sahay  
7044112109

---

<div class="post-metadata">

**Author:** ![Roman2](https://avatars.discourse-cdn.com/v4/letter/r/e47c2d/32.png) [@Roman2](https://forum.ansible.com/u/Roman2)\
**Post date:** [June 6, 2019, 2:48pm UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/17 "2019-06-06T14:48:03Z")

</div>

Hi SUMIT SAHAY,

kindly share with the way how you set up hosts file in terms of defining remote hosts

---

<div class="post-metadata">

**Author:** ![Arbab\_Nazar1](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@Arbab\_Nazar1](https://forum.ansible.com/u/Arbab_Nazar1)\
**Post date:** [June 7, 2019, 9:09am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/18 "2019-06-07T09:09:36Z")

</div>

That might help you: [https://rbgeek.wordpress.com/2016/05/15/autoscaling-with-aws-instances-using-ansible-pull/](https://rbgeek.wordpress.com/2016/05/15/autoscaling-with-aws-instances-using-ansible-pull/)

---

<div class="post-metadata">

**Author:** ![Roman2](https://avatars.discourse-cdn.com/v4/letter/r/e47c2d/32.png) [@Roman2](https://forum.ansible.com/u/Roman2)\
**Post date:** [June 10, 2019, 8:50am UTC](https://forum.ansible.com/t/ansible-pull-configuration/28287/19 "2019-06-10T08:50:55Z")

</div>

Hello,

actually my purpose is to configure remote client server from control server (both located in AWS cloud) using ansible-pull running on control node. I’m stuck with parsing host file when executing ansible-pull. Here is the command which I’m running:  
ansible-pull -U [git@bitbucket.org](mailto:git@bitbucket.org):my-repository.git -C my\_brunch my\_playbook.yml --inventory-file=~/hosts  
I’d appreciate a lot if someone could give a clue.
