The pyenv_cmd variable is only set for Ubuntu >= 22.04 and CentOS >= 9,
but was being used unconditionally in 'pyenv global' commands. This
caused failures on Ubuntu 20.04 and older CentOS versions.
Fixed by adding proper version checks using ansible_facts to:
- Only run 'pyenv global' on Ubuntu >= 22.04
- Only run 'pyenv global' on CentOS >= 9
- Avoid deprecation warnings by using ansible_facts instead of
ansible_distribution variables
This resolves the error:
'pyenv_cmd' is undefined
Change-Id: I768f327edc02c04365f8be60f94d32fe21eed47d
Signed-off-by: Anil Belur <askb23@gmail.com>
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
- molecule-idempotence-notest
- name: 'Set the required python 3.x versions using pyenv on Ubuntu'
ansible.builtin.command: 'pyenv global system {{ pyenv_cmd }}'
- molecule-idempotence-notest
- name: 'Set the required python 3.x versions using pyenv on Ubuntu'
ansible.builtin.command: 'pyenv global system {{ pyenv_cmd }}'
- when: ansible_distribution == 'Ubuntu'
+ when:
+ - ansible_facts['distribution'] == 'Ubuntu'
+ - ansible_facts['distribution_version'] is version('22.04', '>=')
register: pyenv_global_ubuntu_result
changed_when: false
tags:
- molecule-idempotence-notest
- name: 'Set the required python 3.x versions using pyenv on CentOS'
ansible.builtin.command: 'pyenv global {{ pyenv_cmd }}'
register: pyenv_global_ubuntu_result
changed_when: false
tags:
- molecule-idempotence-notest
- name: 'Set the required python 3.x versions using pyenv on CentOS'
ansible.builtin.command: 'pyenv global {{ pyenv_cmd }}'
- when: ansible_distribution == 'CentOS'
+ when:
+ - ansible_facts['distribution'] == 'CentOS'
+ - ansible_facts['distribution_major_version'] | int >= 9
register: pyenv_global_centos_result
changed_when: false
tags:
register: pyenv_global_centos_result
changed_when: false
tags: