diff --git a/utils/remote.py b/utils/remote.py index 459518d..c36263c 100644 --- a/utils/remote.py +++ b/utils/remote.py @@ -22,8 +22,7 @@ port_increments = { "TERMINAL_URL": 6, "MC_URL": 7, "HTOP_URL": 8, - "ANSIBLE_ARA": 9, - "TERRAFORM_BLAST_RADIUS": 10 + "ANSIBLE_ARA": 9 } workspace_meta = { @@ -45,7 +44,7 @@ workspace_meta = { }, "ansible-terraform-workspace": { "port-range": 15, - "entrypoints": ["DOCS_URL", "FILEBROWSER_URL", "STATICFS_URL", "CRONICLE_URL", "UNGIT_URL", "IDE_URL", "TERMINAL_URL", "MC_URL", "HTOP_URL", "ANSIBLE_ARA", "TERRAFORM_BLAST_RADIUS"] + "entrypoints": ["DOCS_URL", "FILEBROWSER_URL", "STATICFS_URL", "CRONICLE_URL", "UNGIT_URL", "IDE_URL", "TERMINAL_URL", "MC_URL", "HTOP_URL", "ANSIBLE_ARA"] } } diff --git a/utils/terraform-report.sh b/utils/terraform-report.sh deleted file mode 100644 index 91b0114..0000000 --- a/utils/terraform-report.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -while getopts i:o: flag -do - case "${flag}" in - i) inventory=${OPTARG};; - o) output_dir=${OPTARG};; - esac -done - -if [ -z "${output_dir}" ]; then output_dir="/home/static-server/terraform-reports/"; fi -project_name=${PWD##*/} -printf '%s\n' "project name - ${project_name}" -report_dir="${output_dir}/${project_name}/$(date +"%d-%m-%Y-%H-%M-%S")" -mkdir -p "$report_dir" - -# terraform-docs -terrascan scan > ${report_dir}/terrascan.txt - -# Terraform Graph -terraform graph | dot -Tsvg > .${report_dir}/graph.svg - -# Terraform Visual -terraform plan -out=${report_dir}/plan.out -terraform show -json ${report_dir}/plan.out > ${report_dir}/plan.json -cd ${report_dir} && terraform-visual --plan ${report_dir}/plan.json - diff --git a/workspaces/ansible-terraform-workspace/Dockerfile b/workspaces/ansible-terraform-workspace/Dockerfile index 3dea056..a13ea15 100644 --- a/workspaces/ansible-terraform-workspace/Dockerfile +++ b/workspaces/ansible-terraform-workspace/Dockerfile @@ -126,5 +126,6 @@ RUN echo "------------------------------------------------------ ansible ara" \ && find /home -type f | xargs -I{} chown abc {} USER abc -COPY README.md /home/docs/docs/get-started.md + +COPY README.md /home/docs/docs/docs.md COPY ./examples/terraform-scaleway /home/terraform \ No newline at end of file diff --git a/workspaces/ansible-terraform-workspace/README.md b/workspaces/ansible-terraform-workspace/README.md index 32ffb7a..43291bd 100644 --- a/workspaces/ansible-terraform-workspace/README.md +++ b/workspaces/ansible-terraform-workspace/README.md @@ -36,12 +36,9 @@ and open [localhost:8020](http://localhost:8020) in browser ## About -The workspace contains browser-based Visual Studio Code, and other browser-based tools that make it comfortable working with dockerized -environments. +The workspace contains browser-based Visual Studio Code and multiple tools which make working with Ansible and Terraform more convenient. -[GIF] - -Workspace has the following Ansible tools installed: +**Ansible tools:** - [**Ansible Ara**](https://github.com/ansible-community/ara). Configured to track execution of all ansible playbooks, has UI. - [**Ansible-pre-commit**](https://github.com/adarnimrod/ansible-pre-commit) @@ -52,7 +49,7 @@ Workspace has the following Ansible tools installed: - [**Ansible Mitogen**](https://mitogen.networkgenomics.com/ansible_detailed.html) - [**Ansible Doctor**](https://ansible-doctor.geekdocs.de/) -Workspace has the following Terraform tools installed: +**Terraform tools:** - [**Pre-commit-terraform**](https://github.com/antonbabenko/pre-commit-terraform) - [**Blast-Radius**](https://github.com/28mm/blast-radius). Has UI, visualizes any terraform project in folder /home/terraform/. @@ -60,11 +57,11 @@ Workspace has the following Terraform tools installed: - [**Terraform Graph**](https://www.terraform.io/docs/cli/commands/graph.html) - [**Inframap**](https://github.com/cycloidio/inframap) -Workspace has the following common tools installed: +**Common tools:** - **Workspace UI** - Browser-based UI for Ansible-Terraform Workspace. Launch all workspace tools from one place. Customize to your yown needs. - [**Eclipse Theia**](https://theia-ide.org/docs/) - open source version of popular Visual Studio Code IDE. Theia is trully open-source, has -VS-Code extensions and works in browser. This means it can run inside a docker container on local machine or in cloud. +VS-Code extensions and works in browser. This means it can run inside a docker container on local machine or in cloud. For the Ansible-Terraform workspace beautiful [SynthWave '84](https://open-vsx.org/extension/RobbOwen/synthwave-vscode) theme is set by default. - [**FileBrowser**](https://github.com/filebrowser/filebrowser) - manage files and folders inside the workspace, and exchange data between local environment and the workspace - [**Cronicle**](https://github.com/jhuckaby/Cronicle) - task scheduler and runner, with a web based front-end UI. It handles both scheduled, repeating and on-demand jobs, targeting any number of worker servers, with real-time stats and live log viewer. - [**Static File Server**](https://github.com/vercel/serve) - view any static html sites as easy as if you do it on your local machine. Serve static websites easily. @@ -100,6 +97,60 @@ and dependencies. Workspace can be used and shared "as a whole", removing this d applying Terraform code (i.e. remote Terraform state), this Workspace makes it even easier, when it is deployed on the remote cloud server, and used by multiple users. + +## Ansible Features + + +## Terraform Features + +### Terraform report + +A small tool that produces several outputs from a terraform project, and visualizes terraform plan as an interactive HTML page. + +If you want to try it out yourself, create key/secret for your AWS account, open workspace and create [file with AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + +> `mkdir -p ~/.aws` +> `nano ~/.aws/credentials` + +The file `~/.aws/credentials` would look like this + +``` +[terraform] +aws_access_key_id = +aws_secret_access_key = +``` + +Clone this terraform example repo into your workspace + +> `git clone https://github.com/pvarentsov/terraform-aws-free-tier /home/project/aws-example` + +Open file `/home/project/aws-example/src/free-tier/main.tf` and comment out the part that configures S3 backend + +``` +terraform { + backend "s3" {} +} +``` + +Initialize a working Terraform directory + +> `cd /home/project/aws-example/src/free-tier && terraform init` + +Paste public ssh key (for the sake of example you can type anything) + +> `nano ./provision/access/free-tier-ec2-key.pub` + +Now you can gen erate terraform report + +> `terraform-report` + +Open Static file server and look on the generated files + +

+ Htop +

+ + ## Launch Workspace Workspaces - are merely docker containers, that's why managing workspaces is easy and intuitive - it is enough to know only docker commands, @@ -136,7 +187,7 @@ There are several ways how to work with terminal of the the ansible-terraform wo - ssh into the running the docker container (of the workspace) from your terminal

- Base-Workspace terminal + Base-Workspace terminal

*(Browser-based terminals always work under the user you started the workspace with, the default is non root user "abc")* @@ -165,7 +216,7 @@ You can work in Ubuntu terminal now. Execute the followinng command to know your Every workspace requires range of ports. If one workspace is up and running, the ports 8020-8035 are taken. -Ansible-terraform workspace itself uses 11 ports (8020-8030), but it is recommended to map several extra ports just in case. Having extra ports, +Ansible-terraform workspace itself uses 10 ports (8020-8029), but it is recommended to map several extra ports just in case. Having extra ports, you can always launch new applications on these ports, and they will be immediately exposed outside of the workspace. In order to start another workspace, you either need to stop currently runnning workspace, or to run another workspace diff --git a/workspaces/ansible-terraform-workspace/img/terminal.gif b/workspaces/ansible-terraform-workspace/img/terminal.gif new file mode 100644 index 0000000..2eb88aa Binary files /dev/null and b/workspaces/ansible-terraform-workspace/img/terminal.gif differ diff --git a/workspaces/ansible-terraform-workspace/img/terraform-report.gif b/workspaces/ansible-terraform-workspace/img/terraform-report.gif new file mode 100644 index 0000000..e8a4bb1 Binary files /dev/null and b/workspaces/ansible-terraform-workspace/img/terraform-report.gif differ diff --git a/workspaces/ansible-terraform-workspace/mkdocs/helpers.py b/workspaces/ansible-terraform-workspace/mkdocs/helpers.py index 43168ec..e6ef8ce 100644 --- a/workspaces/ansible-terraform-workspace/mkdocs/helpers.py +++ b/workspaces/ansible-terraform-workspace/mkdocs/helpers.py @@ -14,8 +14,7 @@ port_increments = { "TERMINAL_URL": 6, "MC_URL": 7, "HTOP_URL": 8, - "ANSIBLE_ARA": 9, - "TERRAFORM_BLAST_RADIUS": 10 + "ANSIBLE_ARA": 9 } # this function name should not be changed diff --git a/workspaces/ansible-terraform-workspace/mkdocs/home.md b/workspaces/ansible-terraform-workspace/mkdocs/home.md index 89b3f5c..ed71692 100644 --- a/workspaces/ansible-terraform-workspace/mkdocs/home.md +++ b/workspaces/ansible-terraform-workspace/mkdocs/home.md @@ -107,12 +107,6 @@ "name": "Ansible Ara", "image": "Ara.png", "description": "Monitor for all Ansible plays" - }, - { - "env": "TERRAFORM_BLAST_RADIUS", - "name": "Terraform Blast Radius", - "image": "Blast-radius.png", - "description": "Visualise terraform dependency graphf for a project in folder /home/terraform" } ] %} diff --git a/workspaces/ansible-terraform-workspace/supervisord-infra.conf b/workspaces/ansible-terraform-workspace/supervisord-infra.conf index 9f06c2f..63db376 100644 --- a/workspaces/ansible-terraform-workspace/supervisord-infra.conf +++ b/workspaces/ansible-terraform-workspace/supervisord-infra.conf @@ -4,7 +4,3 @@ command=/bin/sh -c " ara-manage runserver 0.0.0.0:8029 " stderr_logfile = /var/log/ara/stderr.log stdout_logfile = /var/log/ara/arastdout.log logfile_maxbytes = 1024 - -[program:blast-radius] -directory=/home/terraform -command=/bin/sh -c " blast-radius --serve --port 8030 /home/terraform "