Update circleci config according to deployment-terraform changes
This commit is contained in:
parent
abb1daaa51
commit
44a71a8402
|
@ -1,5 +1,36 @@
|
|||
version: 2
|
||||
jobs:
|
||||
preconf:
|
||||
docker:
|
||||
- image: poanetwork/terraform-prep
|
||||
working_directory: ~/deployment-terraform/azure
|
||||
environment:
|
||||
ANSIBLE_AZURE_AUTH_SOURCE: env
|
||||
|
||||
steps:
|
||||
- run:
|
||||
name: Generate shared workspace folder
|
||||
command: mkdir -p /tmp/workspace
|
||||
|
||||
- run:
|
||||
name: Set all.yml config
|
||||
command: echo $config_file | base64 --decode > /tmp/workspace/all.yml
|
||||
|
||||
- run:
|
||||
name: set id_rsa.pub
|
||||
command: echo $pub_key > /tmp/workspace/id_rsa.pub
|
||||
|
||||
- run:
|
||||
name: Generate unique prefix for this build
|
||||
command: head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5 | tee /tmp/workspace/prefix
|
||||
|
||||
- persist_to_workspace:
|
||||
root: /tmp/workspace
|
||||
paths:
|
||||
- all.yml
|
||||
- prefix
|
||||
- id_rsa.pub
|
||||
|
||||
build:
|
||||
docker:
|
||||
- image: poanetwork/terraform-prep
|
||||
|
@ -10,33 +41,41 @@ jobs:
|
|||
steps:
|
||||
- run:
|
||||
command: cd ~ && rm -R ~/deployment-terraform/ && git clone $terraform_repo ~/deployment-terraform/
|
||||
|
||||
- run:
|
||||
command: git checkout $terraform_branch
|
||||
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace/
|
||||
|
||||
- run:
|
||||
name: adjust configs
|
||||
command: echo $config_file | base64 --decode > ~/deployment-terraform/azure/group_vars/all.yml
|
||||
name: Set unique prefix for this build
|
||||
command: echo 'export tf_prefix=tf_$(cat /tmp/workspace/prefix)_' >> $BASH_ENV
|
||||
|
||||
- run:
|
||||
name: Copy all.yml file to appropriate folder
|
||||
command: cp /tmp/workspace/all.yml ~/deployment-terraform/azure/group_vars/all.yml
|
||||
|
||||
- run:
|
||||
name: set id_rsa.pub
|
||||
command: echo $pub_key > ~/deployment-terraform/azure/id_rsa.pub
|
||||
|
||||
- run:
|
||||
name: deploy infra
|
||||
command: bash -c "ansible-playbook site.yml -e 'terraform_location=/usr/local/bin/terraform' -e 'backend=true' $build_attr"
|
||||
name: Deploy infra
|
||||
command: bash -c "ansible-playbook site.yml -e 'PUB_KEY_STORE=/tmp/workspace/id_rsa.pub' -e 'terraform_location=/usr/local/bin/terraform' -e 'backend=true' -e 'tf_prefix=$tf_prefix' $build_attr"
|
||||
no_output_timeout: 2000
|
||||
|
||||
- run:
|
||||
name: Save artifacts
|
||||
command: bash -c "ansible-playbook -i ~/deployment-terraform/azure/outputs/latest_deploy_hosts download_outputs.yml -t build -e 'destination=/tmp/artifacts/' -e 'terraform_location=/usr/local/bin/terraform' $build_attr"
|
||||
command: bash -c "ansible-playbook -i ~/deployment-terraform/azure/outputs/latest_deploy_hosts download_outputs.yml -t build -e 'PUB_KEY_STORE=/tmp/workspace/id_rsa.pub' -e 'destination=/tmp/artifacts/' -e 'terraform_location=/usr/local/bin/terraform' $build_attr"
|
||||
|
||||
- run:
|
||||
name: Save latest hosts output && build prefix
|
||||
command: cp ~/deployment-terraform/azure/outputs/latest_deploy_hosts /tmp/workspace/hosts && cp /tmp/workspace/prefix /tmp/artifacts/prefix
|
||||
|
||||
- store_artifacts:
|
||||
path: /tmp/artifacts
|
||||
|
||||
- persist_to_workspace:
|
||||
root: ~/deployment-terraform/azure/outputs/
|
||||
root: /tmp/workspace
|
||||
paths:
|
||||
- latest_deploy_hosts
|
||||
- hosts
|
||||
|
||||
test:
|
||||
docker:
|
||||
|
@ -51,24 +90,27 @@ jobs:
|
|||
command: git checkout $terraform_branch
|
||||
|
||||
- attach_workspace:
|
||||
at: /tmp/hosts/
|
||||
at: /tmp/workspace/
|
||||
|
||||
- run:
|
||||
name: adjust configs
|
||||
command: echo $config_file | base64 --decode > ~/deployment-terraform/azure/group_vars/all.yml
|
||||
|
||||
name: Copy all.yml file to appropriate folder
|
||||
command: cp /tmp/workspace/all.yml ~/deployment-terraform/azure/group_vars/all.yml
|
||||
|
||||
- run:
|
||||
name: set id_rsa.pub
|
||||
command: echo $pub_key > ~/deployment-terraform/azure/id_rsa.pub
|
||||
name: Fetch pre-defined prefix to environmental variable
|
||||
command: echo 'export tf_prefix=tf_$(cat /tmp/workspace/prefix)_' >> $BASH_ENV
|
||||
|
||||
- run:
|
||||
name: check network
|
||||
command: bash -c "ansible-playbook tests.yml -i /tmp/hosts/latest_deploy_hosts -e 'terraform_location=/usr/local/bin/terraform' -e 'backend=true' $tests_attr"
|
||||
|
||||
command: bash -c "ansible-playbook tests.yml -i /tmp/workspace/hosts -e 'PUB_KEY_STORE=/tmp/workspace/id_rsa.pub' -e 'terraform_location=/usr/local/bin/terraform' -e 'tf_prefix=$tf_prefix' -e 'backend=true' $tests_attr"
|
||||
|
||||
- run:
|
||||
name: Save artifacts
|
||||
command: bash -c "ansible-playbook -i /tmp/hosts/latest_deploy_hosts download_outputs.yml -t tests -e 'destination=/tmp/artifacts/' -e 'terraform_location=/usr/local/bin/terraform' $tests_attr"
|
||||
command: bash -c "ansible-playbook -i /tmp/workspace/hosts download_outputs.yml -t tests -e 'destination=/tmp/artifacts/' -e 'PUB_KEY_STORE=/tmp/workspace/id_rsa.pub' -e 'tf_prefix=$tf_prefix' -e 'terraform_location=/usr/local/bin/terraform' $tests_attr"
|
||||
|
||||
- store_test_results:
|
||||
path: /tmp/artifacts
|
||||
|
||||
- store_artifacts:
|
||||
path: /tmp/artifacts
|
||||
|
||||
|
@ -86,29 +128,37 @@ jobs:
|
|||
- run:
|
||||
command: git checkout $terraform_branch
|
||||
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace/
|
||||
|
||||
- run:
|
||||
name: adjust configs
|
||||
command: echo $config_file | base64 --decode > ~/deployment-terraform/azure/group_vars/all.yml
|
||||
|
||||
- run:
|
||||
name: set id_rsa.pub
|
||||
command: echo $pub_key > ~/deployment-terraform/azure/id_rsa.pub
|
||||
name: Fetch pre-defined prefix to environmental variable
|
||||
command: echo 'export tf_prefix=tf_$(cat /tmp/workspace/prefix)_' >> $BASH_ENV
|
||||
|
||||
- run:
|
||||
name: Copy all.yml file to appropriate folder
|
||||
command: cp /tmp/workspace/all.yml ~/deployment-terraform/azure/group_vars/all.yml
|
||||
|
||||
- run:
|
||||
name: destroy infra
|
||||
command: bash -c "ansible-playbook destroy.yml -e 'terraform_location=/usr/local/bin/terraform' -e 'backend=true' $destroy_attr"
|
||||
command: bash -c "ansible-playbook destroy.yml -e 'PUB_KEY_STORE=/tmp/workspace/id_rsa.pub' -e 'tf_prefix='$tf_prefix -e 'terraform_location=/usr/local/bin/terraform' -e 'backend=true' -e 'tf_prefix=$tf_prefix' $destroy_attr"
|
||||
no_output_timeout: 2000
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
test_and_destroy:
|
||||
full:
|
||||
jobs:
|
||||
- build
|
||||
- preconf
|
||||
- build:
|
||||
requires:
|
||||
- preconf
|
||||
- test:
|
||||
requires:
|
||||
- build
|
||||
- approve_destroy:
|
||||
type: approval
|
||||
requires:
|
||||
- preconf
|
||||
- destroy:
|
||||
requires:
|
||||
- approve_destroy
|
||||
|
|
Loading…
Reference in New Issue