Refactor Ansible setup environment actions
This commit is contained in:
+6
@@ -5,12 +5,14 @@ runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install Python and required packages
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-pip
|
||||
python3 -m pip install -r requirements.txt
|
||||
|
||||
- name: Setup SSH Key
|
||||
shell: bash
|
||||
env:
|
||||
VAULT_MASTER_PASSWORD: ${{ secrets.VAULT_MASTER_PASSWORD }}
|
||||
run: |
|
||||
@@ -21,6 +23,7 @@ runs:
|
||||
chmod 600 ~/.ssh/id_ecdsa
|
||||
|
||||
- name: Read SSH Trusted Hosts keys
|
||||
shell: bash
|
||||
env:
|
||||
TRUSTED_HOSTS: ${{ secrets.TRUSTED_HOSTS }}
|
||||
run: |
|
||||
@@ -31,12 +34,14 @@ runs:
|
||||
chmod 600 ~/.ssh/known_hosts
|
||||
|
||||
- name: Enable SSH host key algorithms
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Host *" >> ~/.ssh/config
|
||||
echo " HostKeyAlgorithms +sk-ecdsa-sha2-nistp256@openssh.com, sk-ssh-ed25519@openssh.com"
|
||||
chmod 600 ~/.ssh/config
|
||||
|
||||
- name: Start SSH Agent
|
||||
shell: bash
|
||||
env:
|
||||
VAULT_MASTER_PASSWORD: ${{ secrets.VAULT_MASTER_PASSWORD }}
|
||||
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
||||
@@ -47,6 +52,7 @@ runs:
|
||||
rm ~/.ssh_askpass
|
||||
|
||||
- name: Check SSH Connection to remote hosts
|
||||
shell: bash
|
||||
env:
|
||||
TRUSTED_HOSTS: ${{ secrets.TRUSTED_HOSTS }}
|
||||
ANSIBLE_USER: ${{ secrets.ANSIBLE_USER }}
|
||||
+1
@@ -9,6 +9,7 @@ runs:
|
||||
|
||||
- name: Get changed files
|
||||
id: get_changed_files
|
||||
shell: bash
|
||||
run: |
|
||||
# Get the list of changed files
|
||||
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
|
||||
+3
@@ -9,6 +9,7 @@ runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Copy Kube Config from remote host
|
||||
shell: bash
|
||||
env:
|
||||
VAULT_MASTER_PASSWORD: ${{ secrets.VAULT_MASTER_PASSWORD }}
|
||||
ANSIBLE_USER: ${{ secrets.ANSIBLE_USER }}
|
||||
@@ -18,6 +19,7 @@ runs:
|
||||
ansible -i ansible/inventory/hosts -u $ANSIBLE_USER -m fetch -a "src=/home/$ANSIBLE_USER/.kube/config dest=~/.kube/config flat=yes" {{ inputs.k8s-target }}
|
||||
|
||||
- name: Terraform Init
|
||||
shell: bash
|
||||
env:
|
||||
VAULT_MASTER_PASSWORD: ${{ secrets.VAULT_MASTER_PASSWORD }}
|
||||
run: |
|
||||
@@ -25,6 +27,7 @@ runs:
|
||||
sectool exec terraform init
|
||||
|
||||
- name: Terraform Apply
|
||||
shell: bash
|
||||
env:
|
||||
VAULT_MASTER_PASSWORD: ${{ secrets.VAULT_MASTER_PASSWORD }}
|
||||
ANSIBLE_USER: ${{ secrets.ANSIBLE_USER }}
|
||||
Reference in New Issue
Block a user