You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 8 година
пре 7 година
пре 7 година
пре 8 година
пре 7 година
пре 8 година
пре 7 година
пре 8 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 8 година
пре 7 година
пре 8 година
пре 7 година
пре 8 година
пре 7 година
пре 8 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
пре 7 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 | default([]) | join(',') }}"
  21. uid: "{{ users[item].uid }}"
  22. home: "{{ users[item].home | default('/home/'+item) }}"
  23. shell: "{{ users[item].shell | default('/usr/bin/fish') }}"
  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. template:
  52. src: ssh_authorized_keys.j2
  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].ssh_authorized_keys is defined
  58. - name: check if systemd lingering is enabled
  59. stat:
  60. path: /var/lib/systemd/linger/{{item}}
  61. register: _users_systemd_linger_stat
  62. with_items: "{{ users.keys() }}"
  63. - name: set systemd lingering
  64. command:
  65. loginctl
  66. {{ users[item].linger | ternary('enable','disable') }}-linger
  67. {{item}}
  68. with_items: "{{ users.keys() }}"
  69. when:
  70. - users[item].linger is defined
  71. - (
  72. _users_systemd_linger_stat.results
  73. | json_query("[?item=='"+item+"'].stat.exists") | first
  74. ) != users[item].linger