Playbooks to a new Lilik
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.

237 lines
7.3 KiB

  1. ---
  2. - import_role: name='service'
  3. vars:
  4. service_name: 'nscd'
  5. service_packages: 'nscd'
  6. - name: 'set debconf values'
  7. debconf:
  8. name: 'slapd'
  9. question: '{{ item.question }}'
  10. vtype: 'string'
  11. value: '{{ item.value }}'
  12. register: debconfs
  13. loop:
  14. - { question: 'slapd/domain', value: '{{ ldap_domain }}' }
  15. - { question: 'slapd/dump_database', value: 'when needed' }
  16. - { question: 'shared/organization', value: '{{ ldap_organization }}' }
  17. - import_role: name='service'
  18. vars:
  19. service_name: 'slapd'
  20. service_packages:
  21. - 'slapd'
  22. - 'ldap-utils'
  23. - 'libpam-ldap'
  24. - 'python3-ldap'
  25. - 'sudo'
  26. - name: 'delete old backups'
  27. file:
  28. path: '{{ item }}'
  29. state: 'absent'
  30. with_fileglob: '/var/backups/*.ldapdb'
  31. when: debconfs.results[0].changed
  32. - name: 'backup old database and re-create'
  33. command: 'dpkg-reconfigure -p critical slapd'
  34. when: debconfs.results[0].changed
  35. - name: 'start slapd service'
  36. service:
  37. name: 'slapd'
  38. enabled: true
  39. state: 'started'
  40. - name: 'copy schemas'
  41. copy:
  42. src: '{{ item }}'
  43. dest: '/etc/ldap/schema/'
  44. loop:
  45. - 'ldapns.ldif'
  46. - 'kerberos.ldif'
  47. - 'phamm.ldif'
  48. - 'phamm-vacation.ldif'
  49. - name: 'activate schemas'
  50. command:
  51. cmd: 'ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/{{ item }}'
  52. creates: '/etc/ldap/slapd.d/cn=config/cn=schema/cn={*}{{ item }}'
  53. loop:
  54. - 'ldapns.ldif'
  55. - 'kerberos.ldif'
  56. - 'phamm.ldif'
  57. - 'phamm-vacation.ldif'
  58. - name: 'activate modules'
  59. ldap_attr:
  60. dn: 'cn=module{0},cn=config'
  61. name: 'olcModuleLoad'
  62. values:
  63. - '{0}back_mdb'
  64. - '{1}pw-sha2'
  65. - '{2}auditlog'
  66. - '{3}memberof'
  67. - name: 'create log dir'
  68. file:
  69. path: '/var/log/openldap'
  70. owner: 'openldap'
  71. group: 'openldap'
  72. state: 'directory'
  73. - name: 'set loglevel'
  74. ldap_attr:
  75. dn: 'cn=config'
  76. name: 'olcLogLevel'
  77. state: 'exact'
  78. values: 'conns acl'
  79. - name: 'activate auditlog overlay'
  80. ldap_entry:
  81. dn: 'olcOverlay={0}auditlog,olcDatabase={{ item.db }},cn=config'
  82. objectClass:
  83. - 'olcOverlayConfig'
  84. - 'olcAuditLogConfig'
  85. attributes:
  86. olcAuditlogFile: '/var/log/openldap/{{ item.logfile }}'
  87. loop:
  88. - { db: '{0}config', logfile: 'audit_config.ldif' }
  89. - { db: '{1}mdb', logfile: 'audit_mdb.ldif' }
  90. - name: 'activate memberof overlay'
  91. ldap_entry:
  92. dn: 'olcOverlay={1}memberof,olcDatabase={1}mdb,cn=config'
  93. objectClass:
  94. - 'olcOverlayConfig'
  95. - 'olcMemberOf'
  96. - name: 'set default password hash'
  97. ldap_attr:
  98. dn: 'olcDatabase={-1}frontend,cn=config'
  99. name: 'olcPasswordHash'
  100. values: '{SSHA512}'
  101. - name: 'configure TLS x509 <-> ldap dn translation'
  102. ldap_attr:
  103. dn: 'cn=config'
  104. name: 'olcAuthzRegexp'
  105. state: 'exact'
  106. values:
  107. - >-
  108. {0} ^cn=([^,]+),ou=Server,{{ ldap_x509_suffix }}$
  109. cn=$1,ou=Server,{{ ldap_basedn }}
  110. - >-
  111. {1} ^mail=[^,]+,cn=([^,]+),ou=People,{{ ldap_x509_suffix }}$
  112. cn=$1,ou=People,{{ ldap_basedn }}
  113. - >-
  114. {2} ^cn=([^,]+),ou=LDAP,{{ ldap_x509_suffix }}$
  115. cn=$1,ou=LDAP,{{ ldap_basedn }}
  116. - name: 'configure main tree acls'
  117. ldap_attr:
  118. dn: 'olcDatabase={1}mdb,cn=config'
  119. name: 'olcAccess'
  120. state: 'exact'
  121. values:
  122. # TOFIX: Remove hardcoded IP
  123. - >-
  124. {0} to dn.exact={{ ldap_basedn }} attrs=entry,objectClass,contextCSN
  125. by peername.regex=10\.150\.42\..* read
  126. by * break
  127. - >-
  128. {1} to dn.subtree={{ ldap_basedn }}
  129. {% if ldap_syncrepl_is_provider %}
  130. by dn.children=ou=LDAP,{{ ldap_basedn }} tls_ssf=256 read
  131. {% endif %}
  132. by * break
  133. # [0] -> Admins can proxy-auth to RootDN
  134. # /proxy-auth is not required for routine user-management operations
  135. - >-
  136. {2} to dn.exact=cn=admin,{{ ldap_basedn }} attrs=authzFrom
  137. by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} auth
  138. by * none
  139. # [1] :: ou=People
  140. # [1.0] -> Admins can edit People `userPassword`
  141. # -> People can edit their `userPassword`
  142. # -> Anyone can auth with `userPassword` if using strong TLS.
  143. - >-
  144. {3} to dn.one=ou=People,{{ ldap_basedn }} attrs=userPassword
  145. by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} write
  146. by self write
  147. by anonymous {{ 'tls_ssf=256 ' if ldap_tls_enabled }}auth
  148. by * none
  149. # [1.1] -> Admins can add/remove People entries
  150. - >-
  151. {4} to dn.exact=ou=People,{{ ldap_basedn }} attrs=children
  152. by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} write
  153. by * none
  154. # [1.2] -> Admins can list the full People tree
  155. # -> Servers can perform search on People tree
  156. - >-
  157. {5} to dn.exact=ou=People,{{ ldap_basedn }}
  158. by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} read
  159. by dn.children=ou=Server,{{ ldap_basedn }} search
  160. by * none
  161. # [1.3] -> Admins can edit all People attributes
  162. # -> Servers can read all People attributes (except userPassword)
  163. # -> People can read all their attributes
  164. # -> Break: over privileges may be accorded later (i.e.: servers)
  165. - >-
  166. {6} to dn.one=ou=People,{{ ldap_basedn }}
  167. by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} write
  168. by dn.children=ou=Server,{{ ldap_basedn }} read
  169. by self read
  170. by * break
  171. # [1.5] -> No other access to People tree
  172. - >-
  173. {7} to dn.subtree=ou=People,{{ ldap_basedn }}
  174. by * none
  175. # [2] :: ou=Group
  176. # [2.1] -> Admins can list groups
  177. # -> Servers can list groups
  178. - >-
  179. {8} to dn.exact=ou=Group,{{ ldap_basedn }} attrs=entry
  180. by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} read
  181. by dn.children=ou=Server,{{ ldap_basedn }} read
  182. by * none
  183. # [2.2] -> Admins can create/delete groups
  184. - >-
  185. {9} to dn.exact=ou=Group,{{ ldap_basedn }} attrs=children
  186. by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} write
  187. by * none
  188. # [2.3] -> Admins can edit group members
  189. # -> Server can list group members
  190. - >-
  191. {10} to dn.one=ou=Group,{{ ldap_basedn }}
  192. by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} write
  193. by dn.children=ou=Server,{{ ldap_basedn }} read
  194. by * none
  195. # [2.2] -> No other access to Group tree
  196. - >-
  197. {11} to dn.children=ou=Group,{{ ldap_basedn }}
  198. by * none
  199. # [3] :: ou=Server
  200. # [3.0] -> Local servers can simple-bind their entries if using TLS
  201. # /Server using TLS-client Auth with OU=Server are automatically authenticated
  202. ## TODO: Add peername.ip filtering on server subnet
  203. - >-
  204. {12} to dn.children=ou=Server,{{ ldap_basedn }} attrs=userPassword
  205. by anonymous {{ 'tls_ssf=256 ' if ldap_tls_enabled }}auth
  206. by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} write
  207. by * none
  208. # [3.1] -> No other access to Server tree
  209. - >-
  210. {13} to dn.subtree=ou=Server,{{ ldap_basedn }}
  211. by * none
  212. # [4] :: ou=VirtualDomains - WiP
  213. # [4.0] -> Admins can write whole subtree
  214. # [4.1] -> Servers can read whole subtree
  215. # - >-
  216. # to dn.subtree=ou=VirtualDomains,{{ ldap_basedn }}
  217. # by group.exact=cn=admin,ou=Group,{{ ldap_basedn }} write
  218. # by dn.children=ou=Server,{{ ldap_basedn }} read
  219. # [5] :: ou=Kerberos - Wi
  220. ...