diff --git a/.gitignore b/.gitignore index 231ed27..7a87922 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,6 @@ env.bak/ venv.bak/ env.d/development/* !env.d/development/*.dist -env.d/terraform # npm node_modules @@ -59,11 +58,6 @@ src/frontend/tsclient # Logs *.log -# Terraform -.terraform -*.tfstate -*.tfstate.backup - # Test & lint .coverage coverage.json diff --git a/bin/_config.sh b/bin/_config.sh index d5d6106..73ceb05 100644 --- a/bin/_config.sh +++ b/bin/_config.sh @@ -5,7 +5,6 @@ set -eo pipefail REPO_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd)" UNSET_USER=0 -TERRAFORM_DIRECTORY="./env.d/terraform" COMPOSE_FILE="${REPO_DIR}/docker-compose.yml" COMPOSE_PROJECT="people" @@ -92,66 +91,3 @@ function _dc_exec() { function _django_manage() { _dc_run "app-dev" python manage.py "$@" } - -# _set_openstack_project: select an OpenStack project from the openrc files defined in the -# terraform directory. -# -# usage: _set_openstack_project -# -# If necessary the script will prompt the user to choose a project from those available -function _set_openstack_project() { - - declare prompt - declare -a projects - declare -i default=1 - declare -i choice=0 - declare -i n_projects - - # List projects by looking in the "./env.d/terraform" directory - # and store them in an array - read -r -a projects <<< "$( - find "${TERRAFORM_DIRECTORY}" -maxdepth 1 -mindepth 1 -type d | - sed 's|'"${TERRAFORM_DIRECTORY}\/"'||' | - xargs - )" - nb_projects=${#projects[@]} - - if [[ ${nb_projects} -le 0 ]]; then - echo "There are no OpenStack projects defined..." >&2 - echo "To add one, create a subdirectory in \"${TERRAFORM_DIRECTORY}\" with the name" \ - "of your project and copy your \"openrc.sh\" file into it." >&2 - exit 10 - fi - - if [[ ${nb_projects} -gt 1 ]]; then - prompt="Select an OpenStack project to target:\\n" - for (( i=0; i&2 echo "Invalid choice ${choice} (should be <= ${nb_projects})") - exit 11 - fi - - if [[ ${choice} -le 0 ]]; then - choice=${default} - fi - fi - - project=${projects[$((choice-1))]} - # Check that the openrc.sh file exists for this project - if [ ! -f "${TERRAFORM_DIRECTORY}/${project}/openrc.sh" ]; then - (>&2 echo "Missing \"openrc.sh\" file in \"${TERRAFORM_DIRECTORY}/${project}\". Check documentation.") - exit 12 - fi - - echo "${project}" -} diff --git a/bin/state b/bin/state deleted file mode 100755 index 8188385..0000000 --- a/bin/state +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -source "$(dirname "${BASH_SOURCE[0]}")/_config.sh" - -project=$(_set_openstack_project) -echo "Using \"${project}\" project..." - -source "${TERRAFORM_DIRECTORY}/${project}/openrc.sh" - -# Run Terraform commands in the Hashicorp docker container via docker compose -# shellcheck disable=SC2068 -DOCKER_USER="$(id -u):$(id -g)" \ - PROJECT="${project}" \ - docker compose run --rm \ - -e OS_AUTH_URL \ - -e OS_IDENTITY_API_VERSION \ - -e OS_USER_DOMAIN_NAME \ - -e OS_PROJECT_DOMAIN_NAME \ - -e OS_TENANT_ID \ - -e OS_TENANT_NAME \ - -e OS_USERNAME \ - -e OS_PASSWORD \ - -e OS_REGION_NAME \ - terraform-state "$@" diff --git a/bin/terraform b/bin/terraform deleted file mode 100755 index a871a0c..0000000 --- a/bin/terraform +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail - -source "$(dirname "${BASH_SOURCE[0]}")/_config.sh" - -project=$(_set_openstack_project) -echo "Using \"${project}\" project..." - -source "${TERRAFORM_DIRECTORY}/${project}/openrc.sh" - -# Run Terraform commands in the Hashicorp docker container via docker compose -# shellcheck disable=SC2068 -DOCKER_USER="$(id -u):$(id -g)" \ - PROJECT="${project}" \ - docker compose run --rm \ - -e OS_AUTH_URL \ - -e OS_IDENTITY_API_VERSION \ - -e OS_USER_DOMAIN_NAME \ - -e OS_PROJECT_DOMAIN_NAME \ - -e OS_TENANT_ID \ - -e OS_TENANT_NAME \ - -e OS_USERNAME \ - -e OS_PASSWORD \ - -e OS_REGION_NAME \ - -e TF_VAR_user_name \ - terraform "$@" diff --git a/docker-compose.yml b/docker-compose.yml index df185a1..914fc6a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -117,22 +117,6 @@ services: volumes: - ".:/app" - terraform-state: - image: hashicorp/terraform:1.6 - environment: - - TF_WORKSPACE=${PROJECT:-} # avoid env conflict in local state - user: ${DOCKER_USER:-1000} - working_dir: /app - volumes: - - ./src/terraform/create_state_bucket:/app - - terraform: - image: hashicorp/terraform:1.6 - user: ${DOCKER_USER:-1000} - working_dir: /app - volumes: - - ./src/terraform:/app - kc_postgresql: image: postgres:14.3 ports: