# register only matched value by filter.

**URL:** <https://forum.ansible.com/t/register-only-matched-value-by-filter/28048>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [July 15, 2018, 6:43am UTC](https://forum.ansible.com/t/register-only-matched-value-by-filter/28048 "2018-07-15T06:43:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Konstantin\_R](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@Konstantin\_R](https://forum.ansible.com/u/Konstantin_R)\
**Post date:** [July 15, 2018, 6:43am UTC](https://forum.ansible.com/t/register-only-matched-value-by-filter/28048/1 "2018-07-15T06:43:23Z")

</div>

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](http://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
