generated from CC/VMServiceTemplate
delete provider from module, local in main
This commit is contained in:
@@ -21,10 +21,8 @@ jobs:
|
|||||||
- name: Check files & Select tfvars
|
- name: Check files & Select tfvars
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
#rm ansible/inventory/inventory.yml
|
|
||||||
mkdir -p ansible/inventory
|
mkdir -p ansible/inventory
|
||||||
cd terraform
|
cd terraform
|
||||||
#rm vm_data.yml
|
|
||||||
cp "${{ inputs.tfvars_file || 'single.tfvars.example' }}" terraform.tfvars
|
cp "${{ inputs.tfvars_file || 'single.tfvars.example' }}" terraform.tfvars
|
||||||
|
|
||||||
- uses: hashicorp/setup-terraform@v4
|
- uses: hashicorp/setup-terraform@v4
|
||||||
@@ -40,37 +38,37 @@ jobs:
|
|||||||
run: terraform apply -auto-approve
|
run: terraform apply -auto-approve
|
||||||
working-directory: "terraform"
|
working-directory: "terraform"
|
||||||
|
|
||||||
- name: Install Ansible
|
# - name: Install Ansible
|
||||||
shell: bash
|
# shell: bash
|
||||||
run: |
|
# run: |
|
||||||
sudo apt-get update
|
# sudo apt-get update
|
||||||
sudo apt-get install -y ansible rsync
|
# sudo apt-get install -y ansible rsync
|
||||||
|
|
||||||
- name: Set up SSH
|
# - name: Set up SSH
|
||||||
run: |
|
# run: |
|
||||||
mkdir -p ~/.ssh
|
# mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/vlans_rsa
|
# echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/vlans_rsa
|
||||||
chmod 600 ~/.ssh/vlans_rsa
|
# chmod 600 ~/.ssh/vlans_rsa
|
||||||
cat > ~/.ssh/config <<'EOF'
|
# cat > ~/.ssh/config <<'EOF'
|
||||||
Host *
|
# Host *
|
||||||
StrictHostKeyChecking no
|
# StrictHostKeyChecking no
|
||||||
UserKnownHostsFile=/dev/null
|
# UserKnownHostsFile=/dev/null
|
||||||
EOF
|
# EOF
|
||||||
|
|
||||||
- name: Configure Git
|
# - name: Configure Git
|
||||||
run: |
|
# run: |
|
||||||
git config user.name "git-bot"
|
# git config user.name "git-bot"
|
||||||
git config user.email "got-bot@text.com"
|
# git config user.email "got-bot@text.com"
|
||||||
|
|
||||||
- name: Commit and push to Gitea
|
# - name: Commit and push to Gitea
|
||||||
run: |
|
# run: |
|
||||||
git remote set-url origin https://$GITEA_USERNAME:${{ secrets.GIT_BOT_TOKEN }}@tea.charcarservices.uk/CC/N8N.git
|
# 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 add terraform/vm_data.yml ansible/inventory/inventory.yml
|
||||||
git diff --cached --quiet || git commit -m "chore: update terraform outputs"
|
# git diff --cached --quiet || git commit -m "chore: update terraform outputs"
|
||||||
git push origin HEAD:main
|
# git push origin HEAD:main
|
||||||
env:
|
# env:
|
||||||
GITEA_USERNAME: git-bot # or your bot account
|
# GITEA_USERNAME: git-bot # or your bot account
|
||||||
|
|
||||||
- name: Run playbook
|
# - name: Run playbook
|
||||||
run: |
|
# run: |
|
||||||
ansible-playbook ansible/playbooks/docker_copy.yml -i ansible/inventory/inventory.yml -u cloud --private-key ~/.ssh/vlans_rsa
|
# ansible-playbook ansible/playbooks/docker_copy.yml -i ansible/inventory/inventory.yml -u cloud --private-key ~/.ssh/vlans_rsa
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ jobs:
|
|||||||
- name: Check files & Select tfvars
|
- name: Check files & Select tfvars
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
ls
|
|
||||||
cp "${{ inputs.tfvars_file || 'single.tfvars.example' }}" terraform.tfvars
|
cp "${{ inputs.tfvars_file || 'single.tfvars.example' }}" terraform.tfvars
|
||||||
cat terraform.tfvars
|
cat terraform.tfvars
|
||||||
|
|
||||||
|
|||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.terraform*
|
||||||
19
terraform/locals.tf
Normal file
19
terraform/locals.tf
Normal 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, ".", "-")}"]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user