# Command to test and debug ansible-pull code locally

**URL:** <https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750>\
**Category:** Get Help\
**Tags:** playbook\
**Created:** [August 8, 2024, 9:36pm UTC](https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750 "2024-08-08T21:36:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhalano](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mhalano/32/1815_2.png) [@mhalano](https://forum.ansible.com/u/mhalano)\
**Post date:** [August 8, 2024, 9:36pm UTC](https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750/1 "2024-08-08T21:36:03Z")

</div>

I’m writing a playbook to configure my personal machine and I want to use ansible-pull to do that.  
What I need is a command to test my playbook without committing the changes, push and then run ansible-pull. I need something more straightforward, like something that will test the code locally quicker. I came up with this little line, but I don’t know if it’s a good representation of what happens when I invoke ansible-pull locally.

```sh
#!/bin/bash
ansible-playbook local.yml -i "localhost,"

```

It seems simple, but I’m afraid maybe I’m not seeing something and this code could have catches and doesn’t run equal to ansible-pull.

---

<div class="post-metadata">

**Author:** ![markuman](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@markuman](https://forum.ansible.com/u/markuman)\
**Post date:** [August 9, 2024, 8:23am UTC](https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750/2 "2024-08-09T08:23:59Z")

</div>

Depends on what you’re doing, maybe you can run your ansible-pull command inside a container (podman, docker…).

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [August 9, 2024, 1:56pm UTC](https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750/3 "2024-08-09T13:56:41Z")

</div>

This will test what ansible-pull does after it ‘preps’ things. If using a git repo to serve the playbook, you would also need a git action that checkout/updates the repo locally before execution.

---

<div class="post-metadata">

**Author:** ![mhalano](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mhalano/32/1815_2.png) [@mhalano](https://forum.ansible.com/u/mhalano)\
**Post date:** [August 9, 2024, 7:07pm UTC](https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750/4 "2024-08-09T19:07:47Z")

</div>

@bcoca Thanks for the tip, but I just need to test the code itself during development. Do you see any caveats in my code (besides the one you previously mentioned)?

---

<div class="post-metadata">

**Author:** ![mhalano](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mhalano/32/1815_2.png) [@mhalano](https://forum.ansible.com/u/mhalano)\
**Post date:** [August 9, 2024, 7:43pm UTC](https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750/5 "2024-08-09T19:43:03Z")

</div>

BTW, I added a `-c local` so it will always run locally, since the goal is debug. I found that analyzing the `pull.py` source file. Underneath it seems to execute an `ansible-playbook` command with quite opinionated options.

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [August 9, 2024, 7:46pm UTC](https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750/6 "2024-08-09T19:46:08Z")

</div>

That should be enough

---

<div class="post-metadata">

**Author:** ![mhalano](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mhalano/32/1815_2.png) [@mhalano](https://forum.ansible.com/u/mhalano)\
**Post date:** [August 9, 2024, 7:49pm UTC](https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750/7 "2024-08-09T19:49:03Z")

</div>

Thanks @bcoca. One last question: what is the function of `--limit` option in this scenario? For me, it’s configured to `localhost,glados,127.0.0.1` (`glados` is my machine’s name). I wonder why it’s necessary to set the limit even setting --inventory as `localhost,`.

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [August 9, 2024, 8:36pm UTC](https://forum.ansible.com/t/command-to-test-and-debug-ansible-pull-code-locally/7750/8 "2024-08-09T20:36:41Z")

</div>

IIRC because you can pass alternate inventories to ansible-pull
