Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

65 lignes
1.7KB

  1. ---
  2. - name: user groups
  3. group:
  4. name: "{{ item }}"
  5. gid: "{{ user_groups[item].gid }}"
  6. state: present
  7. with_items: "{{ user_groups.keys() }}"
  8. when: user_groups is defined
  9. - name: users primary group
  10. group:
  11. name: "{{ item }}"
  12. gid: "{{ users[item].gid }}"
  13. state: present
  14. with_items: "{{ users.keys() }}"
  15. when: users[item].gid is defined
  16. - name: user accounts
  17. user:
  18. name: "{{ item }}"
  19. group: "{{ item }}"
  20. groups: "{{ users[item].groups | join(',') }}"
  21. uid: "{{ users[item].uid }}"
  22. home: "{{ users[item].home | default('/home/'+item) }}"
  23. shell: "{{ users[item].shell | default('/bin/bash') }}"
  24. generate_ssh_key: yes
  25. ssh_key_type: ed25519
  26. state: present
  27. with_items: "{{ users.keys() }}"
  28. - name: user passwords
  29. user:
  30. name: "{{ item }}"
  31. password: "{{ users[item].password }}"
  32. with_items: "{{ users.keys() }}"
  33. when: users[item].password is defined
  34. - name: home directory
  35. file:
  36. path: "{{ users[item].home | default('/home/'+item) }}"
  37. owner: "{{ item }}"
  38. group: "{{ item }}"
  39. mode: "{{ users[item].homedir_mode | default(700) }}"
  40. state: directory
  41. with_items: "{{ users.keys() }}"
  42. - name: ssh directory
  43. file:
  44. path: "{{ users[item].home | default('/home/'+item) }}/.ssh"
  45. owner: "{{ item }}"
  46. group: "{{ item }}"
  47. mode: "700"
  48. state: directory
  49. with_items: "{{ users.keys() }}"
  50. - name: ssh authorized keys
  51. copy:
  52. content: "{{ users[item].authorized_keys }}"
  53. dest: "{{ users[item].home | default('/home/'+item) }}/.ssh/authorized_keys"
  54. owner: "{{ item }}"
  55. group: "{{ item }}"
  56. with_items: "{{ users.keys() }}"
  57. when: users[item].authorized_keys is defined