initial template v1
This commit is contained in:
@@ -2,6 +2,15 @@ name: Deploy VM and App
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tfvars_file:
|
||||
description: "Which tfvars file to use"
|
||||
required: true
|
||||
default: "single.tfvars.example"
|
||||
type: choice
|
||||
options:
|
||||
- single.tfvars.example
|
||||
- multi.tfvars.example
|
||||
|
||||
jobs:
|
||||
terraform:
|
||||
@@ -14,22 +23,24 @@ jobs:
|
||||
|
||||
- uses: hashicorp/setup-terraform@v3
|
||||
|
||||
- name: Select tfvars
|
||||
run: cp "${{ inputs.tfvars_file }}" terraform.tfvars
|
||||
|
||||
- name: Terraform init
|
||||
run: terraform init
|
||||
|
||||
- name: Terraform apply
|
||||
run: terraform apply -auto-approve
|
||||
|
||||
- name: Write inventory from output
|
||||
- name: Write inventory
|
||||
run: |
|
||||
IP=$(terraform output -raw vm_ipv4_address)
|
||||
mkdir -p ../ansible/inventory
|
||||
printf '[app]\n%s ansible_user=cloud\n' "$IP" > ../ansible/inventory/hosts.ini
|
||||
terraform output -json vm_ipv4_addresses | jq -r '
|
||||
to_entries[] | "[app]\n\(.value) ansible_user=cloud"
|
||||
' > ../ansible/inventory/hosts.ini
|
||||
|
||||
- name: Write tags file
|
||||
run: |
|
||||
TAGS=$(terraform output -json vm_tags)
|
||||
echo "$TAGS" > ../terraform/vm_tags.json
|
||||
- name: Write tags
|
||||
run: terraform output -json vm_tags > ../ansible/vm_tags.json
|
||||
|
||||
deploy:
|
||||
needs: terraform
|
||||
|
||||
Reference in New Issue
Block a user