Refactor file path in actions-validate.yml and add input parameter for K8S_TARGET
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user