trigger: none

variables:
  - group: 'GCP_ZA_ADO-baseline-stages'

stages:
  - stage: Setup
    displayName: 'Setup Tools'
    jobs:
      - job: Access_GCP_environment
        displayName: 'Access to GCP'
        pool:
          vmImage: 'ubuntu-latest'
        steps:
          - template: templates/securefile-template.yaml
      - job: InstallTools
        displayName: 'Install Terraform'
        dependsOn: Access_GCP_environment
        pool:
          vmImage: 'ubuntu-latest'
        steps:
          - script: |
              curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
              sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
              sudo apt-get install -y wget unzip
              wget https://releases.hashicorp.com/terraform/1.6.0/terraform_1.6.0_linux_amd64.zip
              unzip terraform_1.6.0_linux_amd64.zip
              sudo mv terraform /usr/local/bin/
              sudo chmod +x /usr/local/bin/terraform
              terraform version
              sudo apt-get update && sudo apt-get install dos2unix
              sudo apt-get update && sudo apt-get install google-cloud-sdk
              sudo apt-get install google-cloud-cli-terraform-tools -y
              sudo apt-get install jq -y
              sudo apt update && sudo apt install python3  # Installs latest Python 3 version
              ls -l
              # python3 ./fix_tfvars_symlinks.py .
              find . -type f -name "*.sh" | xargs chmod a+x
              find . -type f -name "*.sh" | xargs dos2unix

            displayName: 'Install Terraform'
            continueOnError: false
            

  - template: bootstrap_stage/bootstrap.yaml
    parameters:
      stageName: bootstrap_stage
      continueOnError: false
      

  - template: org_stage/org.yaml
    parameters:
      stageName: org_stage
      continueOnError: false

  - template: environments_stage/environments.yaml
    parameters:
      stageName: environments_stage
      continueOnError: false

  - template: network_hub_spoke_stage/network_hub_spoke.yaml
    parameters:
      stageName: network_hub_spoke_stage
      continueOnError: false

  - template: projects_stage/projects.yaml
    parameters:
      stageName: projects_stage
      continueOnError: false

  - template: orgpolicies_stage/orgpolicies.yaml
    parameters:
      stageName: orgpolicies_stage
      continueOnError: false

  - template: fortigate_stage/fortigate.yaml
    parameters:
      stageName: fortigate_stage
      continueOnError: false