A variável ${SERVER_IP} funciona no stage: Apply; Porém no stage: Setup ela está em branco;
Não sei onde estou errado? tem alguma forma melhor de passar os valores entre os stage?
image:
name: hashicorp/terraform:1.1.4
entrypoint: [""]
stages:
- Plan
- Apply
- Setup
- PlanDetroy
- Destroy
cache:
paths:
- tfplan
- SERVER_IP
- server_config
- WINDOWS_PASSWORD
...
Apply:
stage: Apply
script:
- terraform init -migrate-state
- terraform apply tfplan
- terraform output SERVER_IP > SERVER_IP
- terraform output SERVER_CONFIG > server_config
- echo ${SERVER_IP}
except:
variables:
- $DESTROY == "true"
when: manual
allow_failure: false
Setup:
stage: Setup
image: alpine
script:
- ls -lha
- apk add ansible openssh-client
- apk update && apk add bash
- ansible --version
- cd ansible-windows
- ls -lha
- echo "[host]" >> hosts
- echo ${SERVER_IP} >> hosts
- echo "[host:vars]" >> hosts
- echo "ansible_connection=winrm" >> hosts
- echo "ansible_ssh_port=5986" >> hosts
- echo "ansible_user=Administrator" >> hosts
- echo "ansible_password=WINDOWS_PASSWORD >> hosts
- echo "ansible_winrm_server_cert_validation=ignore" >> hosts
- echo "ansible_winrm_scheme=https" >> hosts
- cat hosts
- ls -lha
- ansible-playbook -i hosts main.yml
when: manual
allow_failure: false