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?

-- 
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/14f38cc2-9ab7-4a5f-bd74-23f529ae1290%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to