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