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.

112 lines
2.6 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. - sudo
  71. - name: upload slapd config
  72. template:
  73. src: slapd.conf.j2
  74. dest: "/etc/ldap/slapd.conf"
  75. - name: update slapd config
  76. shell: slaptest -f /etc/ldap/slapd.conf -F /etc/ldap/slapd.d
  77. args:
  78. creates: "/etc/ldap/slapd.d/cn=config/cn=schema/cn={4}phamm.ldif"
  79. become: true
  80. become_method: sudo
  81. become_user: openldap
  82. notify: restart slapd
  83. - name: fix missing memberOf module load
  84. lineinfile:
  85. dest: /etc/ldap/slapd.d/cn=config/cn=module{0}.ldif
  86. line: "olcModuleLoad: {1}memberof"
  87. notify: restart slapd
  88. - name: upload default tree
  89. template:
  90. dest=/etc/ldap/default_tree.ldif
  91. src=default_tree.ldif.j2
  92. owner=root
  93. group=root
  94. mode=0400
  95. register: upload_default_tree
  96. - name: create default tree
  97. shell: slapadd -l /etc/ldap/default_tree.ldif
  98. when: upload_default_tree.changed
  99. notify: restart slapd
  100. - name: enable OpenLDAP server
  101. service:
  102. name: 'slapd'
  103. enabled: true
  104. state: started