tested template
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
name: Deploy VM and App
|
name: Deploy VM and App
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tfvars_file:
|
tfvars_file:
|
||||||
@@ -13,45 +15,64 @@ on:
|
|||||||
- multi.tfvars.example
|
- multi.tfvars.example
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
terraform:
|
terraform-ansible-deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: terraform
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: hashicorp/setup-terraform@v3
|
- 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
|
||||||
|
|
||||||
- name: Select tfvars
|
- uses: hashicorp/setup-terraform@v4
|
||||||
run: cp "${{ inputs.tfvars_file }}" terraform.tfvars
|
|
||||||
|
- name: Check path
|
||||||
|
run: pwd
|
||||||
|
|
||||||
- name: Terraform init
|
- name: Terraform init
|
||||||
run: terraform init
|
run: terraform init
|
||||||
|
working-directory: "terraform"
|
||||||
|
|
||||||
- name: Terraform apply
|
- name: Terraform apply
|
||||||
run: terraform apply -auto-approve
|
run: terraform apply -auto-approve
|
||||||
|
working-directory: "terraform"
|
||||||
- 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
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
needs: terraform
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install Ansible
|
- name: Install Ansible
|
||||||
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install --upgrade pip
|
sudo apt-get update
|
||||||
pip install ansible community.docker
|
sudo apt-get install -y ansible rsync
|
||||||
|
|
||||||
- name: Deploy app
|
- name: Set up SSH
|
||||||
run: ansible-playbook -i ansible/inventory/hosts.ini ansible/playbooks/deploy.yml
|
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: Run playbook
|
||||||
|
run: |
|
||||||
|
ansible-playbook ansible/playbooks/docker_copy.yml -i ansible/inventory/inventory.yml -u cloud --private-key ~/.ssh/vlans_rsa
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
APP_NAME=n8n
|
|
||||||
APP_PORT=5678
|
|
||||||
# DOMAIN_NAME and SUBDOMAIN together determine where n8n will be reachable from
|
|
||||||
# The top level domain to serve from
|
|
||||||
DOMAIN_NAME=charcarservices.uk
|
|
||||||
|
|
||||||
# The subdomain to serve from
|
|
||||||
SUBDOMAIN=nein
|
|
||||||
|
|
||||||
# The above example serve n8n at: https://n8n.example.com
|
|
||||||
|
|
||||||
# Optional timezone to set which gets used by Cron and other scheduling nodes
|
|
||||||
# New York is the default value if not set
|
|
||||||
GENERIC_TIMEZONE=Europe/London
|
|
||||||
|
|
||||||
# The email address to use for the TLS/SSL certificate creation
|
|
||||||
SSL_EMAIL=user@example.com
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
services:
|
|
||||||
n8n:
|
|
||||||
image: docker.n8n.io/n8nio/n8n
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- "5678:5678"
|
|
||||||
environment:
|
|
||||||
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
|
|
||||||
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
|
|
||||||
- N8N_PORT=5678
|
|
||||||
- N8N_PROTOCOL=https
|
|
||||||
- NODE_ENV=production
|
|
||||||
- WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
|
|
||||||
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
|
|
||||||
- TZ=${GENERIC_TIMEZONE}
|
|
||||||
volumes:
|
|
||||||
- ./n8n_data:/home/node/.n8n
|
|
||||||
- ./local-files:/files
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
n8n_data:
|
|
||||||
traefik_data:
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
name: Deploy VM and App
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
|
|
||||||
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-ansible-deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- name: Check path
|
|
||||||
run: pwd
|
|
||||||
|
|
||||||
- name: Terraform init
|
|
||||||
run: terraform init
|
|
||||||
working-directory: "terraform"
|
|
||||||
|
|
||||||
- name: Terraform apply
|
|
||||||
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: 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: Run playbook
|
|
||||||
run: |
|
|
||||||
ansible-playbook ansible/playbooks/docker_copy.yml -i ansible/inventory/inventory.yml -u cloud --private-key ~/.ssh/vlans_rsa
|
|
||||||
|
|
||||||
- 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
|
|
||||||
Reference in New Issue
Block a user