Gitlab runner issues with stages

Hello i have a pipeline. I have also 2 script in my code et

For now i want that it do only 2 things :slight_smile:

  • 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?

    - runner_test

  - deploy-dev-terraform
  - deploy-dev-ansible

#_________ ETAPE 1 - Déploiement des VM sur GCP via terraform pour l'environement de dév __________#
  stage: deploy-dev-terraform
  image : ubuntu-personalise
    - ssh-keygen -t rsa -b 2048 -f "$HOME/.ssh/id_rsa" -N ""
    - curl --silent "" | bash
    - gcloud auth activate-service-account --key-file=.secure_files/credentials1.json
    - 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
    - ./
    # - chmod +x
    # - ./

#_________ ETAPE 2 - Configuration des serveurs VM via ansible __________#
  stage: deploy-dev-ansible
  image : ubuntu-personalise
    - cd ./environment-dev/scripts
    - echo "Configuration des serveurs VM via ansible"
    - chmod +x
    - ./

Thank you very much for your help.