|
4 | 4 | # complexity = low |
5 | 5 | # disruption = low |
6 | 6 |
|
| 7 | +- name: "{{{ rule_title }}} - Set the base crypto policy" |
| 8 | + ansible.builtin.set_fact: |
| 9 | + expected_crypto_policy: "{{{ BASE_POLICY }}}" |
| 10 | + |
7 | 11 | {{% for sub_policy in SUB_POLICIES %}} |
| 12 | +{{% if "scope" in sub_policy %}} |
| 13 | +- name: "{{{ rule_title }}} - Check That /etc/crypto-policies/back-ends/{{{ sub_policy.scope }}}.config Exists" |
| 14 | + ansible.builtin.stat: |
| 15 | + path: /etc/crypto-policies/back-ends/{{{ sub_policy.scope }}}.config |
| 16 | + register: crypto_{{{ sub_policy.scope | replace("-", "_") }}}_scope |
| 17 | +{{% endif %}} |
| 18 | + |
8 | 19 | - name: "{{{ rule_title }}} - Create custom crypto policy module {{{ sub_policy.module_name }}}" |
9 | 20 | ansible.builtin.lineinfile: |
10 | 21 | path: /etc/crypto-policies/policies/modules/{{{ sub_policy.module_name }}}.pmod |
|
14 | 25 | line: {{{ sub_policy.key }}} = {{{ sub_policy.value }}} |
15 | 26 | create: true |
16 | 27 | regexp: "{{{ sub_policy.key }}}" |
| 28 | +{{% if "scope" in sub_policy %}} |
| 29 | + when: crypto_{{{ sub_policy.scope | replace("-", "_") }}}_scope.stat.exists |
| 30 | +{{% endif %}} |
| 31 | + |
| 32 | +- name: "{{{ rule_title }}} - Update the expected policy" |
| 33 | + ansible.builtin.set_fact: |
| 34 | + expected_crypto_policy: "{{ expected_crypto_policy + ':{{{ sub_policy.module_name }}}' }}" |
| 35 | +{{% if "scope" in sub_policy %}} |
| 36 | + when: crypto_{{{ sub_policy.scope | replace("-", "_") }}}_scope.stat.exists |
| 37 | +{{% endif %}} |
17 | 38 | {{% endfor %}} |
18 | 39 |
|
19 | 40 | - name: "{{{ rule_title }}} - Check current crypto policy" |
|
24 | 45 | check_mode: false |
25 | 46 |
|
26 | 47 | - name: "{{{ rule_title }}} - Update crypto-policies" |
27 | | - ansible.builtin.command: update-crypto-policies --set {{{ BASE_POLICY }}}:{{{ CONFIGURE_CRYPTO_POLICY_MODULES }}} |
28 | | - when: current_crypto_policy.stdout.strip() != "{{{ BASE_POLICY }}}:{{{ CONFIGURE_CRYPTO_POLICY_MODULES }}}" |
| 48 | + ansible.builtin.command: update-crypto-policies --set {{ expected_crypto_policy }} |
| 49 | + when: current_crypto_policy.stdout.strip() != expected_crypto_policy |
0 commit comments