How to launch MySQL docker container using Ansible playbook

0 votes

Hi Guys,

I have configured Ansible in my system. I want to launch one MySQL container using Ansible playbook. How can I do that?

Sep 21, 2020 in Ansible by akhtar
• 38,260 points
4,204 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use docker_container module in your Ansible playbook to launch MySQL container. I have attached one playbook below for your reference.

vars:
  docker_volume: db_data
  docker_network: ansible_net
  db_name: db

- name: "Launch database container"
  docker_container:
    name: "{{ db_name }}"
    image: mysql:5.7
  volumes:
    - "{{ docker_volume }}:/var/lib/mysql:rw"
  restart: true
  networks:
  - name: "{{ docker_network }}"
  alias:
  - "{{ db_name }}"
  env:
    MYSQL_ROOT_PASSWORD: wordpress
    MYSQL_DATABASE: wordpress
    MYSQL_USER: wordpress
    MYSQL_PASSWORD: wordpress
answered Sep 21, 2020 by MD
• 95,460 points

Related Questions In Ansible

0 votes
1 answer

How to pull a docker image using Ansible playbook?

Did you try using this? https://docs.ansible.com/ansible/latest/colle ...READ MORE

answered Nov 5, 2020 in Ansible by undermink
10,809 views
0 votes
1 answer

How to create a docker container using Ansible?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Sep 20, 2020 in Ansible by MD
• 95,460 points
1,110 views
0 votes
1 answer

How to start a docker container with healthstatus using Ansible?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Sep 20, 2020 in Ansible by MD
• 95,460 points
3,020 views
0 votes
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,680 points
1,114 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,100 points
2,689 views
0 votes
1 answer

How to create a docker container using Ansible playbook?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Aug 8, 2020 in Ansible by MD
• 95,460 points
4,292 views
0 votes
1 answer

How to launch an EC2 instance using Ansible Playbook?

Hi@akhtar, Ansible has one module named ec2. This ...READ MORE

answered Aug 12, 2020 in Ansible by MD
• 95,460 points
2,008 views
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