How do I execute ALL the task in a YML file locally?

33 views
Skip to first unread message

ZillaYT

unread,
Oct 25, 2016, 11:02:49 AM10/25/16
to Ansible Project
I have a role whose main.yml file includes several *.yml files, e.g.,

main.yml
---
- include: tasks1.yml
- include: tasks2.yml


tasks1
.yml
---
- name: Create dir
  file
; path=/tmp/dir1 state=dir

- name: Create file from template
 
template: src=my_script.sh.j2 dest=/tmp/dir1/my_script.sh mode=0755

- name: Execute script
  command
: /tmp/dir1/my_script.sh



I want to execute EVERYTHING in tasks1.yml on my local machine, but tasks2.yml on the target machine. Besides using local_action on all the tasks, what's a more global way to do it?

Patrick Laimbock

unread,
Oct 25, 2016, 11:14:36 AM10/25/16
to ansible...@googlegroups.com
Have you looked at delegate_to ?

http://docs.ansible.com/ansible/playbooks_delegation.html#id10

HTH,
Patrick

ZillaYT

unread,
Oct 25, 2016, 11:23:11 AM10/25/16
to Ansible Project, pat...@laimbock.com
Examples for delegate_to, local_action, etc. all show them being added per task. Though this will definitely accomplish what I want, I just want to do it in a more "file-global" way. Again, per my OP.

Chris
Message has been deleted

ZillaYT

unread,
Oct 25, 2016, 11:44:50 AM10/25/16
to Ansible Project, pat...@laimbock.com
IOW, I want to do all the tasks inside the YML file on my local machine in "one fell swoop."
Reply all
Reply to author
Forward
0 new messages