In the next task, I get an error message. Unable to look up a name or access an attribute in template string. Make sure your variable name does not contain invalid characters like '-'.I traced it to the suggestion when.
Using debug statements, I confirmed:
mysql_server_version='5.2.23'mysql_client_version='5.2.23'mysql_version='5.2.23'
If I delete the statement when, the task starts.
- name: download MySQL packages
tags:
- preosupdates
when: "{{ mysql_server_version | version_compare(mysql_version, '<') or mysql_client_version | version_compare(mysql_version, '<') }}"
command: yum update -y --downloadonly MySQL-server-advanced-{{ mysql_version }} MySQL-shared-compat-advanced-{{ mysql_version }} MySQL-client-advanced-{{ mysql_version }}
register: downloadonly
failed_when: downloadonly.rc not in (1, 0)
changed_when: "downloadonly is defined and 'No Packages marked for Update' not in downloadonly.stdout"
Version
Danny source
share