From 862421e80fbb691fe48b461397662fc5f4eb2d5e Mon Sep 17 00:00:00 2001 From: Martin Griesbach Date: Thu, 16 Oct 2014 17:30:04 +0200 Subject: [PATCH 1/3] Added a Vagrant setup to instantly test the formula --- .gitignore | 3 +++ Vagrantfile | 24 ++++++++++++++++++++++++ dev/pillar_top.sls | 3 +++ dev/setup-salt.sh | 15 +++++++++++++++ dev/state_top.sls | 5 +++++ 5 files changed, 50 insertions(+) create mode 100644 .gitignore create mode 100644 Vagrantfile create mode 100644 dev/pillar_top.sls create mode 100644 dev/setup-salt.sh create mode 100644 dev/state_top.sls diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e979701 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vagrant/ +.idea/ +top.sls diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..d26bf7c --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,24 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.box = "ubuntu/trusty64" + config.vm.hostname = "salt" + config.vm.synced_folder "./", "/srv/salt", id: "vagrant-root" + + config.ssh.forward_agent = true + + config.vm.provider :virtualbox do |vb| + # Use VBoxManage to customize the VM. For example to change memory: + vb.customize ["modifyvm", :id, "--memory", "1024"] + end + if Vagrant.has_plugin?("vagrant-cachier") + config.cache.scope = :box + end + + # Set up salt-master and minion + config.vm.provision "shell", path: "dev/setup-salt.sh" +end diff --git a/dev/pillar_top.sls b/dev/pillar_top.sls new file mode 100644 index 0000000..8a14da6 --- /dev/null +++ b/dev/pillar_top.sls @@ -0,0 +1,3 @@ +base: + 'salt': + - salt diff --git a/dev/setup-salt.sh b/dev/setup-salt.sh new file mode 100644 index 0000000..6e4e49e --- /dev/null +++ b/dev/setup-salt.sh @@ -0,0 +1,15 @@ +#!/bin/sh +sudo add-apt-repository ppa:saltstack/salt -y +sudo apt-get update -y +sudo apt-get install salt-master -y +sudo apt-get install salt-minion -y +# Accept all keys# +sleep 5 #give the minion a few seconds to register +sudo salt-key -y -A +# setup top files to test the formula +sudo mkdir -p /srv/pillar +sudo ln -s /srv/salt/pillar.example /srv/pillar/salt.sls +sudo ln -s /srv/salt/dev/pillar_top.sls /srv/pillar/top.sls +# this file will be copied to make a running config. it should not be checked in. +sudo cp /srv/salt/dev/state_top.sls /srv/salt/top.sls + diff --git a/dev/state_top.sls b/dev/state_top.sls new file mode 100644 index 0000000..771046b --- /dev/null +++ b/dev/state_top.sls @@ -0,0 +1,5 @@ +base: + 'salt': + - salt.master + - salt.minion + - salt.cloud \ No newline at end of file From 0c0b1745a835079596ca049ba29583837f509fa8 Mon Sep 17 00:00:00 2001 From: Martin Griesbach Date: Fri, 17 Oct 2014 09:46:33 +0200 Subject: [PATCH 2/3] Vagrant: increased wait to ensure the minion sent it's key to the master before Accepting all keys. --- dev/setup-salt.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dev/setup-salt.sh b/dev/setup-salt.sh index 6e4e49e..dc0a734 100644 --- a/dev/setup-salt.sh +++ b/dev/setup-salt.sh @@ -3,13 +3,12 @@ sudo add-apt-repository ppa:saltstack/salt -y sudo apt-get update -y sudo apt-get install salt-master -y sudo apt-get install salt-minion -y -# Accept all keys# -sleep 5 #give the minion a few seconds to register -sudo salt-key -y -A # setup top files to test the formula sudo mkdir -p /srv/pillar sudo ln -s /srv/salt/pillar.example /srv/pillar/salt.sls sudo ln -s /srv/salt/dev/pillar_top.sls /srv/pillar/top.sls # this file will be copied to make a running config. it should not be checked in. sudo cp /srv/salt/dev/state_top.sls /srv/salt/top.sls - +# Accept all keys# +sleep 15 #give the minion a few seconds to register +sudo salt-key -y -A From ca4a58ec1a57e3e38f1589dbde9d159608bda7ce Mon Sep 17 00:00:00 2001 From: Martin Griesbach Date: Fri, 17 Oct 2014 10:21:24 +0200 Subject: [PATCH 3/3] Added a basic description of Vagrant usage. --- README.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 482602b..a01932f 100644 --- a/README.rst +++ b/README.rst @@ -55,4 +55,13 @@ Every option available in the templates can be set in pillar. Settings under 'sa ``Extending`` ============= -Additional templates can be added by the user under salt/files/minion.d and master.d. This might be useful if, for example, a recently-added configuration option is not yet provided by the default template. +Additional templates can be added by the user under salt/files/minion.d and master.d. This might be useful if, for example, a recently-added configuration option is not yet provided by the default template. + +``Vagrant`` +=========== + +Executing the provided `Vagrantfile `_ will create a Ubuntu 14.04 VM, add the default Saltstack Repository and install the current stable version. + +The folders inside the VM will be set up in a way that enables you to simply execute 'sudo salt "*" state.highstate' to apply the salt formula to the VM, using the pillar.example config. You can check /etc/salt/ for results. + +Remember, you will have to run ``state.highstate`` or ``state.sls salt.(master|minion|cloud)`` manually.