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 20, 2020 in Ansible by akhtar
• 38,170 points
409 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 20, 2020 by MD
• 95,060 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
1,675 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,060 points
132 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,060 points
284 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
271 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
1,039 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 7, 2020 in Ansible by MD
• 95,060 points
1,753 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,060 points
263 views