# accessing localhost with dynamic hosts for limited tasks

**URL:** <https://forum.ansible.com/t/accessing-localhost-with-dynamic-hosts-for-limited-tasks/20877>\
**Category:** Ansible Project\
**Created:** [March 15, 2016, 9:38pm UTC](https://forum.ansible.com/t/accessing-localhost-with-dynamic-hosts-for-limited-tasks/20877 "2016-03-15T21:38:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Boland](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@Daniel\_Boland](https://forum.ansible.com/u/Daniel_Boland)\
**Post date:** [March 15, 2016, 9:38pm UTC](https://forum.ansible.com/t/accessing-localhost-with-dynamic-hosts-for-limited-tasks/20877/1 "2016-03-15T21:38:55Z")

</div>

I’m trying to access localhost when i specify other remote hosts (using ec2 dynamic inventory but not sure if that matters).

But i get this:

PLAY \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

skipping: no hosts matched

Trying to figure out if its an access thing or if there is a way to inject the localhost just for the role i need it.

I dont want to add localhost to the the inventory list since i dont want to deploy any code there.

Odd thing is, this works fine from my local computer. Its just an issue on the remote server that i need to run this on.

My computer is OS X and remote is linux. But ansible was installed using pip on both so shouldn’t be any set up differences

Is there a way to make ansible-playbook work on the localhost even if its not in the inventory or can i specify it and ignore it in the other tasks?

Below is the command and the playbook i am using

Thanks  
Daniel

Command:

ansible-playbook -i inventory/dev/ -l ~tag\_role\_web full-deploy.yml

Playbook:

- name: Get latest Code

gather\_facts: no

hosts: localhost

vars:

next\_color\_name: “{{ lookup(‘file’, ‘./src/nextArchive’) }}”

update\_archive: “{{ next\_color\_name }}-web”

roles:

- role: update-code

- name: Deploy web code

hosts: all

vars:

latest\_archive: “{{ lookup(‘file’, ‘./src/nextArchive’) }}”

roles:

- role: deploy-web

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 18, 2016, 2:35am UTC](https://forum.ansible.com/t/accessing-localhost-with-dynamic-hosts-for-limited-tasks/20877/2 "2016-03-18T02:35:54Z")

</div>

remove the -l from your command line, since you are not passing a limit.
