Refactor SSH key scanning and connection in Ansible actions
This commit is contained in:
@@ -56,7 +56,7 @@ runs:
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
for HOST in $(cat /tmp/ansible_hosts); do
|
||||
ssh-keyscan $HOST >> ~/.ssh/known_hosts
|
||||
ssh-keyscan "$HOST" >> ~/.ssh/known_hosts
|
||||
done
|
||||
chmod 600 ~/.ssh/known_hosts
|
||||
|
||||
@@ -87,5 +87,5 @@ runs:
|
||||
SSH_AUTH_SOCK: ${{ inputs.ssh-auth-socket }}
|
||||
run: |
|
||||
for HOST in $(cat /tmp/ansible_hosts); do
|
||||
ssh $ANSIBLE_USER@$HOST echo "SSH connection to $HOST successful"
|
||||
ssh "$ANSIBLE_USER@$HOST" echo "SSH connection to "$HOST" successful"
|
||||
done
|
||||
|
||||
@@ -41,7 +41,7 @@ runs:
|
||||
IP_ADDR=$(ansible -i 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
|
||||
ssh -f -N -L 16443:localhost:16443 "$ANSIBLE_USER@$ANSIBLE_HOST"
|
||||
|
||||
# Override the kube config file to use localhost
|
||||
sed -i "s/server: https:\/\/$IP_ADDR:16443/server: https:\/\/localhost:16443/g" ~/.kube/config
|
||||
|
||||
Reference in New Issue
Block a user