Skip to content

Commit 99aabb8

Browse files
authored
Merge pull request #180 from ansible-lockdown/devel
Release of v2.0.1 to main
2 parents 6dfd156 + 52947c7 commit 99aabb8

16 files changed

Lines changed: 231 additions & 140 deletions

.github/workflows/devel_pipeline_validation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
types: [opened, reopened, synchronize]
88
branches:
99
- devel
10+
- benchmark*
1011
paths:
1112
- '**.yml'
1213
- '**.sh'
@@ -27,7 +28,7 @@
2728
jobs:
2829
# This will create messages for first time contributers and direct them to the Discord server
2930
welcome:
30-
runs-on: self-hosted
31+
runs-on: ubuntu-latest
3132

3233
steps:
3334
- uses: actions/first-interaction@main
@@ -70,7 +71,6 @@
7071
echo IAC_BRANCH=main >> $GITHUB_ENV
7172
fi
7273
73-
7474
# Pull in terraform code for linux servers
7575
- name: Clone GitHub IaC plan
7676
uses: actions/checkout@v4

.github/workflows/main_pipeline_validation.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
types: [opened, reopened, synchronize]
88
branches:
99
- main
10+
- latest
1011
paths:
1112
- '**.yml'
1213
- '**.sh'
@@ -23,17 +24,6 @@
2324
# A workflow run is made up of one or more jobs
2425
# that can run sequentially or in parallel
2526
jobs:
26-
# This will create messages for first time contributers and direct them to the Discord server
27-
welcome:
28-
runs-on: self-hosted
29-
30-
steps:
31-
- uses: actions/first-interaction@main
32-
with:
33-
repo-token: ${{ secrets.GITHUB_TOKEN }}
34-
pr-message: |-
35-
Congrats on opening your first pull request and thank you for taking the time to help improve Ansible-Lockdown!
36-
Please join in the conversation happening on the [Discord Server](https://www.lockdownenterprise.com/discord) as well.
3727

3828
# This workflow contains a single job that tests the playbook
3929
playbook-test:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ benchparse/
4343

4444
# GitHub Action/Workflow files
4545
.github/
46+
47+
# ansible-lint cache
48+
.ansible/

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ repos:
3737
exclude: .config/.gitleaks-report.json tasks/parse_etc_password
3838

3939
- repo: https://github.com/gitleaks/gitleaks
40-
rev: v8.24.0
40+
rev: v8.27.2
4141
hooks:
4242
- id: gitleaks
4343
args: ['--baseline-path', '.config/.gitleaks-report.json']
4444
exclude: .config/.secrets.baseline
4545

4646
- repo: https://github.com/ansible-community/ansible-lint
47-
rev: v25.1.3
47+
rev: v25.6.1
4848
hooks:
4949
- id: ansible-lint
5050
name: Ansible-lint
@@ -63,6 +63,6 @@ repos:
6363
- ansible-core>=2.10.1
6464

6565
- repo: https://github.com/adrienverge/yamllint.git
66-
rev: v1.36.2 # or higher tag
66+
rev: v1.37.1 # or higher tag
6767
hooks:
6868
- id: yamllint

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Mindpoint Group / Lockdown Enterprise / Lockdown Enterprise Releases
3+
Copyright (c) 2025 Mindpoint Group - A Tyto Athene Company / Ansible Lockdown
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

defaults/main.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ skip_reboot: true
1212

1313
system_is_container: false
1414

15+
# Used for audit
16+
ubtu20cis_level_1: true
17+
ubtu20cis_level_2: true
18+
19+
# Create managed not custom local_facts files
20+
create_benchmark_facts: true
21+
ansible_facts_path: /etc/ansible/facts.d
1522
## Benchmark name used by auditing control role
1623
# The audit variable found at the base
1724
benchmark: UBUNTU20-CIS
@@ -36,16 +43,12 @@ audit_run_heavy_tests: true
3643

3744
## Only run Audit do not remediate
3845
audit_only: false
39-
### As part of audit_only ###
40-
# This will enable files to be copied back to control node in audit_only mode
41-
fetch_audit_files: false
42-
# Path to copy the files to will create dir structure in audit_only mode
43-
audit_capture_files_dir: /some/location to copy to on control node
46+
4447
#############################
4548

4649
# How to retrieve audit binary
4750
# Options are copy or download - detailed settings at the bottom of this file
48-
# you will need to access to either github or the file already dowmloaded
51+
# you will need to access to either github or the file already downloaded
4952
get_audit_binary_method: download
5053

5154
## if get_audit_binary_method - copy the following needs to be updated for your environment
@@ -70,8 +73,23 @@ audit_conf_dest: "/opt"
7073
# Where the audit logs are stored
7174
audit_log_dir: '/opt'
7275

76+
## Ability to collect and take audit files moving to a centralised location
77+
# This enables the collection of the files from the host
78+
fetch_audit_output: false
79+
80+
# Method of getting,uploading the summary files
81+
## Ensure access and permissions are available for these to occur.
82+
## options are
83+
# fetch - fetches from server and moves to location on the ansible controller (could be a mount point available to controller)
84+
# copy - copies file to a location available to the managed node
85+
audit_output_collection_method: fetch
86+
87+
# Location to put the audit files
88+
audit_output_destination: /opt/audit_summaries/
89+
7390
### Goss Settings ##
7491
####### END ########
92+
7593
# We've defined complexity-high to mean that we cannot automatically remediate
7694
# the rule in question. In the future this might mean that the remediation
7795
# may fail in some cases.
@@ -85,7 +103,7 @@ ubtu20cis_audit_complex: true
85103
# We've defined disruption-high to indicate items that are likely to cause
86104
# disruption in a normal workflow. These items can be remediated automatically
87105
# but are disabled by default to avoid disruption.
88-
# Value of true runs duscruptive tasks, value of false will skip disruptive tasks
106+
# Value of true runs disruptive tasks, value of false will skip disruptive tasks
89107
ubtu20cis_disruption_high: true
90108

91109
# Show "changed" for disruptive items not remediated per disruption-high
@@ -604,7 +622,7 @@ ubtu20cis_ufw_allow_in:
604622
# Controls 3.5.3.2.1 through 3.5.3.3.4
605623
# The iptables module only writes to memory which means a reboot could revert settings
606624
# The below toggle will install iptables-persistent and save the rules in memory (/etc/iptables/rules.v4 or rules.v6)
607-
# This makes the CIS role changes permenant
625+
# This makes the CIS role changes permanent
608626
ubtu20cis_save_iptables_cis_rules: true
609627

610628
# Section 4 Control Variables
@@ -616,19 +634,19 @@ ubtu20cis_save_iptables_cis_rules: true
616634

617635
# log_level is the log level variable. This needs to be set to VERBOSE or INFO to conform to CIS standards
618636

619-
# max_auth_tries is the max number of authentication attampts per connection.
637+
# max_auth_tries is the max number of authentication attempts per connection.
620638
# This value should be 10 or less to conform to CIS standards
621639

622-
# ciphers is a comma seperated list of site approved ciphers
640+
# ciphers is a comma separated list of site approved ciphers
623641
# ONLY USE STRONG CIPHERS. Weak ciphers are listed below
624642
# DO NOT USE: 3des-cbc, aes128-cbc, aes192-cbc, and aes256-cbc
625643

626-
# MACs is the comma seperated list of site approved MAC algorithms that SSH can use during communication
644+
# MACs is the comma separated list of site approved MAC algorithms that SSH can use during communication
627645
# ONLY USE STRONG ALGORITHMS. Weak algorithms are listed below
628646
# DO NOT USE: hmac-md5, hmac-md5-96, hmac-ripemd160, hmac-sha1, hmac-sha1-96, umac-64@openssh.com, umac-128@openssh.com, hmac-md5-etm@openssh.com,
629647
# hmac-md5-96-etm@openssh.com, hmac-ripemd160-etm@openssh.com, hmac-sha1-etm@openssh.com, hmac-sha1-96-etm@openssh.com, umac-64-etm@openssh.com, umac-128-etm@openssh.com
630648

631-
# kex_algorithms is comma seperated list of the algorithms for key exchange methods
649+
# kex_algorithms is comma separated list of the algorithms for key exchange methods
632650
# ONLY USE STRONG ALGORITHMS. Weak algorithms are listed below
633651
# DO NOT USE: diffie-hellman-group1-sha1, diffie-hellman-group14-sha1, diffie-hellman-group-exchange-sha1
634652

@@ -668,7 +686,7 @@ ubtu20cis_passwd_hash_algo: sha512 # pragma: allowlist secret
668686
# pam_tally2 login options allows for audit to be removed if required
669687
ubtu20cis_pamtally2_login_opts: 'onerr=fail audit silent deny=5 unlock_time=900'
670688

671-
# ubtu20cis_pamd_pwhistory_remember is number of password chnage cycles a user can re-use a password
689+
# ubtu20cis_pamd_pwhistory_remember is number of password change cycles a user can re-use a password
672690
# This needs to be 5 or more to conform to CIS standards
673691
ubtu20cis_pamd_pwhistory_remember: 5
674692

tasks/LE_audit_setup.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
---
2-
32
- name: Pre Audit Setup | Set audit package name
43
block:
54
- name: Pre Audit Setup | Set audit package name | 64bit
5+
when: ansible_facts.machine == "x86_64"
66
ansible.builtin.set_fact:
77
audit_pkg_arch_name: AMD64
8-
when: ansible_facts.machine == "x86_64"
98

109
- name: Pre Audit Setup | Set audit package name | ARM64
10+
when: (ansible_facts.machine == "arm64" or ansible_facts.machine == "aarch64")
1111
ansible.builtin.set_fact:
1212
audit_pkg_arch_name: ARM64
13-
when: ansible_facts.machine == "aarch64"
1413

1514
- name: Pre Audit Setup | Download audit binary
15+
when: get_audit_binary_method == 'download'
1616
ansible.builtin.get_url:
1717
url: "{{ audit_bin_url }}{{ audit_pkg_arch_name }}"
1818
dest: "{{ audit_bin }}"
1919
owner: root
2020
group: root
2121
checksum: "{{ audit_bin_version[audit_pkg_arch_name + '_checksum'] }}"
22-
mode: '0555'
23-
when:
24-
- get_audit_binary_method == 'download'
22+
mode: 'u+x,go-w'
2523

2624
- name: Pre Audit Setup | Copy audit binary
25+
when: get_audit_binary_method == 'copy'
2726
ansible.builtin.copy:
28-
src: "{{ audit_bin_copy_location }}"
27+
src: "{{ audit_bin_copy_location }}/goss-linux-{{ audit_pkg_arch_name }}"
2928
dest: "{{ audit_bin }}"
30-
mode: '0555'
3129
owner: root
3230
group: root
33-
when:
34-
- get_audit_binary_method == 'copy'
31+
mode: 'u+x,go-w'

tasks/audit_only.yml

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
11
---
22

3-
- name: Audit_Only | Create local Directories for hosts
4-
ansible.builtin.file:
5-
mode: '0755'
6-
path: "{{ audit_capture_files_dir }}/{{ inventory_hostname }}"
7-
recurse: true
8-
state: directory
9-
when: fetch_audit_files
10-
delegate_to: localhost
11-
become: false
12-
13-
- name: Audit_only | Get audits from systems and put in group dir
14-
ansible.builtin.fetch:
15-
dest: "{{ audit_capture_files_dir }}/{{ inventory_hostname }}/"
16-
flat: true
17-
mode: '0644'
18-
src: "{{ pre_audit_outfile }}"
19-
when: fetch_audit_files
20-
21-
- name: Audit_only | Show Audit Summary
3+
- name: Audit_only | Fetch audit files
224
when:
5+
- fetch_audit_output
236
- audit_only
7+
ansible.builtin.import_tasks:
8+
file: fetch_audit_output.yml
9+
10+
- name: Audit_only | Show Audit Summary
11+
when: audit_only
2412
ansible.builtin.debug:
2513
msg: "{{ audit_results.split('\n') }}"
2614

27-
- name: Audit_only | Stop Playbook Audit Only selected
28-
when:
29-
- audit_only
30-
ansible.builtin.meta: end_play
15+
- name: Audit_only | Stop task for host as audit_only selected
16+
when: audit_only
17+
ansible.builtin.meta: end_host

tasks/fetch_audit_output.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
3+
# Stage to copy audit output to a centralised location
4+
5+
- name: "POST | FETCH | Fetch files and copy to controller"
6+
when: audit_output_collection_method == "fetch"
7+
ansible.builtin.fetch:
8+
src: "{{ item }}"
9+
dest: "{{ audit_output_destination }}"
10+
flat: true
11+
changed_when: true
12+
failed_when: false
13+
register: discovered_audit_fetch_state
14+
loop:
15+
- "{{ pre_audit_outfile }}"
16+
- "{{ post_audit_outfile }}"
17+
become: false
18+
19+
# Added this option for continuity but could be changed by adjusting the variable audit_conf_dest
20+
# Allowing backup to one location
21+
- name: "POST | FETCH | Copy files to location available to managed node"
22+
when: audit_output_collection_method == "copy"
23+
ansible.builtin.copy:
24+
src: "{{ item }}"
25+
dest: "{{ audit_output_destination }}"
26+
mode: 'u-x,go-wx'
27+
flat: true
28+
failed_when: false
29+
register: discovered_audit_copy_state
30+
loop:
31+
- "{{ pre_audit_outfile }}"
32+
- "{{ post_audit_outfile }}"
33+
34+
- name: "POST | FETCH | Fetch files and copy to controller | Warning if issues with fetch_audit_files"
35+
when:
36+
- (audit_output_collection_method == "fetch" and not discovered_audit_fetch_state.changed) or
37+
(audit_output_collection_method == "copy" and not discovered_audit_copy_state.changed)
38+
block:
39+
- name: "POST | FETCH | Fetch files and copy to controller | Warning if issues with fetch_audit_files"
40+
ansible.builtin.debug:
41+
msg: "Warning!! Unable to write to localhost {{ audit_output_destination }} for audit file copy"
42+
43+
- name: "POST | FETCH | Fetch files and copy to controller | Warning if issues with fetch_audit_files"
44+
vars:
45+
warn_control_id: "FETCH_AUDIT_FILES"
46+
ansible.builtin.import_tasks:
47+
file: warning_facts.yml

tasks/main.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,14 @@
8989

9090
- name: Include audit specific variables
9191
ansible.builtin.include_vars: audit.yml
92-
when:
93-
- run_audit or audit_only
94-
- setup_audit
92+
when: run_audit or audit_only or setup_audit
9593
tags:
9694
- setup_audit
9795
- run_audit
9896

9997
- name: Include pre-remediation audit tasks
10098
ansible.builtin.import_tasks: pre_remediation_audit.yml
101-
when:
102-
- run_audit or audit_only
103-
- setup_audit
99+
when: run_audit or audit_only or setup_audit
104100
tags:
105101
- run_audit
106102

@@ -181,6 +177,36 @@
181177
when:
182178
- run_audit
183179

180+
- name: Add ansible file showing Benchmark and levels applied
181+
block:
182+
- name: Create ansible facts directory
183+
ansible.builtin.file:
184+
path: "{{ ansible_facts_path }}"
185+
state: directory
186+
owner: root
187+
group: root
188+
mode: 'u=rwx,go=rx'
189+
190+
- name: Create ansible facts file
191+
ansible.builtin.template:
192+
src: etc/ansible/compliance_facts.j2
193+
dest: "{{ ansible_facts_path }}/compliance_facts.fact"
194+
owner: root
195+
group: root
196+
mode: "u-x,go-wx"
197+
when: create_benchmark_facts
198+
tags:
199+
- always
200+
- benchmark
201+
202+
- name: Fetch audit files
203+
ansible.builtin.import_tasks:
204+
file: fetch_audit_output.yml
205+
when:
206+
- fetch_audit_output
207+
- run_audit
208+
tags: always
209+
184210
- name: Show Audit Summary
185211
ansible.builtin.debug:
186212
msg: "{{ audit_results.split('\n') }}"

0 commit comments

Comments
 (0)