As part of my Molecule test, I want to revert a previously created pyenv installation to an old state. The goal is to simulate a new Python version being released but not being available to pyenv because it hasn't been updated yet with git pull
.
The relevant sections of my prepare.yml
look like this:
- name: run Python role to install venv
import_role:
name: company.python
- name: unshallow pyenv repo
command: cd /home/johndoe/.pyenv && git pull --unshallow
# Python 3.8.12 was released on Aug. 30, 2021 (see https://www.python.org/downloads/)
# Use pyenv commit from Aug. 23, 2021
- name: switch to old pyenv commit
command: cd /home/johndoe/.pyenv && git checkout e9c8dfc197744cace4832d7ed3bfdd644445ff50
Unfortunately, ~johndoe/.pyenv
still points to HEAD
in master after the prepare step, and the repository is not unshallowed. Running these commands manually works. What am I missing?
The Molecule invocation does not report any errors either:
TASK [company.python : Print fact python_venv_paths] *************************
ok: [instance] => {
"msg": [
"/home/johndoe/.pyenv/versions/ansible-dependencies"
]
}
TASK [unshallow pyenv repo] ****************************************************
changed: [instance]
TASK [switch to old pyenv commit] **********************************************
changed: [instance]