Hello i have a pipeline. I have also 2 script in my code deploy_terraform.sh et deploy_ansible.sh.
For now i want that it do only 2 things ![]()
- stage deploy-dev-terraform
- stage deploy-dev-ansible
In the first stage it creates ssh keys on the runner and launch a script that creates infrastructures in GCP for my app, several vm, network, …
In every VM it copies the ssh keys created on the runner so that they possess metadata, and so i can create a connexion with ansible later.
In the second stage i want to create the file inventory.ini and connect to my vm with ansible so that i can configure the servers.
My problem is : When i do 2 stages for thos 2 scripts, the problem is that stages in runners are not persistant, so when i want to connect with ansible the elements are no longer present in the second stage, so the pipeline in the seconde stage go on errors.

But when i put all of this in one stage i have no problem.

How to keep persistance between the 2 stages?
default:
tags:
- runner_test
stages:
- deploy-dev-terraform
- deploy-dev-ansible
#_________ ETAPE 1 - Déploiement des VM sur GCP via terraform pour l'environement de dév __________#
deploy_dev_terraform:
stage: deploy-dev-terraform
image : ubuntu-personalise
before_script:
- ssh-keygen -t rsa -b 2048 -f "$HOME/.ssh/id_rsa" -N ""
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
- gcloud auth activate-service-account --key-file=.secure_files/credentials1.json
script:
- mkdir ./environment-dev/private
- cp .secure_files/credentials1.json ./environment-dev/private/credentials1.json
- export GOOGLE_APPLICATION_CREDENTIALS=/builds/$GITLAB_USER_LOGIN/projet_app_devops/environment-dev/private/credentials1.json
- cd ./environment-dev/scripts
- echo "Déploiement sur l'environnement de développement"
- chmod +x deploy_terraform.sh
- ./deploy_terraform.sh
# - chmod +x deploy_ansible.sh
# - ./deploy_ansible.sh
#_________ ETAPE 2 - Configuration des serveurs VM via ansible __________#
deploy_dev_ansible:
stage: deploy-dev-ansible
image : ubuntu-personalise
script:
- cd ./environment-dev/scripts
- echo "Configuration des serveurs VM via ansible"
- chmod +x deploy_ansible.sh
- ./deploy_ansible.sh
Thank you very much for your help.


