Step-by-step process to install MySQL using Ansible playbook
Step 1: Launch two EC2 Instances,.
one is the master and the one is a slave. with the help of master-slave configuration, we need to install mysql into the slave instance through, the master instance.
Step 2: Install Ansible
$ sudo amazon-linux-extras install ansible2
- Now go to /etc/ and check for ansible…. If package Installed, then go to hosts file and make a
- Master Slave configuration
$cd /etc/ → ls → cd ansible → sudo vi hosts
- Save and exit
- Now, check for newly added ip address from master instance terminal by using command;
ansible all --list-hosts
- Now, make a communication to all the slave instances from Master instance by using command;
ansible all -m ping
- Master – Slave Configuration done successful…!!
- Now, with the help of ansible playbook, we need to install mysql package into the instance.
- So, Now by using Master server we are going to install mysql package in Slave instance…for that am going to create a playbook
Step 3: Make a directory for playbooks and create a ansible playbook file.
$ mkdir playbooks
Step 4: Create a .yml extension filed playbook to install MySQL package.
$sudo vi package.yml
save the file.
Step 5: Run the Playbook
Execute the playbook, by using following command
$ansible-playbook package.yml
Step 6: Verify
Now, check MYSQL is installed or not in slave servers. In slave instance terminal, using command.
$ mysql --version
How To Install MYSQL Using Ansible Playbook ?
Introducing MySQL physically on different servers can be a tedious and mistake-inclined process. Be that as it may, with Ansible, an open-source mechanization apparatus, you can computerize the establishment and setup of MySQL across your framework effectively and proficiently. By allowing you to define MySQL installation steps in a playbook, Ansible makes deployment simpler and eliminates the need for manual intervention. With Ansible playbooks, you can guarantee consistency across servers, lessen sending time, and limit the gamble of mistakes.