users.yml 872 B

12345678910111213141516171819202122232425262728293031
  1. ---
  2. - name: users | Create users
  3. user:
  4. force=yes
  5. append=True
  6. args: "{{ item }}"
  7. with_items: cuser.users_db | default([])
  8. when: cuser.users_db is defined
  9. - name: users | Manage public key for users
  10. authorized_key:
  11. user="{{ item.0.user | default(item.0.name) }}"
  12. manage_dir="yes"
  13. args: "{{ item.1 }}"
  14. with_subelements:
  15. - cuser.key_db | default([])
  16. - keys
  17. register: keyrc
  18. failed_when: "'failed' in keyrc and 'getpwnam' not in keyrc.msg"
  19. when: cuser.key_db is defined
  20. - name: users | Manage private key for users
  21. copy:
  22. content="{{ item.privkey }}"
  23. dest="{{ item.home | default(usermanage_default_home_dir_prefix + "/" + item.user ) }}/{{ usermanage_priv_key_suffix}}"
  24. mode=0600
  25. owner="{{ item.user }}"
  26. with_items: usermanage_users_privkey
  27. when: usermanage_users_privkey is defined
  28. # no_log: True