I need to be able to install a MySQL library. Python has 1 package for v2 and another for v3. I need to be able to tell Ansible which package to install.
- name: Ensure MySQL-python is installed
pip:
name: MySQL-python
state: present
become: true
when: python_version is regex("^2.*")
- name: Ensure mysqlclient is installed
pip:
name: mysqlclient
state: present
become: true
when: python_version is regex("^3.*")
The regular expression is valid but Ansible is skipping them both even though this:
- debug:
var: python_version
returns this:
TASK [debug] ****************************************************************************************************************************************************************
ok: [localhost] => {
"python_version": "2.7.10"
}