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, 2021 in Ansible by anonymous
• 140 points
3,248 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
4,155 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,340 points
6,890 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
5,579 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
4,010 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
1,530 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
1,446 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP