From e5e63f9699e3d75e0976597ef0693e1399aa0285 Mon Sep 17 00:00:00 2001 From: Alexandre Pires Date: Sun, 29 Sep 2024 18:59:44 +0200 Subject: [PATCH] Refactor file path in actions-validate.yml and add input parameter for K8S_TARGET --- .github/actions/setup-k8s-env/action.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-k8s-env/action.yml b/.github/actions/setup-k8s-env/action.yml index ba962ad..c6ab8df 100644 --- a/.github/actions/setup-k8s-env/action.yml +++ b/.github/actions/setup-k8s-env/action.yml @@ -20,9 +20,10 @@ runs: VAULT_MASTER_PASSWORD: ${{ inputs.vault-master-password }} ANSIBLE_USER: ${{ inputs.ansible-user }} SSH_AUTH_SOCK: /tmp/ssh_agent.sock + K8S_TARGET: ${{ inputs.k8s-target }} run: | mkdir -p ~/.kube - 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" $K8S_TARGET - name: Terraform Init shell: bash @@ -38,10 +39,11 @@ runs: VAULT_MASTER_PASSWORD: ${{ inputs.vault-master-password }} ANSIBLE_USER: ${{ inputs.ansible-user }} SSH_AUTH_SOCK: /tmp/ssh_agent.sock + K8S_TARGET: ${{ inputs.k8s-target }} run: | # Get Hostname and IP address of the target - ANSIBLE_HOST=$(ansible -i ansible/inventory/hosts -u $ANSIBLE_USER -m shell -a "hostname" {{ inputs.k8s-target }} | grep -oP '(\w+\.){2}\w+' | head -1) - IP_ADDR=$(ansible -i ansible/inventory/hosts -u $ANSIBLE_USER -m shell -a "curl -s ifconfig.me" {{ inputs.k8s-target }} | grep -oP '(\d+\.){3}\d+') + ANSIBLE_HOST=$(ansible -i ansible/inventory/hosts -u $ANSIBLE_USER -m shell -a "hostname" $K8S_TARGET | grep -oP '(\w+\.){2}\w+' | head -1) + IP_ADDR=$(ansible -i ansible/inventory/hosts -u $ANSIBLE_USER -m shell -a "curl -s ifconfig.me" $K8S_TARGET | grep -oP '(\d+\.){3}\d+') # Forward the k8s API server port to localhost ssh -f -N -L 16443:localhost:16443 $ANSIBLE_USER@$ANSIBLE_HOST