Skip to content
Snippets Groups Projects
Commit 51eb507c authored by Jupiter Hu's avatar Jupiter Hu
Browse files

fixed ldap server configuration

parent 052d65aa
No related branches found
No related tags found
No related merge requests found
...@@ -107,7 +107,8 @@ ...@@ -107,7 +107,8 @@
- { after: '^AuthType Shibboleth', line: 'ShibRequireSession On' } - { after: '^AuthType Shibboleth', line: 'ShibRequireSession On' }
- { after: '^ShibRequireSession On', line: 'ShibUseHeaders On' } - { after: '^ShibRequireSession On', line: 'ShibUseHeaders On' }
- { after: '^ShibUseHeaders On', line: 'require valid-user' } - { after: '^ShibUseHeaders On', line: 'require valid-user' }
- { after: '^require valid-user', line: '</Location>' } - { after: 'EOF', line: '</Location>' }
# - { after: '^require valid-user', line: '</Location>' }
sudo: true sudo: true
- -
......
---
dependencies:
- { role: easy-rsa-certificate, x509_csr_args: "", x509_sign_args: "--server", x509_cacert_file: "/etc/ssl/certs/ca.crt", x509_key_file: "/etc/ssl/private/server.key", x509_cert_file: "/etc/ssl/certs/server.crt", x509_common_name: "{{ ansible_fqdn }}" }
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
sudo: true sudo: true
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'
- name: hash password - name: hash password
command: /usr/sbin/slappasswd -h {SSHA} -s {{ ldapManagerPassword }} command: /usr/sbin/slappasswd -h {SSHA} -s {{ ldapManagerPassword }}
register: ldapManagerHash register: ldapManagerHash
...@@ -60,8 +59,8 @@ ...@@ -60,8 +59,8 @@
- name: template acls.ldif - name: template acls.ldif
template: src=acls_ldif.j2 dest=/tmp/acls.ldif template: src=acls_ldif.j2 dest=/tmp/acls.ldif
- name: template ppolicy_moduleload.ldif - name: template load_modules.ldif
template: src=ppolicy_moduleload_ldif.j2 dest=/tmp/ppolicy_moduleload.ldif template: src=load_modules_ldif.j2 dest=/tmp/load_modules.ldif
- name: template ppolicy_overlay.ldif - name: template ppolicy_overlay.ldif
template: src=ppolicy_overlay_ldif.j2 dest=/tmp/ppolicy_overlay.ldif template: src=ppolicy_overlay_ldif.j2 dest=/tmp/ppolicy_overlay.ldif
...@@ -84,6 +83,12 @@ ...@@ -84,6 +83,12 @@
file: path={{ cacert | dirname }} state=directory owner={{ ldapuser }} group={{ ldapgroup }} file: path={{ cacert | dirname }} state=directory owner={{ ldapuser }} group={{ ldapgroup }}
sudo: true sudo: true
# Change to remove easy-rsa and to use fixed key and certs
- name: copy fixed keys and certs from files directory
template: src=files/{{ item.src }} dest="{{ item.dest }}" mode={{ item.mode }} owner=root group=root
with_items: ldapCertFiles
sudo: true
- name: copy cert - name: copy cert
command: cp /etc/ssl/certs/server.crt {{ ldapcert }} command: cp /etc/ssl/certs/server.crt {{ ldapcert }}
sudo: true sudo: true
...@@ -134,16 +139,6 @@ ...@@ -134,16 +139,6 @@
register: aclConfigured register: aclConfigured
- name: check DIT config
shell: "ldapsearch -D {{ ldapManager }} -w {{ ldapManagerPassword }} -b {{ ldapBase }} -x -H ldap://localhost objectClass=dcObject"
ignore_errors: true
register: ditConfigured
- name: check Accounts config
shell: "ldapsearch -D {{ ldapManager }} -w {{ ldapManagerPassword }} -b {{ ldapUserBase }} -x -H ldap://localhost objectClass=*"
ignore_errors: true
register: accountsConfigured
- name: check real Accounts config - name: check real Accounts config
shell: "ldapsearch -D {{ ldapManager }} -w {{ ldapManagerPassword }} -b {{ ldapAccountBase }} -x -H ldap://localhost objectClass=*" shell: "ldapsearch -D {{ ldapManager }} -w {{ ldapManagerPassword }} -b {{ ldapAccountBase }} -x -H ldap://localhost objectClass=*"
ignore_errors: true ignore_errors: true
...@@ -160,8 +155,7 @@ ...@@ -160,8 +155,7 @@
ignore_errors: true ignore_errors: true
register: binddnConfigured register: binddnConfigured
- - name: Initialise cosine and ppolicy
name: Initialise cosine and ppolicy
shell: ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/{{ item }}.ldif -D cn=config shell: ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/{{ item }}.ldif -D cn=config
with_items: with_items:
- ppolicy - ppolicy
...@@ -177,46 +171,94 @@ ...@@ -177,46 +171,94 @@
sudo: true sudo: true
when: tlsConfigured|failed when: tlsConfigured|failed
- name: check DIT config
shell: "ldapsearch -D {{ ldapManager }} -w {{ ldapManagerPassword }} -b {{ ldapBase }} -x -H ldap://localhost objectClass=dcObject"
ignore_errors: true
register: ditConfigured
- name: check Accounts config
shell: "ldapsearch -D {{ ldapManager }} -w {{ ldapManagerPassword }} -b {{ ldapUserBase }} -x -H ldap://localhost objectClass=*"
ignore_errors: true
register: accountsConfigured
- name: initialise server manager - name: initialise server manager
shell: ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/manager.ldif -D cn=config shell: ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/manager.ldif -D cn=config
sudo: true sudo: true
when: managerConfigured|failed when: managerConfigured|failed
- name: initialise server manager - name: initialise server manager
shell: ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/manager2.ldif -D cn=config shell: ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/manager2.ldif -D cn=config
sudo: true sudo: true
ignore_errors: true ignore_errors: true
when: managerConfigured|failed when: managerConfigured|failed
- name: initialise server manager - name: initialise server manager
shell: ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/manager3.ldif -D cn=config shell: ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/manager3.ldif -D cn=config
sudo: true sudo: true
when: managerConfigured|failed when: managerConfigured|failed
- name: initialise server acls - name: initialise server acls
shell: ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/acls.ldif -D cn=config shell: ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/acls.ldif -D cn=config
sudo: true sudo: true
when: aclConfigured|failed when: aclConfigured|failed
- name: add DIT root - name: add DIT root
shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/root.ldif shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/root.ldif
sudo: true
when: ditConfigured|failed when: ditConfigured|failed
- name: add Accounts OU - name: add Accounts OU
shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/accounts.ldif shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/accounts.ldif
sudo: true
when: accountsConfigured|failed when: accountsConfigured|failed
- name: add real Accounts OU - name: add real Accounts OU
shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/real_accounts.ldif shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/real_accounts.ldif
sudo: true
when: realAccountsConfigured is defined and realAccountsConfigured|failed when: realAccountsConfigured is defined and realAccountsConfigured|failed
- name: add Groups OU - name: add Groups OU
shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/groups.ldif shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/groups.ldif
sudo: true
when: groupsConfigured|failed when: groupsConfigured|failed
- name: add binddn - name: add binddn
shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/binddn.ldif shell: ldapadd -x -D {{ ldapManager }} -w {{ ldapManagerPassword }} -x -H ldap://localhost -f /tmp/binddn.ldif
sudo: true sudo: true
when: binddnConfigured|failed when: binddnConfigured|failed
- name: check ppolicy module loaded
shell: slapcat -b cn=config | grep "olcModuleLoad. {.*}ppolicy"
sudo: true
ignore_errors: true
register: ppolicyModuleLoaded
- name: load ppolicy module
shell: ldapadd -Y EXTERNAL -H ldapi:/// -f /tmp/load_modules.ldif -D cn=config
sudo: true
when: ppolicyModuleLoaded|failed
- name: check ppolicy overlay config
shell: "slapcat -b cn=config | grep 'dn: olcOverlay=ppolicy,olcDatabase={.*}.db,cn=config'"
ignore_errors: true
sudo: true
register: ppolicyOverlayConfigured
- name: add ppolicy overlay
shell: ldapadd -Y EXTERNAL -H ldapi:/// -f /tmp/ppolicy_overlay.ldif -D cn=config
sudo: true
when: ppolicyOverlayConfigured|failed
- name: check pwpolicies config
shell: ldapsearch -D cn=binddn,ou=Accounts,{{ ldapDomain }} -w {{ ldapBindDNPassword }} -b ou=pwpolicies,{{ ldapDomain }} objectClass=*
ignore_errors: true
register: pwpoliciesConfigured
- name: add pwpolicies
shell: ldapadd -x -D cn=Manager,{{ ldapDomain }} -w {{ ldapManagerPassword }} -f /tmp/pwpolicies.ldif
when: pwpoliciesConfigured|failed
- name: check defaultPwpolicy config
shell: ldapsearch -D cn=binddn,ou=Accounts,{{ ldapDomain }} -w {{ ldapBindDNPassword }} -b cn=default,ou=pwpolicies,{{ ldapDomain }} objectClass=*
ignore_errors: true
register: defaultPpolicyConfigured
- name: add defaultPwpolicy
shell: ldapadd -x -D cn=Manager,{{ ldapDomain }} -w {{ ldapManagerPassword }} -f /tmp/default_ppolicy.ldif
when: defaultPpolicyConfigured|failed
dn: cn=module,cn=config dn: cn=module,cn=config
objectClass: olcModuleList objectClass: olcModuleList
cn: module cn: module
olcModulePath: /usr/lib64/openldap/ olcModulePath: {{ module_path }}
olcModuleLoad: ppolicy.la olcModuleLoad: ppolicy.la
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
ldapcert: /etc/openldap/certs/ldapcert.pem ldapcert: /etc/openldap/certs/ldapcert.pem
ldapkey: /etc/openldap/certs/ldapkey.pem ldapkey: /etc/openldap/certs/ldapkey.pem
cacert: /etc/openldap/certs/cacert.pem cacert: /etc/openldap/certs/cacert.pem
module_path: "/usr/lib64/openldap/"
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
ldapcert: /etc/ldap/certs/ldapcert.pem ldapcert: /etc/ldap/certs/ldapcert.pem
ldapkey: /etc/ldap/certs/ldapkey.pem ldapkey: /etc/ldap/certs/ldapkey.pem
cacert: /etc/ldap/certs/cacert.pem cacert: /etc/ldap/certs/cacert.pem
module_path: "/usr/lib/ldap"
--- ---
- -
name: "Copying the shibboleth files" name: "Copying the shibboleth files"
template: src=files/{{ item.src }} dest="/etc/shibboleth/{{ item.dest }}" mode=0644 template: src=files/{{ item.src }} dest="{{ item.dest }}" mode=0644
sudo: true
with_items: shibboleth_file with_items: shibboleth_file
when: shibboleth_file is defined sudo: true
- -
name: "Setting shibboleth2.xml sp.example.org" name: "Setting shibboleth2.xml sp.example.org"
...@@ -28,7 +27,7 @@ ...@@ -28,7 +27,7 @@
args: args:
dest: /etc/shibboleth/shibboleth2.xml dest: /etc/shibboleth/shibboleth2.xml
regexp: 'handlerSSL="false"' regexp: 'handlerSSL="false"'
replace: 'handlerSSL="true" handlerURL="https://{{ ansible_fqdn }}/Shibboleth.sso"' replace: 'handlerSSL="true" handlerURL="https://{{ ansible_hostname }}.{{ domain }}/Shibboleth.sso"'
- -
...@@ -101,7 +100,16 @@ ...@@ -101,7 +100,16 @@
args: args:
dest: /etc/shibboleth/shibboleth2.xml dest: /etc/shibboleth/shibboleth2.xml
regexp: '<CredentialResolver type="File" key="sp-key.pem" certificate="sp-cert.pem"/>' regexp: '<CredentialResolver type="File" key="sp-key.pem" certificate="sp-cert.pem"/>'
replace: '<CredentialResolver type="File" key="{{ x509_key_file }}" certificate="{{ x509_cert_file }}"/>' replace: '<CredentialResolver type="File" key="{{ x509_key_file }}" certificate="{{ x509_cert_path }}/{{ x509_common_name }}.cert"/>'
-
name: "fix directory access permission"
file: path={{ x509_key_file | dirname }} owner=root group=_shibd state=directory mode=750
sudo: true
-
name: "fix key access permission"
file: path={{ x509_key_file }} owner=root group=_shibd mode=644
sudo: true
- -
name: "Templating attribute-map.xml" name: "Templating attribute-map.xml"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment