From b753b76e1041166fbd0b2b553270c1a7412e75ce Mon Sep 17 00:00:00 2001 From: Alexandre Pires Date: Sun, 6 Oct 2024 01:53:30 +0200 Subject: [PATCH] Refactor inventory paths in Ansible actions --- .github/actions/get-host-info/action.yml | 2 +- .github/actions/setup-ansible-env/action.yml | 2 +- .github/actions/setup-k8s-env/action.yml | 6 +++--- .github/workflows/actions-validate.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/get-host-info/action.yml b/.github/actions/get-host-info/action.yml index 04a103f..65451a3 100644 --- a/.github/actions/get-host-info/action.yml +++ b/.github/actions/get-host-info/action.yml @@ -27,5 +27,5 @@ runs: SSH_AUTH_SOCK: /tmp/ssh_agent.sock TARGET_HOST: ${{ inputs.target-host }} run: | - system_id=$(ansible -i ansible/inventory/hosts -b -u $ANSIBLE_USER -m shell -a "read_system_id" $TARGET_HOST | tail -1) + system_id=$(ansible -i inventory/hosts -b -u $ANSIBLE_USER -m shell -a "read_system_id" $TARGET_HOST | tail -1) echo "system-id=$system_id" >> $GITHUB_OUTPUT diff --git a/.github/actions/setup-ansible-env/action.yml b/.github/actions/setup-ansible-env/action.yml index b3ece59..daeac05 100644 --- a/.github/actions/setup-ansible-env/action.yml +++ b/.github/actions/setup-ansible-env/action.yml @@ -48,7 +48,7 @@ runs: env: HOST_GROUP: ${{ inputs.host-group }} run: | - ansible-inventory -i ansible/inventory/hosts --list --yaml $HOST_GROUP | grep -oP '(\w+\.){2}\w+' | sort -u > /tmp/ansible_hosts + ansible-inventory -i inventory/hosts --list --yaml $HOST_GROUP | grep -oP '(\w+\.){2}\w+' | sort -u > /tmp/ansible_hosts echo "hosts=$(cat /tmp/ansible_hosts)" >> $GITHUB_OUTPUT - name: Read SSH host keys from remote hosts diff --git a/.github/actions/setup-k8s-env/action.yml b/.github/actions/setup-k8s-env/action.yml index 6b88acf..f244779 100644 --- a/.github/actions/setup-k8s-env/action.yml +++ b/.github/actions/setup-k8s-env/action.yml @@ -26,7 +26,7 @@ runs: 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" $K8S_TARGET + ansible -i inventory/hosts -u $ANSIBLE_USER -m fetch -a "src=/home/$ANSIBLE_USER/.kube/config dest=~/.kube/config flat=yes" $K8S_TARGET - name: Forward K8S API Server port shell: bash @@ -37,8 +37,8 @@ runs: 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" $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+') + ANSIBLE_HOST=$(ansible -i inventory/hosts -u $ANSIBLE_USER -m shell -a "hostname" $K8S_TARGET | grep -oP '(\w+\.){2}\w+' | head -1) + 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 diff --git a/.github/workflows/actions-validate.yml b/.github/workflows/actions-validate.yml index 074e141..e43f5d8 100644 --- a/.github/workflows/actions-validate.yml +++ b/.github/workflows/actions-validate.yml @@ -44,7 +44,7 @@ jobs: env: ANSIBLE_USER: ${{ secrets.ANSIBLE_USER }} run: | - ansible -i ansible/inventory/hosts -u ${{ secrets.ANSIBLE_USER }} -m ping all + ansible -i inventory/hosts -u ${{ secrets.ANSIBLE_USER }} -m ping all - name: Test kubectl get nodes run: |