Skip to content

Commit

Permalink
OPS-7069-fix-awx-workflow (#101)
Browse files Browse the repository at this point in the history
* Try using virtual environment

* Try virtual environment in count hosts workflow

* Add setuptools
  • Loading branch information
YannickEvers authored Oct 16, 2024
1 parent df6d92f commit 347bd9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 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
8 changes: 6 additions & 2 deletions .github/workflows/trigger-awx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ jobs:
run_awx:
runs-on: ubuntu-latest
steps:
- name: Pip install awxkit
- name: Create venv and install awxkit
run: |
pip3 install awxkit==${{ inputs.awxkit_version }}
python -m venv .venv
source .venv/bin/activate
pip3 install awxkit==${{ inputs.awxkit_version }} setuptools
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
- name: Set limit flag env
run: echo "LIMIT_FLAG=--limit ${{ inputs.limit }}" >> $GITHUB_ENV
if: ${{ inputs.limit != '' }}
Expand Down

0 comments on commit 347bd9e

Please sign in to comment.