Managing Servers: Getting started with Salt

Installing Salt

First I installed Xubuntu in a virtual environment to serve as my testing ground. Then I proceeded to update the system and install Salt using the following commands:

sudo apt-get update
sudo apt-get install -y salt-master salt-minion

After this I edited the minion-file at /etc/salt/minion and added the ip-address for the master and an id.
I restarted the service and accepted the keys.

unaccepted_keys

Next I ran some commands to see if my new set up was working.
sudo salt ‘*’ test.ping   (pictured)
sudo salta ‘*’ cmd.run ‘whoami’

test_ping

Creating States

After this I wrote up some states. First one I did was a basic ‘Hello World’ test to see if I could even get any states working.

When this test worked as planned I moved onto modifying the lamp.sls state from Joona Leppälahti’s Salt project. I only used the first function to see if it worked.

After this I wrote my own state to verify that I had understood the basic principles correctly.

state_code

This yielded a successful result, like the previous two tests.

Using salt-grains to get statistics

Using the command: sudo salt ‘*’ grains.items I got a list of statistics from my computer.
Using sudo salt ‘*’ grains.items|less I got a more condensed version of it.
As my computer is a virtual machine in this case, a lot of the data is unknown or replaced by VirtualBox.

Sources:

Course Info by Tero Karvinen

Salt Quickstart by Tero Karvinen

Salt States by Tero Karvinen

Joona Leppälahti CCM

SaltStack

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s