workflows: Install and use ansible in a virtualenv #172
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: tests | |
on: [push, pull_request] | |
jobs: | |
syntax-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install ansible | |
run: | | |
sudo apt-get update | |
sudo apt-get purge ansible | |
sudo apt-get install python3-setuptools python3-virtualenv | |
echo "Creating virtualenv" | |
virtualenv venv | |
echo "Activating virtualenv" | |
source ./venv/bin/activate | |
echo "Installing ansible dependencies in virtualenv" | |
pip3 install ansible==2.10.7 | |
- name: ansible-playbook syntax check | |
run: | | |
echo "Removing vault password file line from ansible.cfg" | |
sed -i /^vault_password_file/d ansible.cfg | |
ansible-playbook -i localhost, cephlab.yml --syntax-check | |
ansible-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install ansible-lint | |
run: | | |
sudo apt-get update | |
sudo apt-get purge ansible | |
sudo apt-get install python3-setuptools python3-virtualenv | |
echo "Creating virtualenv" | |
virtualenv venv | |
echo "Activating virtualenv" | |
source ./venv/bin/activate | |
echo "Installing ansible dependencies in virtualenv" | |
# This pinned ansible version should match teuthology's | |
# requirements.txt. | |
# And we choose an ansible-lint version to be compatible with this | |
# Ansible version. | |
pip3 install ansible==2.10.7 ansible-lint | |
- name: Run ansible-lint | |
run: | | |
echo "Activating virtualenv again" | |
source ./venv/bin/activate | |
pwd | |
echo $PATH | |
ansible-lint -v roles/* |