generated from CC/VMServiceTemplate
n8n ci/cd base
This commit is contained in:
@@ -32,18 +32,16 @@ jobs:
|
||||
- name: Terraform apply
|
||||
run: terraform apply -auto-approve
|
||||
|
||||
- name: Write inventory
|
||||
run: |
|
||||
mkdir -p ../ansible/inventory
|
||||
terraform output -json vm_ipv4_addresses | jq -r '
|
||||
to_entries[] | "[app]\n\(.value) ansible_user=cloud"
|
||||
' > ../ansible/inventory/hosts.ini
|
||||
|
||||
- name: Write tags
|
||||
run: terraform output -json vm_tags > ../ansible/vm_tags.json
|
||||
- name: Upload generated files
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: terraform-outputs
|
||||
path: |
|
||||
ansible/inventory/inventory.yml
|
||||
terraform/vm_data.yml
|
||||
|
||||
ansible-configure:
|
||||
needs: terraform
|
||||
needs: terraform-deploy
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
@@ -51,6 +49,12 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Download generated files
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: terraform-outputs
|
||||
path: .
|
||||
|
||||
- name: Install Ansible
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -64,6 +68,12 @@ jobs:
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
echo -e "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile=/dev/null\n" > ~/.ssh/config
|
||||
|
||||
- name: Setup Ansible Directories
|
||||
run: |
|
||||
mkdir inventory
|
||||
cat inventory/inventory.yml
|
||||
ls -r
|
||||
|
||||
- name: Run playbook
|
||||
run: |
|
||||
ansible-playbook playbooks/docker_copy.yml -i inventory/inventory.yml -u cloud --private-key ~/.ssh/id_rsa
|
||||
|
||||
@@ -40,12 +40,12 @@ module "vm-n8n" {
|
||||
|
||||
module "inventory" {
|
||||
source = "./modules/proxmox_ansible_inventory"
|
||||
filename = "${path.module}/ansible/inventory/inventory.yml"
|
||||
filename = "${path.root}/ansible/inventory/inventory.yml"
|
||||
instances = local.vm_created
|
||||
}
|
||||
|
||||
module "vm_data" {
|
||||
source = "./modules/proxmox_vm_data"
|
||||
filename = "${path.module}/terraform/vm_data.yml"
|
||||
filename = "${path.root}/terraform/vm_data.yml"
|
||||
instances = local.vm_created
|
||||
}
|
||||
|
||||
@@ -1,20 +1,41 @@
|
||||
output "vm_ipv4_addresses" {
|
||||
description = "Map of instance key to VM IPv4 address"
|
||||
value = {
|
||||
for k, m in module.vm-n8n : k => m.vm_ipv4_address
|
||||
}
|
||||
}
|
||||
|
||||
output "vm_tags" {
|
||||
output "service_names" {
|
||||
description = "Map of instance key to service name"
|
||||
value = {
|
||||
for k, m in module.vm-n8n : k => concat(
|
||||
try(local.instance_map[k].vm_tags, []),
|
||||
["terraform", "docker", local.instance_map[k].service_name, "ip-${replace(m.vm_ipv4_address, ".", "-")}"]
|
||||
)
|
||||
for k, v in local.instance_map : k => v.service_name
|
||||
}
|
||||
}
|
||||
|
||||
output "service_names" {
|
||||
output "vm_names" {
|
||||
description = "Map of instance key to VM name"
|
||||
value = {
|
||||
for k, cfg in local.instance_map : k => cfg.service_name
|
||||
for k, v in local.instance_map : k => v.vm_name
|
||||
}
|
||||
}
|
||||
|
||||
output "vm_tag_data" {
|
||||
description = "Map of instance key to node, VM name, and final tags"
|
||||
value = {
|
||||
for k, v in local.vm_created : k => {
|
||||
node_name = v.node_name
|
||||
vm_name = v.vm_name
|
||||
tags = v.vm_tags
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output "inventory_file" {
|
||||
description = "Path to the generated Ansible inventory"
|
||||
value = local_file.inventory.filename
|
||||
}
|
||||
|
||||
output "vm_data_file" {
|
||||
description = "Path to the generated VM data file"
|
||||
value = local_file.vm_data.filename
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user