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

Issue 22 #23

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ skip_list:
- 'schema'
- 'no-changed-when'
- 'var-spacing'
- 'fqcn-builtins'
- 'experimental'
- 'name[play]'
- 'name[casing]'
- 'name[template]'
- 'fqcn[action]'
- 'key-order[task]'
- '204'
- '305'
- '303'
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/OS.tfvars

This file was deleted.

53 changes: 0 additions & 53 deletions .github/workflows/github_networks.tf

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/github_vars.tfvars

This file was deleted.

79 changes: 56 additions & 23 deletions .github/workflows/linux_benchmark_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,34 @@ jobs:
Congrats on opening your first pull request and thank you for taking the time to help improve Ansible-Lockdown!
Please join in the conversation happening on the [Discord Server](https://discord.io/ansible-lockdown) as well.
# This workflow contains a single job called "build"
build:
playbook-test:
# The type of runner that the job will run on
runs-on: ubuntu-latest

env:
ENABLE_DEBUG: false

# Steps represent a sequence of tasks that will be executed as part of the job
ENABLE_DEBUG: ${{ vars.ENABLE_DEBUG || 'false' }}
OSVAR: AMAZON2
BENCHMARK_TYPE: CIS
# Imported as a variable by terraform
TF_VAR_repository: ${{ github.event.repository.name }}
defaults:
run:
shell: bash
working-directory: .github/workflows/github_linux_IaC

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE,
# so your job can access it
- uses: actions/checkout@v3
- name: Clone ${{ github.event.repository.name }}
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

# Pull in terraform code for linux servers
- name: Clone github IaC plan
uses: actions/checkout@v3
with:
repository: ansible-lockdown/github_linux_IaC
path: .github/workflows/github_linux_IaC

- name: Add_ssh_key
working-directory: .github/workflows
env:
Expand All @@ -59,53 +72,73 @@ jobs:
echo $PRIVATE_KEY > .ssh/github_actions.pem
chmod 600 .ssh/github_actions.pem

### Build out the server
- name: DEBUG - Show IaC files
if: env.ENABLE_DEBUG == 'true'
run: |
echo "OSVAR = $OSVAR"
echo "benchmark_type = $benchmark_type"
pwd
ls
env:
# Imported from github variables this is used to load the relvent OS.tfvars file
OSVAR: ${{ env.OSVAR }}
benchmark_type: ${{ env.BENCHMARK_TYPE }}

- name: Terraform_Init
working-directory: .github/workflows
id: init
run: terraform init
env:
# Imported from github variables this is used to load the relvent OS.tfvars file
OSVAR: ${{ env.OSVAR }}
TF_VAR_benchmark_type: ${{ env.BENCHMARK_TYPE }}

- name: Terraform_Validate
working-directory: .github/workflows
id: validate
run: terraform validate
env:
# Imported from github variables this is used to load the relvent OS.tfvars file
OSVAR: ${{ env.OSVAR }}
TF_VAR_benchmark_type: ${{ env.BENCHMARK_TYPE }}

- name: Terraform_Apply
working-directory: .github/workflows
id: apply
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: terraform apply -var-file "OS.tfvars" -var-file "github_vars.tfvars" --auto-approve -input=false
OSVAR: ${{ env.OSVAR }}
TF_VAR_benchmark_type: ${{ env.BENCHMARK_TYPE }}
run: terraform apply -var-file "github_vars.tfvars" -var-file "${OSVAR}.tfvars" --auto-approve -input=false

## Debug Section
## Debug Section
- name: DEBUG - Show Ansible hostfile
if: env.ENABLE_DEBUG == 'true'
working-directory: .github/workflows
run: cat hosts.yml

# Aws deployments taking a while to come up insert sleep or playbook fails
# Aws deployments taking a while to come up insert sleep or playbook fails

- name: Sleep for 60 seconds
run: sleep 60s
shell: bash

# Run the ansible playbook
# Run the ansible playbook
- name: Run_Ansible_Playbook
uses: arillso/action.playbook@master
uses: ansible-lockdown/action.playbook@main
with:
playbook: site.yml
inventory: .github/workflows/hosts.yml
inventory: .github/workflows/github_linux_IaC/hosts.yml
galaxy_file: collections/requirements.yml
private_key: ${{ secrets.SSH_PRV_KEY }}
# verbose: 3
env:
ANSIBLE_HOST_KEY_CHECKING: "false"
ANSIBLE_DEPRECATION_WARNINGS: "false"

# Remove test system - User secrets to keep if necessary
# Remove test system - User secrets to keep if necessary

- name: Terraform_Destroy
working-directory: .github/workflows
if: always() && env.ENABLE_DEBUG == 'false'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: terraform destroy -var-file "github_vars.tfvars" -var-file "OS.tfvars" --auto-approve -input=false
OSVAR: ${{ env.OSVAR }}
TF_VAR_benchmark_type: ${{ env.BENCHMARK_TYPE }}
run: terraform destroy -var-file "github_vars.tfvars" -var-file "${OSVAR}.tfvars" --auto-approve -input=false
82 changes: 0 additions & 82 deletions .github/workflows/main.tf

This file was deleted.

6 changes: 0 additions & 6 deletions .github/workflows/terraform.tfvars

This file was deleted.

76 changes: 0 additions & 76 deletions .github/workflows/variables.tf

This file was deleted.

Loading
Loading