Best practice for performing SQL query inside of Ansible playbook task?
1,317 views
Skip to first unread message
Bruce W. Mohler
unread,
Dec 17, 2019, 5:38:28 PM12/17/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
What is the best practice for performing a SQL query inside of an Ansible playbook task? I know that Ansible provides some builtin MySQL modules but they only allow you to create databases, tables inside of databases, and users. They don't allow you to actually do a query. There's a mysql_query.py library module (https://github.com/teemops/ansible-modules/blob/master/database/mysql_query.py) written back in 2016 that worked up to the point until MySQL required you to authenticate to a UNIX socket rather than a TCP/IP socket.
Someone pointed to an obscure use of the mysql_db module (https://docs.ansible.com/ansible/latest/modules/mysql_db_module.html - see the last import example) do "run a query" but you need to have an external Jinja2 file for each query and I'd prefer something embedded, if possible.