Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: install interpreters only when necessary #58

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dephekt
Copy link

@dephekt dephekt commented Oct 21, 2022

Add a check if the proposed version is already installed prior to installing a given python interpreter. Each item in pyenv_python_versions will be checked if it's contained in the output of pyenv versions. If the item was in the output, the execution of the install command will be skipped. Versions not already installed will still be installed during the looping.

Fixes #57

@dephekt
Copy link
Author

dephekt commented Oct 21, 2022

Probably needs something similar in tasks/versions/python_versions_with_homebrew.yml but since I don't use homebrew and am not familiar with it, I didn't do any testing with that.

I installed my PR branch role on my local machine to test that my reported issue is fixed by this. I'm not incredibly familiar with Travis tests, so I have not added any test to reproduce the issue and I don't understand why the current idempotency test is not failing for this scenario like I'd expect.

Before:

TASK [ansible_pyenv : Install Python interpreters] *****************************************
failed: [localhost] (item=3.10.3) => {"ansible_loop_var": "item", "changed": true, "cmd": "/home/dephekt//.pyenv/bin/pyenv install 3.10.3", "delta": "0:00:00.024369", "end": "2022-10-21 02:15:19.618294", "item": "3.10.3", "msg": "non-zero return code", "rc": 1, "start": "2022-10-21 02:15:19.593925", "stderr": "pyenv: /root/.pyenv/versions/3.10.3 already exists", "stderr_lines": ["pyenv: /root/.pyenv/versions/3.10.3 already exists"], "stdout": "", "stdout_lines": []}

After:

TASK [ansible_pyenv : Install python versions with Git install] *********************************
included: /home/dephekt/.ansible/roles/ansible_pyenv/tasks/versions/python_versions_with_git.yml for localhost

TASK [ansible_pyenv : Check if interpreters installed] ******************************************
changed: [localhost]

TASK [ansible_pyenv : Install Python interpreters] **********************************************
changed: [localhost] => (item=3.8.14)
ok: [localhost] => (item=3.7.14)
changed: [localhost] => (item=2.7.18)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task fails if python interpreters already exist
1 participant