---
title: "MariaDB DevOps: Installing MariaDB with SaltStack"
publish_date: 2015-02-11
updated_date: 2019-08-20
author: "Geoff Montee"
---

# MariaDB DevOps: Installing MariaDB with SaltStack

![SaltStacklogo](/sites/default/files/pictures/Images/SaltStacklogo.png)I have been thinking about how I could streamline my deployment and configuration of MariaDB with [salt](http://saltstack.com/) for a while now. When I decided to give it a shot, I didn’t find any formulas that I liked, so I decided to start writing [my own](https://github.com/GeoffMontee/mariadb-saltstack-formula). Currently, my salt formula can deploy MariaDB 5.5, MariaDB Galera Cluster 5.5, MariaDB 10.0, or MariaDB Galera Cluster 10.0 to a CentOS 6 or 7 server.

## How do I use this formula?

I’ll go through the basic setup process of a SaltStack master and minion on CentOS 7. If you’re curious to know more about salt, check out the [documentation](http://docs.saltstack.com/en/latest/).

### Set up a salt master

To set up a salt master, first execute the following commands:

```
sudo yum install epel-release
sudo yum install salt-master
sudo firewall-cmd --permanent --zone=public --add-port=4505-4506/tcp
sudo firewall-cmd --reload
sudo mkdir -p /srv/salt/
cd /srv/salt/
git clone https://github.com/GeoffMontee/mariadb-saltstack-formula.git

```

Then add the following to */etc/salt/master*:

```
file_roots:
    base:
        - /srv/salt/mariadb-saltstack-formula

```

We should also create a [top file](http://docs.saltstack.com/en/latest/ref/states/top.html) (which configures the [highstate](http://docs.saltstack.com/en/latest/ref/states/highstate.html). In this case, let’s set up */srv/salt/mariadb-saltstack-formula/top.sls* to make all hosts run MariaDB 10.0 (so they will invoke the *mariadb\_10\_0* state by default):

```
base:
    '*':
        - mariadb_10_0

```

Now, start the master (and make sure it always starts on reboot):

```
sudo chkconfig salt-master on
sudo service salt-master start

```

### Set up a salt minion

To set up a salt minion, first execute the following commands (replace the IP address with that of your master):

```
sudo yum install epel-release
sudo yum install salt-minion
echo "master: 192.168.1.30" | sudo tee -a /etc/salt/minion
sudo chkconfig salt-minion on
sudo service salt-minion start

```

### Accept the minion’s key

Now that the minion is connecting to the master, the master has to either accept or reject the minion’s public key. Use [salt-key](http://docs.saltstack.com/en/latest/ref/cli/salt-key.html) for this. First, see which private keys have not been accepted yet:

```
sudo salt-key -L

```

If you don’t see anything suspicious, you can accept them all with:

```
sudo salt-key -A

```

### Deploy MariaDB via salt

In one of the steps above, we setup the *top file* to make all of our servers use the MariaDB 10.0 state as their *highstate*. Let’s make them execute their highstate now:

```
sudo salt '*' state.highstate

```

If instead, we wanted to deploy a specific version of MariaDB to a particular server, we could do that:

```
sudo salt '192.168.1.31' state.sls mariadb_galera_10_0

```

### Thoughts?

As I improve my skills with *salt*, I will probably improve my formulas. Is there anything that you want to see in a formula? Is anyone already doing cool or useful things with *salt* and *MariaDB*? Share your thoughts or tips in the comments.