Skip to content

Management

kako edited this page Apr 30, 2016 · 2 revisions

This document reviews the procedures to set up the salt master and manage minions.

Salt Master

First you need to install salt-master in the box that will be the Salt master. See Installation for instructions.

The default configuration provided for the Master is adequate, but if you need to set advanced options see Configuring the Salt Master.

Repository

The second step is to clone this repository:

cd ~/dev
git clone git@github.com:ESCL/salt-config.git

And create the symbolic links for pillar, states and cloud configurations:

ln -sf <home>/salt-config/pillar /srv/pillar
ln -sf <home>/salt-config/salt /srv/salt
ln -sf <home>/salt-config/cloud/profiles /etc/salt/cloud.profiles
ln -sf <home>/salt-config/cloud/providers /etc/salt/cloud.providers

Start the Service

Now you can start the service:

sudo service salt-master start

And update the bootstrap script required to create new minions with Salt Cloud:

sudo salt-cloud -u

Managing Minions

Once Salt Master and Salt Cloud are set up, you can create and destroy minions easily.

Adding Minions

You only need to specify the profile and box names:

sudo salt-cloud -p pjtracker-demo pjtracker-demo-0 pjtracker-demo-1

The virtual machines are assigned the grains defined in the profiles when created, and then a highstate is applied on them automatically, so they're ready to work.

Finally, you need to add the machines to the listeners for the load balancer.

Destroying Minions

Destroying them is just as easy:

sudo salt-cloud -d pjtracker-demo-0 pjtracker-demo-1

Since non-responsive machines are deactivated automatically by the load balancer, you don't need to update its listeners.

Adding Profiles

The only case in which non-trivial work is required is when a new role, environment, sub-environment or application is added. In that case, new pillar information, states or cloud profiles need to be added.

We'll review the process to add a new sub-environment for pjtracker, which is required when a client requests a dedicated server (and thus, the most common case).

Database

First you need to create a new database instance (through the AWS console when using RDS) and write down its connection parameters.

Repository

Then you make three modifications to the repository:

  • Add application sub-environment pillar
  • Add pillar targeting to apply new sub-environment pillar
  • Add machine profile for sub-environment

In the case of a new sub-environment google for application pjtracker, the pillar would consist of the database connection parameters, and would be located in pillar/pjtracker/google.sls.

The additional targeting to the pillar/top.sls file would be:

'G@app:pjtracker and G@sub_env:google':
  - match: compound
  - pjtracker.google

And the profile to add to cloud/profiles:

pjtracker-google:
  provider: ec2-public-www
  size: t2.medium
  grains:
    box_type: ec2
    app: pjtracker
    env: prod
    sub_env: google

Adding Minions

Once the repository is updated (pulled), you can create the new machines. This step remains the same as for existing environments, so if we wanted to use three boxes for this sub-environment:

sudo salt-cloud -p pjtracker-google pjtracker-google-0 pjtracker-google-1 pjtracker-google-2

Subdomain Configuration

Once the machines are up and running, you need to add them to a new load balancer as listeners, and then create the new DNS record pointing to that load balancer.

Clone this wiki locally