Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Ansible Scripts #2134

Merged
merged 51 commits into from Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
46a5e30
ansible remediation: no_direct_root_logins.yml
shawndwells Jul 6, 2017
24a5499
ansible: ensure_gpgcheck_never_disabled.yml
shawndwells Jul 6, 2017
0d74e64
ansible: no_direct_root_logins.yml, restrict_serial_port_logins.yml, …
shawndwells Jul 6, 2017
4350505
ansible: require_smb_client_signing.yml
shawndwells Jul 6, 2017
a15b196
ansible: sshd_enable_x11_forwarding.yml
shawndwells Jul 6, 2017
0e276c8
ansible: accounts_maximum_age_login_defs.yml
shawndwells Jul 6, 2017
edca324
ansible: accounts_password_warn_age_login_defs.yml
shawndwells Jul 6, 2017
0fadd73
ansible: accounts_minimum_age_login_defs.yml
shawndwells Jul 6, 2017
5f8f429
ansible: accounts_password_pam_minlen.yml
shawndwells Jul 6, 2017
3d56736
ansible: bootloader_audit_argument.yml
shawndwells Jul 6, 2017
bba7583
ansible: auditd_data_retention_space_left_action.yml
shawndwells Jul 6, 2017
f07b71c
ansible: auditd_data_retention_admin_space_left_action.yml
shawndwells Jul 6, 2017
109a804
update auditd_data_retention_space_left_action.yml with notify action
shawndwells Jul 6, 2017
0d3d239
ansible: account_disable_post_pw_expiration.yml
shawndwells Jul 6, 2017
c210040
ansible: accounts_maximum_age_login_defs.yml
shawndwells Jul 6, 2017
024fe01
ansible: accounts_password_minlen_login_defs.yml
shawndwells Jul 6, 2017
cdc97d6
updated ensure_gpgcheck_never_disabled.yml with ANSIBLE_TAGS
shawndwells Jul 6, 2017
4753887
add ansible tags
shawndwells Jul 6, 2017
6a6cda0
remove shell
shawndwells Jul 6, 2017
115841a
ansible: auditd_data_retention_action_mail_acct.yml
shawndwells Jul 6, 2017
7aa0fc5
ansible: auditd_data_retention_max_log_file.yml
shawndwells Jul 6, 2017
46d9612
ansible: auditd_data_retention_max_log_file_action.yml
shawndwells Jul 6, 2017
aed4f9a
ansible: auditd_data_retention_flush.yml
shawndwells Jul 6, 2017
8f97df5
ansible: clean_components_post_updating.yml
shawndwells Jul 6, 2017
34dce7e
ansible: accounts_max_concurrent_login_sessions.yml
shawndwells Jul 6, 2017
ef6cd21
ansible: sshd_enable_warning_banner.yml
shawndwells Jul 6, 2017
14c291d
add validate and notify to sshd checks
shawndwells Jul 6, 2017
ddfc139
update for lineinfile
shawndwells Jul 6, 2017
d25e60c
ansible: accounts_tmout.yml
shawndwells Jul 6, 2017
22cd600
update regex of sshd checks
shawndwells Jul 6, 2017
89e6329
ansible: accounts_password_pam_maxrepeat.yml
shawndwells Jul 6, 2017
3b7cc89
ansible: accounts_password_pam_maxclassrepeat.yml
shawndwells Jul 6, 2017
ec092f0
ansible: set_password_hashing_algorithm_logindefs.yml
shawndwells Jul 6, 2017
cd387c9
ansible: accounts_minimum_age_login_defs.yml
shawndwells Jul 6, 2017
8c900f8
ansible: accounts_maximum_age_login_defs.yml
shawndwells Jul 7, 2017
7f256d2
ansible: no_rsh_trust_files.yml
shawndwells Jul 7, 2017
0874bd0
removed rhel multiplatform
shawndwells Jul 7, 2017
a00ad68
remove rhel5
shawndwells Jul 7, 2017
812f3ff
commented out notify
shawndwells Jul 13, 2017
6434bfe
fixed notify call for sshd_allow_only_protocol2.yml
shawndwells Jul 13, 2017
58e630a
removing validate until functions implemented
shawndwells Jul 13, 2017
ada55fc
update validate
shawndwells Jul 14, 2017
cf89346
updated yaml ensure_redhat_gpgkey_installed.yml
shawndwells Jul 14, 2017
675dd43
rebase
shawndwells Jul 14, 2017
6ab1ec4
Merge branch 'more_ansible' of github.com:shawndwells/scap-security-g…
shawndwells Jul 14, 2017
0e829d8
formatting for sshd_set_keepalive.yml
shawndwells Jul 14, 2017
89eaf69
update ansible syntax to use :
shawndwells Jul 14, 2017
b29b16b
additional syntax cleanup
shawndwells Jul 14, 2017
d7a75e2
Merge branch 'master' into more_ansible
shawndwells Jul 14, 2017
5613309
Merge remote-tracking branch 'origin/more_ansible' into more_ansible
shawndwells Jul 14, 2017
3151080
removed broke ansible
shawndwells Jul 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3,12 +3,12 @@
# strategy = restrict
# complexity = low
# disruption = low
- name: "Disable POST password expiration"
- name: "Set Account Expiration Following Inactivity"
lineinfile:
create=yes
dest="/etc/default/useradd"
regexp="^INACTIVE"
line="INACTIVE=-1"
line="INACTIVE=(ansible-populate var_account_disable_post_pw_expiration)"
tags:
@ANSIBLE_TAGS@

