- name: "set disk_count fact"
set_fact:
disk_count: "{{ disk_count_result.stdout | int }}"
- name: "Do something with disk_count"
shell: "echo {{ disk_count }}"
- name: "Do something with MY_DISK_COUNT exposed as an environment variable to this specific task"
shell: "export | grep COUNT"
environment:
MY_DISK_COUNT: "{{ disk_count }}"
- name: "repeat same command without exposing MY_DISK_COUNT to this specific task"
shell: "export | grep COUNT"
"""
However, as you appear to already know. The question you've posted is *not* what this list is for:
- It's not a bug in Ansible (which should be reported in GitHub as an issue, but might get traction here)
- It's not an attempt to start a discussion about how some future feature might function.
- It's not a question about developing a custom module for Ansible.
- It's not an announcement about a milestone in the Ansible development lifecycle.
This kind of question is best suited for the ansible-project mailing list which "is for sharing Ansible tips, answering questions about playbooks and roles, and general user discussion". But, you should include more than just the output of a single task and its error. I would also strongly recommend spending some time working through some Ansible tutorials. I suspect you've misunderstood some of the underlying fundamentals of how Ansible works, which is only going to lead to further frustration.