Hey guys,
I have a task in my playbook that looks like this:
- name: Ensure the database user for database
mysql_user: name=‘{{database_user}}’ password=‘{{database_password}}’ priv=‘“{{database}}”.*:ALL’ state=present
ignore_errors: yes
when: “‘instance’ in repos”
{{database}} contains the string “glasgow-locum-group_production”.
ignore_errors still causes the task to fail.
When I run this task without any matching user in the database, it runs fine. If I run the task again, then I get this error:
> TASK: [Ensure the database user for database] *********************************
> fatal: [bravo.farmer.io] => failed to parse: Traceback (most recent call last):
> File "/home/john/.ansible/tmp/ansible-1377268811.91-196684433087208/mysql_user", line 1281, in <module>
> main()
> File "/home/john/.ansible/tmp/ansible-1377268811.91-196684433087208/mysql_user", line 374, in main
> changed = user_mod(cursor, user, host, password, priv)
> File "/home/john/.ansible/tmp/ansible-1377268811.91-196684433087208/mysql_user", line 156, in user_mod
> privileges_revoke(cursor, user,host,db_table)
> File "/home/john/.ansible/tmp/ansible-1377268811.91-196684433087208/mysql_user", line 237, in privileges_revoke
> cursor.execute(query)
> File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
> self.errorhandler(self, exc, value)
> File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
> raise errorclass, errorvalue
> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-locum-group_production.* FROM 'glg'@'localhost'' at line 1")
>
>
> FATAL: all hosts have already failed -- aborting
>
> PLAY RECAP ********************************************************************
> to retry, use: --limit @/var/tmp/ansible/site.retry
I've enabled logging on mysqld and it shows that ansible either fails at or after the following SQL query:
41 Query REVOKE ALL PRIVILEGES ON glasgow-locum-group_production.* FROM ‘glg’@‘localhost’
Any help would be really appreciated!
Best,
JH