Merge pull request #28 from deltron-fr/infra_features #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy infrastructure | |
| on: | |
| push: | |
| branches: | |
| - infra_main | |
| jobs: | |
| deploy-terraform-and-ansible: | |
| env: | |
| ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }} | |
| ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }} | |
| ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
| ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }} | |
| TF_VAR_resource_name: ${{ secrets.TF_VARS_RESOURCE_NAME }} | |
| TF_VAR_location: ${{ secrets.TF_VARS_LOCATION }} | |
| TF_VAR_address_space: ${{ secrets.TF_VARS_ADDRESS_SPACE }} | |
| TF_VAR_address_prefixes: ${{ secrets.TF_VARS_ADDRESS_PREFIXES }} | |
| TF_VAR_vm_size: ${{ secrets.TF_VARS_VM_SIZE }} | |
| TF_VAR_admin_username: ${{ secrets.TF_VARS_ADMIN_USERNAME }} | |
| TF_VAR_ssh_key_path: ${{ secrets.TF_VARS_SSH_KEY_PATH }} | |
| TF_VAR_ssh_pri_key: ${{ secrets.TF_VARS_SSH_PRI_KEY_PATH }} | |
| TF_VAR_dns_password: ${{ secrets.TF_VARS_DNS_PASSWORD }} | |
| name: deploy terraform and configure monitoring stack | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Write ssh keys to file | |
| run: | | |
| mkdir -p /home/runner/.ssh | |
| touch /home/runner/.ssh/known_hosts | |
| echo "${{ secrets.SSH_PUBLIC_KEY }}" > /home/runner/.ssh/id_rsa.pub | |
| echo "${{ secrets.SSH_PRIVATE_KEY }}" > /home/runner/.ssh/id_rsa | |
| chmod 600 /home/runner/.ssh/id_rsa | |
| chmod 644 /home/runner/.ssh/id_rsa.pub | |
| - name: create ansible config file | |
| run: | | |
| touch infrastructure/ansible/ansible.cfg | |
| echo "[defaults]" > infrastructure/ansible/ansible.cfg | |
| echo "inventory = inventory.ini" >> infrastructure/ansible/ansible.cfg | |
| echo "private_key_file = /home/runner/.ssh/id_rsa" >> infrastructure/ansible/ansible.cfg | |
| echo "remote_user = ${{ secrets.REMOTE_USER }}" >> infrastructure/ansible/ansible.cfg | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.9.5 | |
| - name: Terraform init | |
| run: | | |
| cd infrastructure/terraform | |
| terraform init | |
| - name: Terraform apply | |
| run: | | |
| cd infrastructure/terraform | |
| terraform apply -auto-approve | |