-
Notifications
You must be signed in to change notification settings - Fork 0
Management
This document reviews the procedures to set up the salt master and manage minions.
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.
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
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
Once Salt Master and Salt Cloud are set up, you can create and destroy minions easily.
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 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.
The only case in which human intervention 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.
First you need to create a new database instance (through the AWS console when using RDS) and write down its connection parameters.
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
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
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.