Skip to content

Commit

Permalink
Try virtual environment in count hosts workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickEvers authored Oct 15, 2024
1 parent 8297061 commit 495a00b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ansible-count-hosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ jobs:
count: ${{ steps.count_hosts.outputs.count }}
steps:
- uses: actions/checkout@v4
- name: Count hosts in limit
id: count_hosts
- name: Create virtual environment and install ansible
run: |
python -m venv .venv
source .venv/bin/activate
# Only keep Ansible in the pip requirements
pip3 install $(grep ansible $GITHUB_WORKSPACE/${{ inputs.requirements_file }})
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
- name: Count hosts in limit
id: count_hosts
run: |
echo "count=$(ansible-inventory -i $GITHUB_WORKSPACE/${{ inputs.inventory_file }} --list -l ${{ inputs.limit }} | jq -e '._meta.hostvars | keys | length')" >> $GITHUB_OUTPUT

0 comments on commit 495a00b

Please sign in to comment.