GitHub Actions - Install Ansible in a runner VM

by
Jeremy Canfield |
Updated: December 20 2024
| GitHub Actions articles
GitHub Actions can be used to do something whenever something happens in one of your GitHub repositories. If you are not familiar with GitHub Actions, check out my article Getting Started with GitHub Actions.
Before you can use pip to install Ansible you will need to setup Python in the runner VM. Check out my article FreeKB - GitHub Actions - Install Python in a runner VM.
The plain ole run command can be used to run the pip commands in the runner VM to install Ansible in the runner VM.
name: GitHub Action
run-name: ${{ github.workflow }} run by ${{ github.actor }}
on:
push:
branches:
- main
jobs:
restart-docker-container:
runs-on: ubuntu-latest
steps:
- name: setup python version 3.12 in the runner VM
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: use pip to install ansible in the runner VM
run: |
python3 -m pip install --upgrade pip
pip install --upgrade ansible
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
Did you find this article helpful?
If so, consider buying me a coffee over at