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.

115 lines
2.7 KiB

  1. - include_role:
  2. name: service
  3. vars:
  4. service_name: nscd
  5. service_packages: nscd
  6. - name: configure OpenLDAP (domain)
  7. debconf:
  8. name: 'slapd'
  9. question: 'slapd/domain'
  10. vtype: 'string'
  11. value: '{{ ldap_domain }}'
  12. - name: configure OpenLDAP (configure)
  13. debconf:
  14. name: 'slapd'
  15. question: 'slapd/dump_database'
  16. vtype: 'string'
  17. value: 'when needed'
  18. - name: configure OpenLDAP (organization)
  19. debconf:
  20. name: 'slapd'
  21. question: 'shared/organization'
  22. vtype: 'string'
  23. value: '{{ ldap_organization }}'
  24. - name: slurp slap secret file
  25. slurp:
  26. src: /etc/slapd.secret
  27. register: slapdsecret
  28. failed_when: false
  29. changed_when: false
  30. - set_fact:
  31. slapd_passwd: "{{ slapdsecret['content'] | b64decode }}"
  32. when: '"content" in slapdsecret'
  33. - block:
  34. - name: generate admin password
  35. gen_passwd: length=20
  36. register: new_passwd
  37. - name: store slapd secret
  38. copy:
  39. content : "{{ new_passwd.passwd }}"
  40. dest: /etc/slapd.secret
  41. - set_fact:
  42. slapd_passwd: "{{ new_passwd.passwd }}"
  43. when: 'not "content" in slapdsecret'
  44. - name: configure OpenLDAP (password1)
  45. debconf:
  46. name: 'slapd'
  47. question: 'slapd/password1'
  48. vtype: 'string'
  49. value: '{{ slapd_passwd }}'
  50. - name: configure OpenLDAP (password2)
  51. debconf:
  52. name: 'slapd'
  53. question: 'slapd/password2'
  54. vtype: 'string'
  55. value: '{{ slapd_passwd }}'
  56. - name: configure phamm-ldap
  57. debconf:
  58. name: 'phamm-ldap'
  59. question: 'phamm-ldap/init_base_ldap'
  60. vtype: 'boolean'
  61. value: false
  62. - include_role:
  63. name: service
  64. vars:
  65. service_name: slapd
  66. service_packages:
  67. - slapd
  68. - ldap-utils
  69. - phamm-ldap
  70. - libpam-ldap
  71. - sudo
  72. - name: upload slapd config
  73. template:
  74. src: slapd.conf.j2
  75. dest: "/etc/ldap/slapd.conf"
  76. - name: update slapd config
  77. shell: slaptest -f /etc/ldap/slapd.conf -F /etc/ldap/slapd.d
  78. args:
  79. creates: "/etc/ldap/slapd.d/cn=config/cn=schema/cn={4}phamm.ldif"
  80. become: true
  81. become_method: sudo
  82. become_user: openldap
  83. notify: restart slapd
  84. - name: fix missing memberOf and pw-sha2 module load
  85. blockinfile:
  86. dest: /etc/ldap/slapd.d/cn=config/cn=module{0}.ldif
  87. content: |
  88. olcModuleLoad: {1}memberof
  89. olcModuleLoad: {2}pw-sha2
  90. notify: restart slapd
  91. - name: upload default tree
  92. template:
  93. dest=/etc/ldap/default_tree.ldif
  94. src=default_tree.ldif.j2
  95. owner=root
  96. group=root
  97. mode=0400
  98. register: upload_default_tree
  99. - name: create default tree
  100. shell: slapadd -l /etc/ldap/default_tree.ldif
  101. when: upload_default_tree.changed
  102. notify: restart slapd
  103. - name: enable OpenLDAP server
  104. service:
  105. name: 'slapd'
  106. enabled: true
  107. state: started