accessing localhost with dynamic hosts for limited tasks

26 views
Skip to first unread message

Daniel Boland

unread,
Mar 17, 2016, 8:10:19 AM3/17/16
to Ansible Project
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







Brian Coca

unread,
Mar 17, 2016, 10:36:00 PM3/17/16
to ansible...@googlegroups.com
remove the -l from your command line, since you are not passing a limit.


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages