Go Firewall Rule Self-Service – v0.04 Milestone

This update is where I have managed to get all the pieces together to form a complete Infrastructure as Code pipeline for the self-service firewall rules on the Cisco ASA. The Go firewall project incorporates the ASA API Terraform project and a GitLab pipeline.

The flow of the application in the current prototype is as follows;

  1. User goes to the firewall portal web app
  2. A new firewall rule is created
  3. The firewall rule is stored inside the Postgres DB
  4. Inside the ASA Terraform repo a branch named FirewallRules is switched to or created from the main branch
  5. The firewall rule in Terraform format is written to the main.tf file.
  6. The main.tf file is then committed and pushed to the ASA Terraform repo in GitLab
  7. The GitLab pipeline is skipped from running automatically, allowing for numerous firewall rules to be created
  8. The GitLab pipeline can be manually run for the branch FirewallRules
  9. Running the pipeline collects all the new Terraform firewall rules and will perform the operations; fmt, validate, build automatically.
  10. The administrator of the repo can review the build and ensure that the config is acceptable and can create a Merge Request to commit the changes from the FirewallRules branch to the main branch. This is a manual operation in the pipeline named merge_main.
  11. When the new Merge Request is made, this needs to be manually merged, giving another opportunity to compare the configuration changes.
  12. Once merged, the pipeline is run again (fmt, validate, build) and then a manual button to deploy the new configuration to the ASA firewall.
  13. The process can be repeated.

The Process Illustrated

1-2. User Creates New Rule in Portal

The firewall portal is running locally on my machine at http://127.0.0.1:8010/

3. Firewall Rules Stored in Postgres DB

Database running locally contains all the firewall rules

3-6. Git Commands to Create New Branch and Push

Inside the ASA Terraform repo a branch named FirewallRules is switched to or created from the main branch

7. The GitLab Pipeline is Skipped

The commit message contains [ci skip], which GitLab uses to skip the automatic pipeline run.

8-10. Manually Run Pipeline for FirewallRules Branch & Create MR

The pipeline must be run for all of the new firewall rules. The pipeline is run against the branch FirewallRules.

The Merge Request is created and can be reviewed and merged into main

11-12. Pipeline to Deploy New Rules

When the new firewall rule config has been merged into the main branch, automatically a pipeline is started. The admin may review the build step and then manually deploy the new rule config to the firewalls.

Terraform moves around some of the configuration, so it looks in the plan as if more is changing than really is. All that really counts is that there are 0 destroy and 1 add.

ASA Rules present through the Firewall Portal App and some GitLab management.

Future Improvements

  1. The ASA Terraform repo must already be downloaded onto the same host as where the Go firewall portal is running from
  2. The host must have the SSH private key to interact with the ASA Terraform GitLab repo
  3. The web application must wait for the Git commands to run before it displays the firewall summary page to indicate that the firewall addition has been a success.
  4. There are a couple of unnecessary steps in the pipeline

Problems

  1. GitLab variables needed to be unprotected so they can be used on my FirewallRules unprotected branch
  2. GitLab runner for the project needed to have the shared
  3. GNS3 Cisco ASA required 4096MB of RAM, up from 2048MB to avoid crashes

Leave a Comment

Your email address will not be published. Required fields are marked *