I am trying to use ansible to check to see if there are any aerospike migrations happening, and then run a task when migrations reach 0. To do that, I am using the ansible shell module to output the total number of migrations to stdout, register that output with ansible, and have ansible test on it.
Ansible seems to be recording the output correctly, but it is constantly displaying the stdout as "Hello World"
Here is my test playbook:
---
- hosts:
- foo
- bar
serial: 1
gather_facts: no
tasks:
- name: check for migrates
shell: "echo 10"
register: as_migrates
- debug: var=as_migrates
- debug: msg = "{{ as_migrates.stdout }}"
- debug: msg = "{{ as_migrates.stdout_lines }}"
- debug: msg = "{{ as_migrates }}"
Here is the output:
PLAY [foo;bar] ******************************************************
TASK: [check for migrates] ****************************************************
changed: [foo-10]
TASK: [debug var=as_migrates] *************************************************
ok: [foo-10] => {
"var": {
"as_migrates": {
"changed": true,
"cmd": "echo 10",
"delta": "0:00:00.001367",
"end": "2016-01-26 23:19:20.586245",
"invocation": {
"module_args": "echo 10",
"module_complex_args": {},
"module_name": "shell"
},
"rc": 0,
"start": "2016-01-26 23:19:20.584878",
"stderr": "",
"stdout": "10",
"stdout_lines": [
"10"
],
"warnings": []
}
}
}
TASK: [debug msg = "{{ as_migrates.stdout }}"] ********************************
ok: [foo-10] => {
"msg": "Hello world!"
}
TASK: [debug msg = "{{ as_migrates.stdout_lines }}"] **************************
ok: [foo-10] => {
"msg": "Hello world!"
}
TASK: [debug msg = "{{ as_migrates }}"] ***************************************
ok: [foo-10] => {
"msg": "Hello world!"
}
My question is: Why is does the debug var clearly show the correct stdout and the as_migrats.stdout display "Hello World"?? I know that "Hello World" is the default message for the message module. So is the register not persisting from one task to another?? I feel like I am missing something obvious. I don't have another variable named "as_migrates" in my ansible environment.