How do I execute MySqL query using Ansible playbook

0 votes
Dear team,

I'm trying to execute MySQL , queries using ansible playbook, kindly provide steps or format of the MySQL command,

Currently I'm planning to use as given below

 - name: "+++Run MySQL query SHOW STATUS+++"
    command: >  ## I can use shell module as well.
      mysql -u {{ user_name }} -p {{ pass }} --db {{ DB_name }}  
      --host={{ h1_ip }} --batch --skip-column-names
      --execute: "show master status;" > /tmp/status
    register: m_status

  - name: "+++The Value of Update_user_status+++"
    debug:
      msg="The Value of Above query {{ m_status.stdout }

Where as DB username, password and schema names are hardcoded in the vars.yml file.
Oct 4 in Ansible by anonymous
• 140 points
2 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Ansible

0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
2,588 views
0 votes
1 answer
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 7,320 points
4,897 views
0 votes
2 answers

How do i install Ansible using virtualenv

Adding to @Mohit's answer,  For CentOS and RHEL: sudo ...READ MORE

answered Jan 10, 2019 in Ansible by Dikinson
4,045 views
0 votes
1 answer

How do I update CentOS using Ansible?

You can use the yum module in the ...READ MORE

answered Feb 4, 2019 in Ansible by Diana
2,656 views
0 votes
1 answer
0 votes
1 answer

How do I add ssh authorized keys in ansible playbook?

Hey @kailash use the authorized_key plugin that ...READ MORE

answered Feb 12, 2019 in Ansible by Kyra
589 views
0 votes
1 answer

How do i set multiple authorized keys to my ansible playbook?

Try this: - name: Set up multiple authorized ...READ MORE

answered Feb 12, 2019 in Ansible by John
680 views
0 votes
1 answer