|
7 | 7 | - name: Package facts |
8 | 8 | package_facts: |
9 | 9 |
|
| 10 | +- name: Check if cert_policy entry exists in /etc/pam_pkcs11/pam_pkcs11.conf |
| 11 | + shell: grep "cert_policy" /etc/pam_pkcs11/pam_pkcs11.conf | wc -l |
| 12 | + register: cert_policy_count |
| 13 | + changed_when: false |
| 14 | + when: |
| 15 | + {{% if 'sle' in product %}} |
| 16 | + - "'pam_pkcs11' in ansible_facts.packages" |
| 17 | + {{% else %}} |
| 18 | + - "'libpam-pkcs11' in ansible_facts.packages" |
| 19 | + {{% endif %}} |
| 20 | + |
| 21 | +- name: Add cert_policy entry if none exist in /etc/pam_pkcs11/pam_pkcs11.conf |
| 22 | + lineinfile: |
| 23 | + path: /etc/pam_pkcs11/pam_pkcs11.conf |
| 24 | + line: 'cert_policy = ca,signature,ocsp_on;' |
| 25 | + create: true |
| 26 | + when: |
| 27 | + - (cert_policy_count.stdout | int) == 0 |
| 28 | + {{% if 'sle' in product %}} |
| 29 | + - "'pam_pkcs11' in ansible_facts.packages" |
| 30 | + {{% else %}} |
| 31 | + - "'libpam-pkcs11' in ansible_facts.packages" |
| 32 | + {{% endif %}} |
| 33 | + |
10 | 34 | - name: Replace 'none' from cert_policy |
11 | 35 | replace: |
12 | 36 | path: /etc/pam_pkcs11/pam_pkcs11.conf |
13 | 37 | regexp: (^\s*cert_policy\s*=\s*)none\s*;(\s*$) |
14 | 38 | replace: \g<1>ocsp_on,ca,signature;\g<2> |
15 | | - when: "'pam_pkcs11' in ansible_facts.packages" |
| 39 | + when: |
| 40 | + {{% if 'sle' in product %}} |
| 41 | + - "'pam_pkcs11' in ansible_facts.packages" |
| 42 | + {{% else %}} |
| 43 | + - "'libpam-pkcs11' in ansible_facts.packages" |
| 44 | + {{% endif %}} |
| 45 | + |
16 | 46 |
|
17 | 47 | - name: Add 'ocsp_on' parameter for cert_policy in /etc/pam_pkcs11/pam_pkcs11.conf |
18 | 48 | replace: |
19 | 49 | path: /etc/pam_pkcs11/pam_pkcs11.conf |
20 | 50 | regexp: (^\s*cert_policy\s*=\s*)(?!.*ocsp_on)(.*) |
21 | 51 | replace: \g<1>ocsp_on,\g<2> |
22 | | - when: "'pam_pkcs11' in ansible_facts.packages" |
| 52 | + when: |
| 53 | + {{% if 'sle' in product %}} |
| 54 | + - "'pam_pkcs11' in ansible_facts.packages" |
| 55 | + {{% else %}} |
| 56 | + - "'libpam-pkcs11' in ansible_facts.packages" |
| 57 | + {{% endif %}} |
| 58 | + |
0 commit comments