accessing localhost with dynamic hosts for limited tasks

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

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