ansible-postgresql-on-el6
ansible-postgresql-on-el6 copied to clipboard
Error running on Ansible v2
After upgrading to Ansible (2.0.1.0) I'm unable to get past Stage 1:
TASK [postgresql : Stage 1: install repository package] ************************ fatal: [axiom]: FAILED! => {"failed": true, "msg": "'str object' has no attribute 'repo'"} to retry, use: --limit @webservers.retry
- name: "Stage 1: install repository package" yum: state: present pkg: "{{ item.repo }}" when: item.version == "{{ postgresql_version }}" with_items: postgresql_repo_{{ ansible_distribution }} tags: - postgresql
From what I can tell it isn't expanding the postgresql_repo_{{ ansible_distribution }} variable properly. If I hard code the variable name to 'postgresql_repo_CentOS' the play works.
I got similar error but with postgresql_version
fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional check 'item.version == \"{{ postgresql_version }}\"' failed. The error was: error while evaluating conditional (item.version == \"{{ postgresql_version }}\"): 'unicode object' has no attribute 'version'\n\nThe error appears to have been in '/home/dbax/projects/scripts/ansible-postgresql-on-el6/tasks/install.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"Stage 1: install repository package\"\n ^ here\nThis one looks easy to fix. It seems that there is a value started\nwith a quote, and the YAML parser is expecting to see the line ended\nwith the same kind of quote. For instance:\n\n when: \"ok\" in result.stdout\n\nCould be written as:\n\n when: '\"ok\" in result.stdout'\n\nOr equivalently:\n\n when: \"'ok' in result.stdout\"\n"}
Just replace in install.yml
when: item.version is defined
# when: item.version == " {{ postgresql_version }} "
and this is correct way:
with_items: postgresql_repo_{{ ansible_distribution }}