At a high level I would look at adjusting the query so that it returns json: https://dev.mysql.com/doc/refman/5.7/en/json-creation-functions.html
Register the output, and then set your values in a set_fact task. And I would try to change the authorization setup so you don’t have to echo throw root passwords around in shell commands. Dick On Fri, 30 Aug 2019 at 06:44, Mohtashim S <[email protected]> wrote: > Below is my playbook with a single SQL query that fetches 3 columns from > MYSQL database. > > I wish to read the values returned if any in three different variables. > > - name: "Fetch from Database" > tags: validateA > command: > > mysql --user=root --password=mypass@d deployment > --host=localhost -Ns -e "SELECT status,layer,environment FROM > my_database WHERE num LIKE '{{ Number }}' AND status LIKE 'Deploy'" > failed_when: ('{{ Number }}' not in command_result.stdout) or > command_result.rc != 0 > > Thus, variable1 should have the output of status > variable2 should have the output of layer > variable3 should have the output of environment > > This will help me get the results with one query fired instead of Running > three seperate queries one for each column. > > Please let me know if and how is it possible ? > > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/1c6a4beb-4d10-4db0-97aa-3f4c2e626a9f%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/1c6a4beb-4d10-4db0-97aa-3f4c2e626a9f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Sent from a mobile device - please excuse the brevity, spelling and punctuation. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwNK_%2BaA%2Brn9B41UGbt1-W7tThcgJ3DkrTOyxR0AvBeReQ%40mail.gmail.com.
