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.

127 lines
3.4 KiB

  1. ---
  2. - name: 'SYNC | create replication consumer certificate'
  3. import_role: name='ca_cert'
  4. vars:
  5. ca_cert_common_name: '{{ host_fqdn }}'
  6. ca_cert_proto: 'tls'
  7. ca_cert_client: true
  8. ca_cert_tls_subj: '{{ openssl_x509_prefix }}/OU=LDAP/CN={{ ca_cert_common_name }}'
  9. ca_cert_tls_ca_path: '/etc/ldap/user_ca.crt'
  10. ca_cert_tls_key_path: '/etc/ldap/syncrepl.key'
  11. ca_cert_tls_csr_path: '/etc/ldap/syncrepl.csr'
  12. ca_cert_tls_cert_path: '/etc/ldap/syncrepl.crt'
  13. when: ldap_syncrepl_is_consumer
  14. tags:
  15. - 'pki'
  16. - 'pki::tls'
  17. - name: 'SYNC | set key ownership'
  18. file:
  19. path: '/etc/ldap/syncrepl.key'
  20. owner: 'openldap'
  21. group: 'openldap'
  22. when: ldap_syncrepl_is_consumer
  23. tags:
  24. - 'pki'
  25. - 'pki::tls'
  26. - name: 'SYNC | activate syncprov module'
  27. ldap_attr:
  28. dn: 'cn=module{0},cn=config'
  29. name: 'olcModuleLoad'
  30. values: '{4}syncprov'
  31. state: 'present'
  32. when: ldap_syncrepl_is_provider
  33. - name: 'SYNC | activate overlay'
  34. ldap_entry:
  35. dn: 'olcOverlay={2}syncprov,olcDatabase={1}mdb,cn=config'
  36. objectClass:
  37. - 'olcOverlayConfig'
  38. - 'olcSyncProvConfig'
  39. when: ldap_syncrepl_is_provider
  40. - name: 'SYNC | disable limits for consumer'
  41. ldap_attr:
  42. dn: 'olcDatabase={1}mdb,cn=config'
  43. name: 'olcLimits'
  44. state: 'exact'
  45. values:
  46. - >-
  47. {0} dn.children=ou=LDAP,{{ ldap_basedn }}
  48. time.soft=unlimited
  49. time.hard=unlimited
  50. size.soft=unlimited
  51. size.hard=unlimited
  52. when: ldap_syncrepl_is_provider
  53. - name: 'SYNC | set serverID'
  54. ldap_attr:
  55. dn: 'cn=config'
  56. name: 'olcServerID'
  57. values: '{{ ldap_syncrepl_server_id }}'
  58. state: 'exact'
  59. - name: 'SYNC | build SyncRepl configuration'
  60. set_fact:
  61. syncrepls: |
  62. {{ syncrepls|d([])
  63. + [
  64. '{'+idx|string+'}'
  65. + ' rid='+item.rid|string
  66. + ' provider='+item.url
  67. + ' searchbase='+ldap_basedn
  68. + ' type=refreshAndPersist'
  69. + ' interval=00:01:00:00'
  70. + ' retry="5 5 300 5"'
  71. + ' timeout=1'
  72. + ' bindmethod=sasl'
  73. + ' saslmech=EXTERNAL'
  74. + ' starttls=critical'
  75. + ' tls_cert="/etc/ldap/syncrepl.crt"'
  76. + ' tls_key="/etc/ldap/syncrepl.key"'
  77. + ' tls_cacert="/etc/ldap/server_ca.crt"'
  78. ] }}
  79. loop: '{{ ldap_syncrepl_target_providers }}'
  80. loop_control:
  81. index_var: idx
  82. when: ldap_syncrepl_is_consumer
  83. - debug:
  84. msg: syncrepls
  85. - name: 'SYNC | apply SyncRepl configuration'
  86. ldap_attr:
  87. dn: 'olcDatabase={1}mdb,cn=config'
  88. name: 'olcSyncRepl'
  89. values: '{{ syncrepls }}'
  90. state: 'exact'
  91. ignore_errors: true
  92. when: ldap_syncrepl_is_consumer
  93. - name: 'SYNC | enable MirrorMode'
  94. ldap_attr:
  95. dn: 'olcDatabase={1}mdb,cn=config'
  96. name: 'olcMirrorMode'
  97. values: 'TRUE'
  98. state: 'exact'
  99. when:
  100. - ldap_syncrepl_is_consumer
  101. - ldap_syncrepl_is_provider
  102. - name: 'MONITORING | add ldap_master'
  103. set_fact:
  104. monitoring_facts: >
  105. {{ hostvars[monitoring_host]['monitoring_facts']
  106. | default({})
  107. | combine({
  108. host_fqdn: {
  109. "vars": { "ldap_master": ldap_syncrepl_target_providers[0].url }
  110. }
  111. }, recursive=True) }}
  112. delegate_to: '{{ monitoring_host }}'
  113. delegate_facts: true
  114. when: ldap_syncrepl_is_consumer
  115. tags:
  116. - 'monitoring'
  117. ...