delete provider from module, local in main

This commit is contained in:
CC
2026-09-12 15:18:24 +01:00
parent 1041be3770
commit fbb2a53e23
4 changed files with 50 additions and 33 deletions

View File

@@ -21,10 +21,8 @@ jobs:
- name: Check files & Select tfvars
shell: bash
run: |
#rm ansible/inventory/inventory.yml
mkdir -p ansible/inventory
cd terraform
#rm vm_data.yml
cp "${{ inputs.tfvars_file || 'single.tfvars.example' }}" terraform.tfvars
- uses: hashicorp/setup-terraform@v4
@@ -40,37 +38,37 @@ jobs:
run: terraform apply -auto-approve
working-directory: "terraform"
- name: Install Ansible
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y ansible rsync
# - name: Install Ansible
# shell: bash
# run: |
# sudo apt-get update
# sudo apt-get install -y ansible rsync
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/vlans_rsa
chmod 600 ~/.ssh/vlans_rsa
cat > ~/.ssh/config <<'EOF'
Host *
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
EOF
# - name: Set up SSH
# run: |
# mkdir -p ~/.ssh
# echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/vlans_rsa
# chmod 600 ~/.ssh/vlans_rsa
# cat > ~/.ssh/config <<'EOF'
# Host *
# StrictHostKeyChecking no
# UserKnownHostsFile=/dev/null
# EOF
- name: Configure Git
run: |
git config user.name "git-bot"
git config user.email "got-bot@text.com"
# - name: Configure Git
# run: |
# git config user.name "git-bot"
# git config user.email "got-bot@text.com"
- name: Commit and push to Gitea
run: |
git remote set-url origin https://$GITEA_USERNAME:${{ secrets.GIT_BOT_TOKEN }}@tea.charcarservices.uk/CC/N8N.git
git add terraform/vm_data.yml ansible/inventory/inventory.yml
git diff --cached --quiet || git commit -m "chore: update terraform outputs"
git push origin HEAD:main
env:
GITEA_USERNAME: git-bot # or your bot account
# - name: Commit and push to Gitea
# run: |
# git remote set-url origin https://$GITEA_USERNAME:${{ secrets.GIT_BOT_TOKEN }}@tea.charcarservices.uk/CC/N8N.git
# git add terraform/vm_data.yml ansible/inventory/inventory.yml
# git diff --cached --quiet || git commit -m "chore: update terraform outputs"
# git push origin HEAD:main
# env:
# GITEA_USERNAME: git-bot # or your bot account
- name: Run playbook
run: |
ansible-playbook ansible/playbooks/docker_copy.yml -i ansible/inventory/inventory.yml -u cloud --private-key ~/.ssh/vlans_rsa
# - name: Run playbook
# run: |
# ansible-playbook ansible/playbooks/docker_copy.yml -i ansible/inventory/inventory.yml -u cloud --private-key ~/.ssh/vlans_rsa

View File

@@ -34,7 +34,6 @@ jobs:
- name: Check files & Select tfvars
shell: bash
run: |
ls
cp "${{ inputs.tfvars_file || 'single.tfvars.example' }}" terraform.tfvars
cat terraform.tfvars

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.terraform*

19
terraform/locals.tf Normal file
View File

@@ -0,0 +1,19 @@
locals {
instance_map = var.instance_mode == "single" ? {
main = var.instance
} : var.instances
vm_created = {
for k, v in local.instance_map :
k => {
service_name = v.service_name
vm_name = v.vm_name
node_name = v.node_name
ipv4_address = module.vm-music[k].vm_ipv4_address
vm_tags = concat(
try(v.vm_tags, []),
["terraform", "docker", v.service_name, "ip-${replace(module.vm-music[k].vm_ipv4_address, ".", "-")}"]
)
}
}
}