Skip to content

Commit f98b63a

Browse files
authored
Merge pull request #137 from ansible-lockdown/devel
Benchmark 1.7 and issue fixes
2 parents 64be48d + 8da1b6e commit f98b63a

28 files changed

Lines changed: 512 additions & 468 deletions

.ansible-lint

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
---
12
parseable: true
23
quiet: true
34
skip_list:
4-
- '204'
5-
- '305'
6-
- '303'
7-
- '403'
8-
- '306'
9-
- '602'
10-
- '208'
5+
- 'schema'
6+
- 'no-changed-when'
7+
- 'var-spacing'
8+
- 'fqcn-builtins'
9+
- 'experimental'
10+
- 'name[casing]'
11+
- 'name[template]'
12+
- '204'
13+
- '305'
14+
- '303'
15+
- '403'
16+
- '306'
17+
- '602'
18+
- '208'
1119
use_default_rules: true
1220
verbosity: 0
Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,53 @@
11
resource "aws_vpc" "Main" {
22
cidr_block = var.main_vpc_cidr
3-
tags = var.instance_tags
3+
instance_tenancy = "default"
4+
tags = {
5+
Environment = "${var.environment}"
6+
Name = "${var.namespace}-VPC"
7+
}
48
}
59

610
resource "aws_internet_gateway" "IGW" {
711
vpc_id = aws_vpc.Main.id
812
tags = {
9-
Name = "${var.namespace}-IGW"
13+
Environment = "${var.environment}"
14+
Name = "${var.namespace}-IGW"
1015
}
1116
}
17+
18+
resource "aws_subnet" "publicsubnets" {
19+
vpc_id = aws_vpc.Main.id
20+
cidr_block = var.public_subnets
21+
availability_zone = var.availability_zone
22+
tags = {
23+
Environment = "${var.environment}"
24+
Name = "${var.namespace}-pubsub"
25+
}
26+
}
27+
28+
resource "aws_subnet" "Main" {
29+
vpc_id = aws_vpc.Main.id
30+
availability_zone = var.availability_zone
31+
cidr_block = var.private_subnets
32+
tags = {
33+
Environment = "${var.environment}"
34+
Name = "${var.namespace}-prvsub"
35+
}
36+
}
37+
38+
resource "aws_route_table" "PublicRT" {
39+
vpc_id = aws_vpc.Main.id
40+
route {
41+
cidr_block = "0.0.0.0/0"
42+
gateway_id = aws_internet_gateway.IGW.id
43+
}
44+
tags = {
45+
Environment = "${var.environment}"
46+
Name = "${var.namespace}-publicRT"
47+
}
48+
}
49+
50+
resource "aws_route_table_association" "rt_associate_public" {
51+
subnet_id = aws_subnet.Main.id
52+
route_table_id = aws_route_table.PublicRT.id
53+
}

.github/workflows/github_vars.tfvars

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
// Declared in variables.tf
44
//
55

6-
namespace = "github_actions"
6+
namespace = "github_actions"
7+
environment = "lockdown_github_repo_workflow"
78

89
// Matching pair name found in AWS for keypairs PEM key
910
ami_key_pair_name = "github_actions"
1011
main_vpc_cidr = "172.22.0.0/24"
1112
public_subnets = "172.22.0.128/26"
12-
private_subnets = "172.22.0.192/26"
13+
private_subnets = "172.22.0.192/26"

.github/workflows/linux_benchmark_testing.yml

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is a basic workflow to help you get started with Actions
2-
2+
---
33
name: linux_benchmark_pipeline
44

55
# Controls when the action will run.
@@ -23,26 +23,26 @@ on:
2323
jobs:
2424
# This will create messages for first time contributers and direct them to the Discord server
2525
welcome:
26-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-latest
2727

28-
steps:
29-
- uses: actions/first-interaction@v1.1.0
30-
with:
31-
repo-token: ${{ secrets.GITHUB_TOKEN }}
32-
pr-message: |-
33-
Congrats on opening your first pull request and thank you for taking the time to help improve Ansible-Lockdown!
34-
Please join in the conversation happening on the [Discord Server](https://discord.gg/JFxpSgPFEJ) as well.
28+
steps:
29+
- uses: actions/first-interaction@main
30+
with:
31+
repo-token: ${{ secrets.GITHUB_TOKEN }}
32+
pr-message: |-
33+
Congrats on opening your first pull request and thank you for taking the time to help improve Ansible-Lockdown!
34+
Please join in the conversation happening on the [Discord Server](https://discord.gg/JFxpSgPFEJ) as well.
3535
# This workflow contains a single job called "build"
3636
build:
3737
# The type of runner that the job will run on
3838
runs-on: ubuntu-latest
3939

40-
env:
40+
env:
4141
ENABLE_DEBUG: false
4242

4343
# Steps represent a sequence of tasks that will be executed as part of the job
4444
steps:
45-
# Checks-out your repository under $GITHUB_WORKSPACE,
45+
# Checks-out your repository under $GITHUB_WORKSPACE,
4646
# so your job can access it
4747
- uses: actions/checkout@v2
4848
with:
@@ -75,46 +75,37 @@ jobs:
7575
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
7676
run: terraform apply -var-file "OS.tfvars" -var-file "github_vars.tfvars" --auto-approve -input=false
7777

78-
## Debug Section
78+
## Debug Section
7979
- name: DEBUG - Show Ansible hostfile
8080
if: env.ENABLE_DEBUG == 'true'
8181
working-directory: .github/workflows
8282
run: cat hosts.yml
8383

84-
# Centos 7 images take a while to come up insert sleep or playbook fails
85-
86-
- name: Check if test os is rhel7
87-
working-directory: .github/workflows
88-
id: test_os
89-
run: >-
90-
echo "::set-output name=RHEL7::$(
91-
grep -c RHEL7 OS.tfvars
92-
)"
84+
# Aws deployments taking a while to come up insert sleep or playbook fails
9385

94-
- name: if RHEL7 - Sleep for 60 seconds
95-
if: steps.test_os.outputs.RHEL7 >= 1
86+
- name: Sleep for 60 seconds
9687
run: sleep 60s
9788
shell: bash
9889

99-
# Run the ansible playbook
90+
# Run the ansible playbook
10091
- name: Run_Ansible_Playbook
10192
uses: arillso/action.playbook@master
10293
with:
10394
playbook: site.yml
10495
inventory: .github/workflows/hosts.yml
10596
galaxy_file: collections/requirements.yml
10697
private_key: ${{ secrets.SSH_PRV_KEY }}
107-
# verbose: 3
98+
# verbose: 3
10899
env:
109100
ANSIBLE_HOST_KEY_CHECKING: "false"
110101
ANSIBLE_DEPRECATION_WARNINGS: "false"
111102

112-
# Remove test system - User secrets to keep if necessary
103+
# Remove test system - User secrets to keep if necessary
113104

114105
- name: Terraform_Destroy
115106
working-directory: .github/workflows
116107
if: always() && env.ENABLE_DEBUG == 'false'
117108
env:
118109
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
119110
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
120-
run: terraform destroy -var-file "OS.tfvars" -var-file "github_vars.tfvars" --auto-approve -input=false
111+
run: terraform destroy -var-file "github_vars.tfvars" -var-file "OS.tfvars" --auto-approve -input=false

.github/workflows/main.tf

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ provider "aws" {
55

66
// Create a security group with access to port 22 and port 80 open to serve HTTP traffic
77

8-
data "aws_vpc" "default" {
9-
default = true
10-
}
11-
128
resource "random_id" "server" {
139
keepers = {
1410
# Generate a new id each time we switch to a new AMI id
@@ -19,8 +15,8 @@ resource "random_id" "server" {
1915
}
2016

2117
resource "aws_security_group" "github_actions" {
22-
name = "${var.namespace}-${random_id.server.hex}"
23-
vpc_id = data.aws_vpc.default.id
18+
name = "${var.namespace}-${random_id.server.hex}-SG"
19+
vpc_id = aws_vpc.Main.id
2420

2521
ingress {
2622
from_port = 22
@@ -43,6 +39,7 @@ resource "aws_security_group" "github_actions" {
4339
cidr_blocks = ["0.0.0.0/0"]
4440
}
4541
tags = {
42+
Environment = "${var.environment}"
4643
Name = "${var.namespace}-SG"
4744
}
4845
}
@@ -51,11 +48,13 @@ resource "aws_security_group" "github_actions" {
5148

5249
resource "aws_instance" "testing_vm" {
5350
ami = var.ami_id
51+
availability_zone = var.availability_zone
5452
associate_public_ip_address = true
5553
key_name = var.ami_key_pair_name # This is the key as known in the ec2 key_pairs
5654
instance_type = var.instance_type
5755
tags = var.instance_tags
5856
vpc_security_group_ids = [aws_security_group.github_actions.id]
57+
subnet_id = aws_subnet.Main.id
5958
root_block_device {
6059
delete_on_termination = true
6160
}
@@ -80,4 +79,3 @@ resource "local_file" "inventory" {
8079
audit_git_version: devel
8180
EOF
8281
}
83-

.github/workflows/test.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@ RHEL7=$(grep -c RHEL7 OS.tfvars)
22
if [ `echo $?` != 0 ]; then
33
exit 0
44
fi
5-
6-

.github/workflows/variables.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ variable "aws_region" {
66
type = string
77
}
88

9+
variable "availability_zone" {
10+
description = "List of availability zone in the region"
11+
default = "us-east-1b"
12+
type = string
13+
}
14+
915
variable "instance_type" {
1016
description = "EC2 Instance Type"
1117
default = "t3.micro"
@@ -47,6 +53,11 @@ variable "namespace" {
4753
type = string
4854
}
4955

56+
variable "environment" {
57+
description = "Env Name used across all tags"
58+
type = string
59+
}
60+
5061
// taken from github_vars.tfvars &
5162

5263
variable "main_vpc_cidr" {
@@ -62,4 +73,4 @@ variable "public_subnets" {
6273
variable "private_subnets" {
6374
description = "private subnet cidr block"
6475
type = string
65-
}
76+
}

.yamllint

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ rules:
1414
spaces: 4
1515
# Requiring consistent indentation within a file, either indented or not
1616
indent-sequences: consistent
17-
truthy: disable
17+
level: error
1818
braces:
1919
max-spaces-inside: 1
2020
level: error
2121
brackets:
2222
max-spaces-inside: 1
2323
level: error
2424
line-length: disable
25+
key-duplicates: enable
26+
new-line-at-end-of-file: enable
27+
new-lines:
28+
type: unix
29+
trailing-spaces: enable
30+
truthy:
31+
allowed-values: ['true', 'false']
32+
check-keys: false

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# TESTS
2+
3+
all: yamllint
4+
5+
yamllint:
6+
git ls-files "*.yml"|xargs yamllint
7+
8+
requirements:
9+
@echo 'Python dependencies:'
10+
@cat requirements.txt
11+
pip install -r requirements.txt

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
Configure a RHEL/Rocky 8 system to be DISA STIG compliant. All findings will be audited by default. Non-disruptive CAT I, CAT II, and CAT III findings will be corrected by default. Disruptive finding remediation can be enabled by setting `rhel8stig_disruption_high` to `yes`.
88

9-
This role is based on RHEL 8 DISA STIG: [Version 1, Rel 6 released on April 27, 2022](https://dl.dod.cyber.mil/wp-content/uploads/stigs/zip/U_RHEL_8_V1R6_STIG.zip).
9+
This role is based on RHEL 8 DISA STIG: [Version 1, Rel 7 released on July 27, 2022](https://dl.dod.cyber.mil/wp-content/uploads/stigs/zip/U_RHEL_8_V1R7_STIG.zip).
1010

1111
## Join us
1212

13-
On our [Discord Server](https://discord.gg/JFxpSgPFEJ) to ask questions, discuss features, or just chat with other Ansible-Lockdown users
13+
On our [Discord Server](https://discord.io/ansible-lockdown) to ask questions, discuss features, or just chat with other Ansible-Lockdown users
1414

1515
## Updating
1616

@@ -45,7 +45,7 @@ Refer to [RHEL8-STIG-Audit](https://github.com/ansible-lockdown/RHEL8-STIG-Audit
4545
- [Tower User Guide](https://docs.ansible.com/ansible-tower/latest/html/userguide/index.html)
4646
- [Ansible Community Info](https://docs.ansible.com/ansible/latest/community/index.html)
4747
- Functioning Ansible and/or Tower Installed, configured, and running. This includes all of the base Ansible/Tower configurations, needed packages installed, and infrastructure setup.
48-
- Please read through the tasks in this role to gain an understanding of what each control is doing. Some of the tasks are disruptive and can have unintended consiquences in a live production system. Also familiarize yourself with the variables in the defaults/main.yml file or the [Main Variables Wiki Page](https://github.com/ansible-lockdown/RHEL8-STIG/wiki/Main-Variables).
48+
- Please read through the tasks in this role to gain an understanding of what each control is doing. Some of the tasks are disruptive and can have unintended consequences in a live production system. Also familiarize yourself with the variables in the defaults/main.yml file or the [Main Variables Wiki Page](https://github.com/ansible-lockdown/RHEL8-STIG/wiki/Main-Variables).
4949

5050
## Documentation
5151

@@ -149,7 +149,7 @@ uses:
149149

150150
If adopting stig rule RHEL-08-040134
151151

152-
This will affect cloud init as per https://bugs.launchpad.net/cloud-init/+bug/1839899
152+
This will affect cloud init as per [bug 1839899](https://bugs.launchpad.net/cloud-init/+bug/1839899)
153153

154154
## Support
155155

0 commit comments

Comments
 (0)