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