@@ -0,0 +1,14 @@
# platform = multi_platform_fedora, Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 6
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: "Limit the Number of Concurrent Login Sessions Allowed Per User"
lineinfile:
state: present
dest: /etc/security/limits.conf
insertbefore: '^# End of file'
regexp: '^#?\\*.*maxlogins'
line: '* hard maxlogins (ansible-populate var_accounts_max_concurrent_login_sessions)'
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Set Password Maximum Age
lineinfile:
create: yes
dest: /etc/login.defs
regexp: ^#?PASS_MAX_DAYS
line: PASS_MAX_DAYS (ansible-populate var_accounts_maximum_age_login_defs)
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Set Password Minimum Age
lineinfile:
create: yes
dest: /etc/login.defs
regexp: ^#?PASS_MIN_DAYS
line: PASS_MIN_DAYS (ansible-populate var_accounts_minimum_age_login_defs)
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: "Set Password Minimum Length in login.defs"
lineinfile:
dest: /etc/login.defs
regexp: "^PASS_MIN_LEN *[0-9]*"
state: present
line: "PASS_MIN_LEN (ansible-populate var_accounts_password_minlen_login_defs)"
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name:
lineinfile:
create: yes
dest: /etc/security/pwquality.conf
regexp: '^#?\s*maxclassrepeat'
line: maxclassrepeat = (ansible-populate var_password_pam_maxclassrepeat)
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Set Password Maximum Consecutive Repeating Characters
lineinfile:
create: yes
dest: /etc/security/pwquality.conf
regexp: '^#?\s*maxrepeat'
line: maxrepeat = (ansible-populate var_password_pam_maxrepeat)
tags:
@ANSIBLE_TAGS@
13 changes: 13 additions & 0 deletions shared/templates/static/ansible/accounts_password_pam_minlen.yml
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: "Set Password Minimum Length - /etc/security/pwquality.conf"
lineinfile:
dest: /etc/security/pwquality.conf
regexp: "^minlen ="
state: present
line: "minlen = (ansible-populate var_password_pam_minlen)"
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: "Set Password Warning Age"
lineinfile:
dest: /etc/login.defs
regexp: "^PASS_WARN_AGE *[0-9]*"
state: present
line: "PASS_WARN_AGE (ansible-populate var_accounts_password_warn_age_login_defs)"
tags:
@ANSIBLE_TAGS@
13 changes: 13 additions & 0 deletions shared/templates/static/ansible/accounts_tmout.yml
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Set Interactive Session Timeout
lineinfile:
create: yes
dest: /etc/profile
regexp: ^#?TMOUT
line: TMOUT=(ansible-populate var_accounts_tmout)
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Configure auditd mail_acct Action on Low Disk Space
lineinfile:
dest: /etc/audit/auditd.conf
line: "action_mail_acct = (ansible-populate var_auditd_action_mail_acct)"
state: present
notify: reload auditd
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Configure auditd admin_space_left Action on Low Disk Space
lineinfile:
dest: /etc/audit/auditd.conf
line: "admin_space_left_action = (ansible-populate var_auditd_admin_space_left_action)"
regexp: "^admin_space_left_action*"
notify: reload auditd
tags:
@ANSIBLE_TAGS@
13 changes: 13 additions & 0 deletions shared/templates/static/ansible/auditd_data_retention_flush.yml
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Configure auditd Flush Priority
lineinfile:
dest: /etc/audit/auditd.conf
regexp: '.*flush.*'
line: flush = data
notify: reload auditd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this work as is or do we need ansible handlers defined for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpreisler: shoot, you're right. I can take the notify out for now... how would we create handles?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's comment it or something so that we can grep for it when we implement handlers

tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Configure auditd Max Log File Size
lineinfile:
dest: /etc/audit/auditd.conf
line: "max_log_file (ansible-populate var_auditd_max_log_file)"
state: present
notify: reload auditd
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Configure auditd max_log_file_action Upon Reaching Maximum Log Size
lineinfile:
dest: /etc/audit/auditd.conf
line: "max_log_file_action (ansible-populate var_auditd_max_log_file_action)"
state: present
notify: reload auditd
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Configure auditd space_left Action on Low Disk Space
lineinfile:
dest: /etc/audit/auditd.conf
line: "space_left_action = (ansible-populate var_auditd_space_left_action)"
regexp: "^space_left_action*"
notify: reload auditd
tags:
@ANSIBLE_TAGS@
9 changes: 9 additions & 0 deletions shared/templates/static/ansible/bootloader_audit_argument.yml
@@ -0,0 +1,9 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = true
# strategy = restrict
# complexity = low
# disruption = low
- name: "Enable Auditing for Processes Which Start Prior to the Audit Daemon"
shell: /sbin/grubby --update-kernel=ALL --args="audit=1"
tags:
@ANSIBLE_TAGS@
13 changes: 13 additions & 0 deletions shared/templates/static/ansible/clean_components_post_updating.yml
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: "Ensure YUM Removes Previous Package Versions"
lineinfile:
dest: /etc/yum.conf
regexp: ^#?clean_requirements_on_remove
line: clean_requirements_on_remove=1
insertafter: '\[main\]'
tags:
@ANSIBLE_TAGS@
21 changes: 21 additions & 0 deletions shared/templates/static/ansible/ensure_gpgcheck_never_disabled.yml
@@ -0,0 +1,21 @@
# platform = multi_platform_rhel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole file needs @ANSIBLE_TAGS@

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved in cdc97d6

# reboot = false
# strategy = unknown
# complexity = low
# disruption = medium
#
- name: Find All Yum Repositories
find:
paths: "/etc/yum.repos.d/"
patterns: "*.repo"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs check_mode: no I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm learning ansible as I go here.

If I understand check_mode correctly, this still should run in check mode to populate the yum_find variable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct. This does not need check_mode no.

register: yum_find

- name: Ensure gpgcheck Enabled For All Yum Package Repositories
with_items: "{{ yum_find.files }}"
lineinfile:
create: yes
dest: "{{ item.path }}"
regexp: '^gpgcheck'
line: 'gpgcheck=1'
tags:
@ANSIBLE_TAGS@
9 changes: 9 additions & 0 deletions shared/templates/static/ansible/no_direct_root_logins.yml
@@ -0,0 +1,9 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: "Direct root Logins Not Allowed"
shell: echo > /etc/securetty
tags:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using shell in ansible is frowned upon and I think we can do this without shell.

@ANSIBLE_TAGS@
22 changes: 22 additions & 0 deletions shared/templates/static/ansible/no_rsh_trust_files.yml
@@ -0,0 +1,22 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- block:
- name: "Detect shosts.equiv Files on the System"
find:
paths: /
recurse: yes
patterns: shosts.equiv
check_mode: no
register: shosts_equiv_locations

- name: "Remove Rsh Trust Files"
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ shosts_equiv_locations }}"
when: shosts_equiv_locations
tags:
@ANSIBLE_TAGS@
22 changes: 22 additions & 0 deletions shared/templates/static/ansible/require_smb_client_signing.yml
@@ -0,0 +1,22 @@
# platform = multi_platform_rhel, multi_platform_fedora
# reboot = false
# strategy = configure
# complexity = low
# disruption = medium
- name: Check if /etc/samba/smb.conf exists
stat:
path: /etc/samba/smb.conf
register: st_smb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_mode no

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all items related to the rule need @ANSIBLE_TAGS@

That way if you just select one rule by its tag it will work. Otherwise it would skip the register tag and then use undeclared variables.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Believe this needs check_mode to populate the st_smb variable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you are right, since it's not shell and it already has both check and execution modes it doesn't need check_mode no

tags:
@ANSIBLE_TAGS@

- name: Require Client SMB Packet Signing, if using smbclient
lineinfile:
dest: /etc/samba/smb.conf
line: "client signing = mandatory"
state: present
insertafter: "[global]"
when: st_smb.stat.exists
tags:
@ANSIBLE_TAGS@

12 changes: 12 additions & 0 deletions shared/templates/static/ansible/restrict_serial_port_logins.yml
@@ -0,0 +1,12 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: "Restrict Serial Port Root Logins"
lineinfile:
dest: /etc/securetty
regexp: 'ttyS[0-9]'
state: absent
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,12 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: "Restrict Virtual Console Root Logins"
lineinfile:
dest: /etc/securetty
regexp: '^vc'
state: absent
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,14 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Set Password Hashing Algorithm in /etc/libuser.conf
lineinfile:
dest: /etc/libuser.conf
insertafter: "^.default]"
regexp: ^#?crypt_style
line: crypt_style = sha512
state: present
tags:
@ANSIBLE_TAGS@
@@ -0,0 +1,13 @@
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
- name: Set Password Hashing Algorithm in /etc/login.defs
lineinfile:
dest: /etc/login.defs
regexp: ^#?ENCRYPT_METHOD
line: ENCRYPT_METHOD SHA512
state: present
tags:
@ANSIBLE_TAGS@
Expand Up @@ -9,6 +9,7 @@
dest: /etc/ssh/sshd_config
regexp: "^Protocol [0-9]"
line: "Protocol 2"
validate: sshd -t -f %s
notify:
- reload ssh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be commented as well

tags:
Expand Down