What parameters are possible for "include"?

29 views
Skip to first unread message

t.hi...@sendandstore.de

unread,
Jan 25, 2016, 8:00:38 AM1/25/16
to Ansible Project
Hello, 
when I want to include another file, which includes a list of tasks, what parameters are possible to pas to the include to have them forwarded to the task? For example, I set "tags" when including something, maybe to reduce some duplication. How can I know which parameters can work and which don't. For example "remote_user", "become", "become_user" etc. Is there a place where there is a synopsis of the include command? Or am I supposed to read the code, which I haven't yet.

Thanks for help ad regards, 
Thomas

t.hi...@sendandstore.de

unread,
Jan 25, 2016, 8:26:55 AM1/25/16
to Ansible Project
To clarify, I am looking for a good general way to reuse tasks in different context (for example with different "ansible_user", different "become_user" ...) without explicitly giving defaults at all times. I understand there is a tradeoff here, but the question is really, what's the best way to find out?

** some_task.yml **
---
- command: echo success
  become
: "{{ become }}"
  become
_user: "{{ become_user }}"


** main.yml **
---
# ...
- include: some-task.yml become=true become_user=username
# ...




Brian Coca

unread,
Jan 25, 2016, 2:28:13 PM1/25/16
to Ansible Project
The inline mode is only for vars, not directives:

- include: some-task.yml
become: "{{ mybecome}}"
become_user: "{{ mybecome_user }}"

Also naming vars the same as directives can lead to confusion.



--
Brian Coca

t.hi...@sendandstore.de

unread,
Jan 26, 2016, 3:55:50 AM1/26/16
to Ansible Project
Thank you! Can you point me to the documentation somewhere, where this is clarified?
Reply all
Reply to author
Forward
0 new messages