Last active
February 5, 2019 14:46
-
-
Save mz0/4462cb7bdae37881a21660c5703a0fd2 to your computer and use it in GitHub Desktop.
-- Icanhaz mai var, Ansible? -- Not after 2.8 of me!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Return task result in a variable named in 'ret' | |
debug: msg="My first argument is {{ arg1 | default("undefined!") }}" | |
register: "{{ ret }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: localhost | |
gather_facts: no | |
vars: | |
var_a: "dynamic include AAA" | |
var_b: "dynamic include_tasks BBB" | |
var_c: "static import_tasks CCC" | |
tasks: | |
- name: Check ret0 before task include. | |
debug: msg="ret0 is {{ ret0 | default("undefined!") }}" | |
- name: You wouldn't see this 'name' in output ( | |
include: inc1.yml | |
vars: | |
arg1: "{{ var_a }}" | |
ret: ret0 | |
- name: Check returned var | |
debug: msg="ret0 is {{ ret0 | default("undefined!") }}" | |
- name: Run inc1.yml with 'include_tasks'. | |
include_tasks: inc1.yml | |
vars: | |
arg1: "{{ var_b }}" | |
ret: ret0 | |
- name: Check returned var | |
debug: msg="ret0 is {{ ret0 | default("undefined!") }}" | |
- name: Neither would you see this 'name'! | |
import_tasks: inc1.yml | |
vars: | |
arg1: "{{ var_c }}" | |
ret: ret0 | |
- name: Check returned var | |
debug: msg="ret0 is {{ ret0 | default("undefined!") }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is my version of a wonderful answer given 2017-05-23 18:43:28Z to a question "How can Ansible 'register' in a variable the result of included playbook?"
Works OK in Ansible 2.7.6 but not in 2.8.0dev0.