|
14 | 14 | ansible.builtin.file:
|
15 | 15 | path: /etc/ldap/ssl
|
16 | 16 | state: directory
|
17 |
| - when: pam_ldap.ssl_certificate is defined and pam_ldap.ssl_certificate | length > 0 |
| 17 | + when: pam_ldap.ssl_certificate|length > 0 |
18 | 18 |
|
19 | 19 | - name: Copy certificate.
|
20 | 20 | ansible.builtin.copy:
|
21 | 21 | src: "{{ pam_ldap.ssl_certificate }}"
|
22 | 22 | dest: "/etc/ldap/ssl/{{ pam_ldap.ssl_certificate | basename }}"
|
23 | 23 | mode: "0666"
|
24 |
| - when: pam_ldap.ssl_certificate is defined and pam_ldap.ssl_certificate | length > 0 |
| 24 | + when: pam_ldap.ssl_certificate|length > 0 |
25 | 25 |
|
26 | 26 | - name: Copy nslcd config.
|
27 | 27 | ansible.builtin.template:
|
|
82 | 82 | mode: 0555
|
83 | 83 | owner: root
|
84 | 84 |
|
85 |
| -- name: Create LDAP key script passwd file. |
86 |
| - ansible.builtin.template: |
87 |
| - src: ldap-bindpw.j2 |
88 |
| - dest: /etc/ldap/ldap-bindpw |
89 |
| - mode: "0600" |
90 |
| - owner: root |
91 |
| - when: |
92 |
| - - ldap_client.binddn is defined and ldap_client.binddn |
93 |
| - - ldap_client.bindpw is defined and ldap_client.bindpw |
94 |
| - |
95 |
| -- name: Create wrapper script for LDAP key script. |
96 |
| - ansible.builtin.template: |
97 |
| - src: ssh-getkey-ldap-wrapper.sh.j2 |
98 |
| - dest: /usr/local/bin/ssh-getkey-ldap-wrapper.sh |
99 |
| - mode: "0555" |
100 |
| - owner: root |
101 |
| - when: |
102 |
| - - ldap_client.binddn is defined and ldap_client.binddn |
103 |
| - - ldap_client.bindpw is defined and ldap_client.bindpw |
104 |
| - |
105 |
| -- name: Configure SSH pub key command if there is a binddn set. |
106 |
| - ansible.builtin.lineinfile: |
107 |
| - path: /etc/ssh/sshd_config |
108 |
| - regexp: "AuthorizedKeysCommand " |
109 |
| - line: AuthorizedKeysCommand /usr/local/bin/ssh-getkey-ldap-wrapper.sh |
| 85 | +- name: LDAP password handling. |
110 | 86 | when:
|
111 |
| - - ldap_client.binddn is defined and ldap_client.binddn |
| 87 | + - ldap_client.binddn|length > 0 |
| 88 | + - ldap_client.bindpw|length > 0 |
| 89 | + block: |
| 90 | + - name: Create LDAP key script passwd file. |
| 91 | + ansible.builtin.template: |
| 92 | + src: ldap-bindpw.j2 |
| 93 | + dest: /etc/ldap/ldap-bindpw |
| 94 | + mode: "0600" |
| 95 | + owner: root |
| 96 | + |
| 97 | + - name: Create wrapper script for LDAP key script. |
| 98 | + ansible.builtin.template: |
| 99 | + src: ssh-getkey-ldap-wrapper.sh.j2 |
| 100 | + dest: /usr/local/bin/ssh-getkey-ldap-wrapper.sh |
| 101 | + mode: "0555" |
| 102 | + owner: root |
| 103 | + |
| 104 | + # We don't support bind DN with no password because if there is no password the necessary script is not created. |
| 105 | + - name: Configure SSH pub key command if there is a binddn set. |
| 106 | + ansible.builtin.lineinfile: |
| 107 | + path: /etc/ssh/sshd_config |
| 108 | + regexp: "AuthorizedKeysCommand " |
| 109 | + line: AuthorizedKeysCommand /usr/local/bin/ssh-getkey-ldap-wrapper.sh |
112 | 110 |
|
113 | 111 | - name: Configure SSH pub key command if no binddn set.
|
114 | 112 | ansible.builtin.lineinfile:
|
115 | 113 | path: /etc/ssh/sshd_config
|
116 | 114 | regexp: "AuthorizedKeysCommand "
|
117 | 115 | line: AuthorizedKeysCommand /usr/local/bin/ssh-getkey-ldap
|
118 | 116 | when:
|
119 |
| - - not ldap_client.binddn |
| 117 | + - ldap_client.binddn|length == 0 |
120 | 118 |
|
121 | 119 | - name: Configure SSH pub key command user.
|
122 | 120 | ansible.builtin.lineinfile:
|
|
0 commit comments