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.

314 lines
9.2 KiB

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