# Registering returns to a dictionary attribute

**URL:** <https://forum.ansible.com/t/registering-returns-to-a-dictionary-attribute/17987>\
**Category:** Ansible Project\
**Created:** [April 15, 2015, 9:38pm UTC](https://forum.ansible.com/t/registering-returns-to-a-dictionary-attribute/17987 "2015-04-15T21:38:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Yarusso](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@Tony\_Yarusso](https://forum.ansible.com/u/Tony_Yarusso)\
**Post date:** [April 15, 2015, 9:38pm UTC](https://forum.ansible.com/t/registering-returns-to-a-dictionary-attribute/17987/1 "2015-04-15T21:38:53Z")

</div>

So, I have a dictionary variable containing information about all of my users, like this:  
user\_dictionary:  
bjones:  
realname: Bob Jones  
uniqueid: 1007  
status: active  
notes: Database consultant

Part of my playbook changes users’ UIDs to make sure they’re consistent across all of our systems. After that happens I want to make sure that the correct user owns things like their mail spool. However, not every user HAS a mail spool, and I’d like that to be handled gracefully without spitting out any red failure text on playbook run - just skip the task if no mail spool exists. So, I was thinking I could do something like this:

tasks:

- name: Check if mail spools exist  
stat:  
path: “{{ ‘/var/spool/mail/’ ~ item.key }}”  
register: user\_dictionary[item.key][“mailspool”]  
with\_dict: user\_dictionary
- name: Set ownership and permissions of user mail spools  
file:  
path: “{{ ‘/var/spool/mail/’ ~ item.key }}”  
owner: “{{ item.key | lower }}”  
group: “mail”  
mode: “0660”  
state: file  
with\_dict: user\_dictionary  
when: item.key in getent\_passwd and item.key.mailspool.stat.exists

But, that register statement isn’t working. There are no mailspool attributes in user\_dictionary after running the first task. Anyone know how to register to a dictionary attribute like that?
