Refactor inventory paths in Ansible actions

This commit is contained in:
2024-10-06 01:53:30 +02:00
parent cae03aa746
commit b753b76e10
4 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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: |