I have a role that I need to use for more values. For each task within the 
role I register a variable: checkdeps (it's the same for all tasks within 
this role - during a run it always has at least one value/output - I need 
it like this because the path differs "/opt/play/apps/default-ace", 
"default-device" etc.) and in the end I do an echo to view the output of 
checkdeps.stdout. 

Below I've put one task that will output ok and one that will intentionally 
will be skipped. If I use the parameter dep: APK_PARSER in the playbook 
what it does is: first checkdeps registers the output and in the second 
task the value of checkdeps is replaced with nothing! Even though the task 
is skipped due to no matching dep parameter. 

Why does the value of checkdeps is replaced if the condition is not met ?

- name: "output ok"
  shell: "cd /opt/play/apps/default-ace && play deps {{ dep }}"
  register: checkdeps
  when: "dep == \"APK_PARSER\""

- name: "example to skip"
  shell: "cd /opt/play/apps/default-device && play deps {{ dep }}"
  register: checkdeps
  when: "dep == \"I\" or dep == \"II\""

- name: "echo ok if Done!"
  shell: "echo \"OK - {{ dep }} Dependencies {{ checkdeps.stdout }}\""

And it gives me error: 

One or more undefined variables: 'dict' object has no attribute 'stdout'

I've modified the last line without the stdout:

shell: "echo \"OK - {{ dep }} Dependencies {{ checkdeps }}\""

and it gives the output:

stdout:
OK - APK_PARSER Dependencies {u'skipped': True, u'changed': False}

did the variable checkdeps register the "skipping: [...]" ? Why it is 
changing it's value if the condition is not met ?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2c5e1ae5-c6bc-45c0-b442-6050c37fd997%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to