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.

214 lines
6.3 KiB

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