Skip to content

Commit

Permalink
add ansible remediation
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtapolasek committed Sep 8, 2020
1 parent 649880f commit 57554f1
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# platform = Oracle Linux 7,Oracle Linux 8,Red Hat Enterprise Linux 6,Red Hat Enterprise Linux 7,Red Hat Enterprise Linux 8,Red Hat Virtualization 4,WRLinux 1019
# reboot = false
# complexity = low
# strategy = configure
# disruption = low

{{{ ansible_instantiate_variables("tftpd_secure_directory") }}}

- name: "Find out if the file exists and contains the line configuring server arguments"
find:
path: "/etc/xinetd.d"
patterns: "tftp"
contains: '^[\s]+server_args.*$'
register: tftpd_secure_config_line

- name: "Ensure that TFTP server is configured to start with secure directory"
lineinfile:
path: "/etc/xinetd.d/tftp"
regexp: '^[\s]*(server_args[\s]+=[\s]+.*?)(-s[\s]+[/\.\w]+)*(.*)$'
line: '\1 -s {{ tftpd_secure_directory }} \3'
state: present
backrefs: true
when: tftpd_secure_config_line is defined and tftpd_secure_config_line.matched > 0

- name: "Insert correct config line to start TFTP server with secure directory"
lineinfile:
path: "/etc/xinetd.d/tftp"
line: "server_args = -s {{ tftpd_secure_directory }}"
state: present
create: true
when: tftpd_secure_config_line is defined and tftpd_secure_config_line.matched == 0

0 comments on commit 57554f1

Please sign in to comment.