Our target is to make environment to stacksalt so that we can install+work with salt from multiple machines(virtual) and after we have done everything we can delete the environment. This way our ubuntu can be safe from harmful installations.
This is from: http://www.giantflyingsaucer.com/blog/?p=5001
Lets make 3 folders in our desktop where we want to make the environment:
$ cd
$ cd VagrantBoxes
$ mkdir salt-master
$ mkdir salt-minion1
$ mkdir salt-minion2
$ cd salt-master
$ vagrant init ubuntu/trusty64
$ cd ..
$ cd salt-minion1
$ vagrant init ubuntu/trusty64
$ cd ..
$ cd salt-minion2
$ vagrant init ubuntu/trusty64
Open 3 separate terminals for each master/minion1/minion2
in Vagrant file of master:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "salt-master"
end
in Vagrant file of minion1:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.11"
config.vm.hostname = "salt-minion1"
end
in Vagrant file of minion2:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.12"
config.vm.hostname = "salt-minion2"
end
in all 3 terminals:
$ vagrant up
...
...
...
$ vagrant ssh
you will notice in master terminal vagrant@salt-master:~$
you will notice in minion terminals vagrant@salt-minion1:~$
vagrant@salt-minion2:~$
which means our Vagrant file config:config.vm.hostname = <name>
is working
Start the virtual box GUI see that all 3 machines are running.
In all 3 terminal:
$ sudo apt-get install python-software-properties
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:saltstack/salt
$ sudo apt-get update
In master terminal:
$ sudo apt-get install salt-master
In both minion terminals:
$ sudo apt-get install salt-minion
Once the salt-minion package is installed run the following on the Minion Terminal1:
$ sudo nano /etc/salt/minionChange:
\# master: salt
to:master: 192.168.33.10
Save and exit
ctrl+x -> Y -> enter
Once we updated the /etc/salt/minion file we need to restart the service. From Minion Terminal1:
$ sudo service salt-minion restartExpected output:
salt-minion stop/waiting salt-minion start/running, process 6207
Ok, now we need to add the salt-minion1 key to the salt-master. From Master Terminal:
$ sudo salt-key -LThis should display the following:
Accepted Keys: Unaccepted Keys: salt-minion1 Rejected Keys:
From Master Terminal:
$ sudo salt-key -a 'salt-minion1'
Note: You will be promoted with a yes/no.
Verify the key was added. From the Master Terminal:
$ sudo salt-key -LExpected output:
Accepted Keys: salt-minion1 Unaccepted Keys: Rejected Keys:
Do the exact same thing to add salt-minion2. After adding minion2 from salt-master:
Accepted Keys:
salt-minion1
salt-minion2
Unaccepted Keys:
Rejected Keys:
Assuming everything went well, lets try to ping our minions (in this case just one). From Master Terminal run the following:
$ sudo salt '*' test.ping
Expected output:
salt-minion1: True salt-minion2: True
Let’s find the Minion’s IP address. From the Master Terminal:
$ sudo salt 'salt-minion1' network.ip_addrs
Expected output:
salt-minion1: - 10.0.2.15 - 192.168.33.11
Try some other commands for fun from the Master Terminal:
$ sudo salt 'salt-minion1' cmd.run 'ls -l /etc/salt'
$ sudo salt 'salt-minion1' disk.percent
$ sudo salt 'salt-minion1' network.interfaces
That’s it. You now have a simple Salt playground to experiment with. Stay tuned for my next tutorial to show you how to do more with Salt.
Final Notes: If you have UFW enabled (it won’t be enabled by default) you need to do the following on both terminals:
$ sudo ufw allow saltsee more here: http://docs.saltstack.com/en/latest/topics/tutorials/firewall.html