Skip to content
Snippets Groups Projects
Commit 73ac8c69 authored by MUNIER Florian's avatar MUNIER Florian
Browse files

Merge branch 'master' of...

Merge branch 'master' of gitlab.imt-atlantique.fr:f21munie/projet_terraform_ansible_k8s into rebond_bastion
parents f43e5bbc b0f08d23
No related branches found
No related tags found
No related merge requests found
Pipeline #14577 canceled
stages: # List of stages for jobs, and their order of execution
- test
- init
- plan
- apply
- destroy
- on_failure
- deploy
image:
name: "hashicorp/terraform:latest"
entrypoint:
- /usr/bin/env
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
tflint:
image:
name: wata727/tflint:latest
entrypoint:
- "/usr/bin/env"
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
stage: test
artifacts:
paths:
- tflint
script:
- mkdir tflint
- tflint -v
- tflint > tflint/result_tflint.txt || exit_code=0
.lint_ansible:
image: python:3.9
stage: test
tags:
- ms-icd
yamllint:
extends: .lint_ansible
artifacts:
paths:
- yamllint
script:
- mkdir yamllint
- pip install yamllint
- yamllint Ansible/* > yamllint/result_yamllint.txt || exit_code=0
ansible_lint:
extends: .lint_ansible
artifacts:
paths:
- ansible_lint
script:
- mkdir ansible_lint
- pip install ansible-lint
- ansible-lint Ansible/* > ansible_lint/result_ansible_lint.txt || exit_code=0
init_step:
stage: init
only:
- master
script:
- source $OPENRC
- env | grep OS_
- cd Terraform
- terraform init
artifacts:
name: "init_step:${CI_JOB_ID}"
when: "on_success"
expire_in: "6h"
paths:
- ./Terraform/.terraform/
- ./Terraform/.terraform.lock.hcl/
plan_step:
stage: plan
only:
- master
script:
- cd Terraform
- terraform plan -out=tfplan
artifacts:
name: "plan_step:${CI_JOB_ID}"
when: "on_success"
expire_in: "6h"
paths:
- ./Terraform/tfplan
dependencies:
- init_step
apply_step:
stage: apply
only:
- master
before_script:
- python3 -m venv ./venv/ansible
- source ./venv/ansible/bin/activate
- pip install ansible
script:
- cd Terraform
- terraform apply -input=false tfplan
dependencies:
- init_step
- plan_step
artifacts:
name: "apply_step:${CI_JOB_ID}"
when: on_success
expire_in: "6h"
paths:
- ./Terraform/tfplan
- .ssh/
- ./Terraform/ip_files/
#- ./hosts.ini
destroy_step:
stage: destroy
only:
- master
script:
- cd Terraform
- terraform destroy -auto-approve
when: manual
dependencies:
- init_step
- plan_step
- apply_step
destroy_ansible:
stage: destroy
tags:
- deploy-runner
when: manual
before_script:
- source ./venv/ansible/bin/activate
script:
- ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i Ansible/hosts.ini Ansible/destroy.yml
- deactivate
dependencies:
- apply_step
destroy_on_failure:
stage: on_failure
only:
- master
script:
- cd Terraform
- terraform destroy -auto-approve
when: on_failure
dependencies:
- init_step
- plan_step
- apply_step
pages:
image: python:3.8-buster
stage: deploy
tags:
- ms-icd
artifacts:
paths:
- public
dependencies:
- yamllint
- ansible_lint
script:
- mkdir public
- cp yamllint/result_yamllint.txt public
- cp ansible_lint/result_ansible_lint.txt public
- echo "<h1>Résultats des tests</h1>" > public/index.html
- echo "<ul><li><a href="result_yamllint.txt">Résultats des tests lint yamlint</a></li>
<li><a href="result_ansible_lint.txt">Résultats des tests lint ansible_lint</a></li></ul>" >> public/index.html
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment