Hello,
I’m searching for a cluster in vmware with module vmware_cluster_facts.
Filter is corrent, but when I register a value:
`
- hosts: 127.0.0.1
tasks: - name: Load variables
include_vars:
file: vars/vcenter.yaml
name: vcenter - name: Get information about cluster
vmware_cluster_facts:
datacenter: ‘DC1’
hostname: vcenter.example.com
username: ‘{{ vcenter.user }}’
password: ‘{{ vcenter.password }}’
validate_certs: no
register: cluster_facts.skipped - name: “Display all cluster names”
debug: var=item
with_items: “{{ cluster_facts.clusters }}”
when: item == “CLUSTER1”
register: cluster_name - name: Print cluster name
shell: |
echo “{{ cluster_name }}” >> out.txt
`
I see this in out put:
{‘msg’: u’All items completed’, ‘changed’: False, ‘results’: [{‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER3’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER3’}, {‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER2’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER2’}, {‘changed’: False, ‘_ansible_no_log’: False, ‘failed’: False, ‘_ansible_item_result’: True, u’item’: u’CLUSTER1’, ‘_ansible_verbose_always’: True, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER1’}, {‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER10’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER10’}, {‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER4’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER4’}, {‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER8’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER8’}, {‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER5’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER5’}, {‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER9’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER9’}, {‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER6’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER6’}, {‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER7’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER7’}, {‘skipped’: True, ‘_ansible_no_log’: False, ‘skip_reason’: u’Conditional result was False’, ‘_ansible_item_result’: True, ‘item’: u’CLUSTER11’, ‘changed’: False, ‘_ansible_ignore_errors’: None, ‘_ansible_item_label’: u’CLUSTER11’}]}
Is there a way to output only CLUSTER1 to out.txt?
Thanks