Patch ansible remediation for postfix_network_listening_disabled rule#14394
Draft
teacup-on-rockingchair wants to merge 1 commit intoComplianceAsCode:masterfrom
Draft
Conversation
…e file with desired config
|
Skipping CI for Draft Pull Request. |
|
This datastream diff is auto generated by the check Click here to see the full diffansible remediation for rule 'xccdf_org.ssgproject.content_rule_postfix_network_listening_disabled' differs.
--- xccdf_org.ssgproject.content_rule_postfix_network_listening_disabled
+++ xccdf_org.ssgproject.content_rule_postfix_network_listening_disabled
@@ -20,9 +20,34 @@
tags:
- always
-- name: Gather list of packages
- ansible.builtin.package_facts:
- manager: auto
+- name: Make changes to Postfix configuration file
+ block:
+
+ - name: Check for duplicate values
+ ansible.builtin.lineinfile:
+ path: /etc/postfix/main.cf
+ create: false
+ regexp: (?i)^inet_interfaces\s*=\s*.*$
+ state: absent
+ check_mode: true
+ changed_when: false
+ register: dupes
+
+ - name: Deduplicate values from /etc/postfix/main.cf
+ ansible.builtin.lineinfile:
+ path: /etc/postfix/main.cf
+ create: false
+ regexp: (?i)^inet_interfaces\s*=\s*.*$
+ state: absent
+ when: dupes.found is defined and dupes.found > 1
+
+ - name: Insert correct line to /etc/postfix/main.cf
+ ansible.builtin.lineinfile:
+ path: /etc/postfix/main.cf
+ create: false
+ regexp: (?i)^inet_interfaces\s*=\s*.*$
+ line: inet_interfaces = {{ var_postfix_inet_interfaces }}
+ state: present
when:
- '"kernel-core" in ansible_facts.packages'
- '"postfix" in ansible_facts.packages'
@@ -39,29 +64,3 @@
- no_reboot_needed
- postfix_network_listening_disabled
- restrict_strategy
-
-- name: Make changes to Postfix configuration file
- ansible.builtin.lineinfile:
- path: /etc/postfix/main.cf
- create: false
- regexp: (?i)^inet_interfaces\s*=\s.*
- line: inet_interfaces = {{ var_postfix_inet_interfaces }}
- state: present
- insertafter: ^inet_interfaces\s*=\s.*
- when:
- - '"kernel-core" in ansible_facts.packages'
- - '"postfix" in ansible_facts.packages'
- - '"postfix" in ansible_facts.packages'
- tags:
- - CCE-82174-4
- - NIST-800-53-CM-6(a)
- - NIST-800-53-CM-7(a)
- - NIST-800-53-CM-7(b)
- - PCI-DSSv4-1.4
- - PCI-DSSv4-1.4.2
- - low_complexity
- - low_disruption
- - medium_severity
- - no_reboot_needed
- - postfix_network_listening_disabled
- - restrict_strategy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Rationale:
Fixes