Skip to content

Instantly share code, notes, and snippets.

@pedro-r-marques
Created October 17, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedro-r-marques/14639ebbbe514a41f4e0 to your computer and use it in GitHub Desktop.
Save pedro-r-marques/14639ebbbe514a41f4e0 to your computer and use it in GitHub Desktop.
---
- name: inventory, task variables and facts
hosts:
- test
tasks:
- name: example task
command: hostname
register: hostname_var
- name: facts can be determined by output of tasks
set_fact:
flag_task_a: "{{ hostname_var.stdout }}"
when: hostname_var.rc == 0
- debug: var=flag_task_a
- debug: var=flag_task_b
- debug: var=flag_user_a
- debug: var=flag_user_b
- debug: var=flag_user_c
vars:
flag_task_a: "a"
flag_task_b: "b"
flag_user_a: "{{ flag_a | default('a') }} "
flag_user_b: "{{ flag_b | default('b') }} "
flag_user_c: "{{ flag_c | default('c') }} "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment