vagrant-salt 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rst CHANGED
@@ -21,7 +21,7 @@ to deploy for other environments.
21
21
 
22
22
  There are two different ways to use `Salty Vagrant`_. The simplest way uses
23
23
  the salt minion in a masterless configuration. With this option you distribute
24
- your state tree along with your Vagrantfile and a dev minion config. The
24
+ your state tree along with your Vagrantfile and a minion config. The
25
25
  minion will bootstrap itself and apply all necessary states.
26
26
 
27
27
  The second method lets you specify a remote salt master, which assures that
@@ -36,12 +36,12 @@ Masterless (Quick Start)
36
36
  1. Install `Vagrant`_
37
37
  2. Install `Salty Vagrant`_ (``vagrant gem install vagrant-salt``)
38
38
  3. Get the Ubuntu 12.04 base box: ``vagrant box add precise64 http://files.vagrantup.com/precise64.box``
39
- 4. Create/Update your ``Vagrantfile`` (Detailed in `Configuration`_)
40
- 5. Place your salt state tree in ``salt/roots/salt``
41
- 6. Place your minion config in ``salt/minion`` [#file_client]_
42
- 7. Run ``vagrant up`` and you should be good to go.
39
+ 4. Create/Update your ``Vagrantfile`` (Detailed in `Configuration`_) [#shared_folders]_
40
+ 5. Place your minion config in ``salt/minion`` [#file_client]_
41
+ 6. Run ``vagrant up`` and you should be good to go.
43
42
 
44
43
  .. [#file_client] Make sure your minion config sets ``file_client: local`` for masterless
44
+ .. [#shared_folders] Don't forget to create a shared folder for your salt file root
45
45
 
46
46
  Using Remote Salt Master
47
47
  ========================
@@ -62,7 +62,7 @@ On the master, create the keypair and add the public key to the accepted minions
62
62
  folder::
63
63
 
64
64
  root@saltmaster# salt-key --gen-keys=[minion_id]
65
- root@saltmaster# cp minion_id.pub /etc/salt/pki/minions/[minion_id]
65
+ root@saltmaster# cp [minion_id].pub /etc/salt/pki/minions/[minion_id]
66
66
 
67
67
  Replace ``[minion_id]`` with the id you would like to assign the minion.
68
68
 
@@ -102,24 +102,27 @@ Configuration
102
102
  Your ``Vagrantfile`` should look roughly like this::
103
103
 
104
104
  Vagrant::Config.run do |config|
105
+ ## Chose your base box
105
106
  config.vm.box = "precise64"
107
+
108
+ ## For masterless, mount your salt file root
109
+ config.vm.share_folder "salt_file_root", "/srv", "/path/to/salt_file_root"
110
+
111
+
106
112
  ## Use all the defaults:
107
113
  config.vm.provision :salt do |salt|
108
114
  salt.run_highstate = true
109
115
 
110
116
  ## Optional Settings:
111
117
  # salt.minion_config = "salt/minion.conf"
112
-
113
- ## Only Use these with a masterless setup to
114
- ## load your state tree:
115
- # salt.salt_file_root_path = "salt/roots/salt"
116
- # salt.salt_pillar_root_path = "salt/roots/pillar"
118
+ # salt.temp_config_dir = "/existing/folder/on/basebox/"
119
+ # salt.salt_install_type = "git"
120
+ # salt.salt_install_args = "develop"
117
121
 
118
122
  ## If you have a remote master setup, you can add
119
123
  ## your preseeded minion key
120
- # salt.master = true
121
- # salt.minion_key = "salt/key/testing.pem"
122
- # salt.minion_pub = "salt/key/testing.pub"
124
+ # salt.minion_key = "salt/key/minion.pem"
125
+ # salt.minion_pub = "salt/key/minion.pub"
123
126
  end
124
127
  end
125
128
 
@@ -129,58 +132,98 @@ depending on whether you are running masterless or with a remote master.
129
132
  minion_config : "salt/minion.conf"
130
133
  Path to your minion configuration file.
131
134
 
135
+ temp_config_dir : "/tmp"
136
+ Path on the guest box that the minion files will be copied to before
137
+ placing in the salt directories. (Not all distros support "/tmp")
138
+
132
139
  minion_key : false
133
140
  String path to your minion key. Only useful with ``master=true``
134
141
 
135
142
  minion_pub : false
136
143
  String path to your minion public key. Only useful with ``master=true``
137
144
 
138
- master : false
139
- Boolean whether or not you want to use a remote master. If set to false,
140
- make sure your minion config file has ``file_client: local`` set.
141
-
142
- salt_file_root_path : "salt/roots/salt"
143
- String path to your salt state tree. Only useful with ``master=false``.
145
+ salt_install_type : "stable" : "daily" : "git"
146
+ Whether to install from a distribution's stable package manager, a
147
+ daily ppa, or git treeish.
144
148
 
145
- salt_file_root_guest_path : "/srv/salt"
146
- Path to share the file root state tree on the VM. Only use with ``master=false``.
149
+ salt_install_args : ""
150
+ When performing a git install, you can specify a branch, tag, or
151
+ any treeish.
147
152
 
148
- salt_pillar_root_path : "salt/roots/pillar"
149
- Path to share your pillar tree. Only useful with ``master=false``.
150
-
151
- salt_pillar_root_guest_path : "/srv/pillar"
152
- Path on VM where pillar tree will be shared. Only use with ``master=true``
153
153
 
154
154
  Bootstrapping Salt
155
155
  ==================
156
156
 
157
- Before `Salt`_ can be used for provisioning on the target virtual box, the binaries need to be installed. Since `Vagrant`_ and `Salt`_ support many different distributions and versions of operating systems, the `Salt`_ installation process is handled by the shell script ``scripts/bootstrap-salt-minion.sh``. This script runs through a series of checks to determine operating system type and version to then install the `Salt`_ binaries using the appropriate methods.
157
+ Before `Salt`_ can be used for provisioning on the target virtual box, the
158
+ binaries need to be installed. Since `Vagrant`_ and `Salt`_ support many
159
+ different distributions and versions of operating systems, the `Salt`_
160
+ installation process is handled by the shell script
161
+ ``scripts/bootstrap-salt-minion.sh``. This script runs through a series of
162
+ checks to determine operating system type and version to then install the
163
+ `Salt`_ binaries using the appropriate methods.
158
164
 
159
165
  Adding support for other operating systems
160
166
  ------------------------------------------
161
-
162
- Below is an example for targeting an installation for Debian Squeeze which first checks for the ``/etc/debian_version`` file and then determines the version using ``cat /etc/debian_version``::
163
-
164
- (...)
165
- elif [ -f /etc/debian_version ] ; then
166
- DVER=$(cat /etc/debian_version)
167
- if [ $DVER = '6.0' ]; then
168
- log "Installing for Debian Squeeze."
169
- do_with_root echo "deb http://backports.debian.org/debian-backports squeeze-backports main" >> /etc/apt/sources.list.d/backports.list
170
- do_with_root apt-get update
171
- do_with_root apt-get -t squeeze-backports -y install salt-minion
172
- else
173
- log "Debian version $VER not supported."
174
- exit 1
175
- fi
176
- (...)
177
-
178
- The bootstrapping script must be plain POSIX sh only, **not** bash or another shell script. By design the targeting for each operating system and version is very specific. Assumptions of supported versions or variants should not be made, to avoid failed or broken installations.
167
+ In order to install salt for a distribution you need to define:
168
+
169
+ To Install Dependencies, which is required, one of:
170
+ 1. install_<distro>_<distro_version>_<install_type>_deps
171
+ 2. install_<distro>_<distro_version>_deps
172
+ 3. install_<distro>_<install_type>_deps
173
+ 4. install_<distro>_deps
174
+
175
+
176
+ To install salt, which, of course, is required, one of:
177
+ 1. install_<distro>_<distro_version>_<install_type>
178
+ 2. install_<distro>_<install_type>
179
+
180
+ Optionally, define a minion configuration function, which will be called if
181
+ the -c|config-dir option is passed. One of:
182
+ 1. config_<distro>_<distro_version>_<install_type>_minion
183
+ 2. config_<distro>_<distro_version>_minion
184
+ 3. config_<distro>_<install_type>_minion
185
+ 4. config_<distro>_minion
186
+ 5. config_minion [THIS ONE IS ALREADY DEFINED AS THE DEFAULT]
187
+
188
+ Also optionally, define a post install function, one of:
189
+ 1. install_<distro>_<distro_versions>_<install_type>_post
190
+ 2. install_<distro>_<distro_versions>_post
191
+ 3. install_<distro>_<install_type>_post
192
+ 4. install_<distro>_post
193
+
194
+ Below is an example for Ubuntu Oneiric:
195
+
196
+ install_ubuntu_1110_deps() {
197
+ apt-get update
198
+ apt-get -y install python-software-properties
199
+ add-apt-repository -y 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'
200
+ add-apt-repository -y ppa:saltstack/salt
201
+ }
202
+
203
+ install_ubuntu_1110_post() {
204
+ add-apt-repository -y --remove 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'
205
+ }
206
+
207
+ install_ubuntu_stable() {
208
+ apt-get -y install salt-minion
209
+ }
210
+
211
+ Since there is no ``install_ubuntu_1110_stable()`` it defaults to the
212
+ unspecified version script.
213
+
214
+ The bootstrapping script must be plain POSIX sh only, **not** bash or another
215
+ shell script. By design the targeting for each operating system and version is
216
+ very specific. Assumptions of supported versions or variants should not be
217
+ made, to avoid failed or broken installations.
179
218
 
180
219
  Supported Operating Systems
181
220
  ---------------------------
182
221
  - Ubuntu 10.x/11.x/12.x
183
222
  - Debian 6.x
223
+ - CentOS 6.3
224
+ - Fedora
225
+ - Arch
226
+ - FreeBSD 9.0
184
227
 
185
228
  Installation Notes
186
229
  ==================
@@ -204,3 +247,5 @@ Installing from source
204
247
  3. ``cd saltstack-salty-vagrant-[hash]``
205
248
  4. ``gem build vagrant-salt.gemspec``
206
249
  5. ``vagrant gem install vagrant-salt-[version].gem``
250
+
251
+ .. vim: fenc=utf-8 spell spl=en cc=80 tw=79 fo=want sts=2 sw=2 et
data/example/Vagrantfile CHANGED
@@ -1,25 +1,26 @@
1
- require "../lib/vagrant-salt"
1
+ # require "../lib/vagrant-salt"
2
2
 
3
3
  Vagrant::Config.run do |config|
4
+ ## Chose your base box
4
5
  config.vm.box = "precise64"
6
+
7
+ ## For masterless, mount your salt file root
8
+ config.vm.share_folder "salt_file_root", "/srv", "salt/roots/"
9
+
10
+
5
11
  ## Use all the defaults:
6
12
  config.vm.provision :salt do |salt|
7
- salt.run_highstate = true
8
-
13
+ salt.run_highstate = false
9
14
 
10
15
  ## Optional Settings:
11
16
  # salt.minion_config = "salt/minion.conf"
12
- # salt.salt_install_type = "daily"
13
-
14
- ## Only Use these with a masterless setup to
15
- ## load your state tree:
16
- # salt.salt_file_root_path = "salt/roots/salt"
17
- # salt.salt_pillar_root_path = "salt/roots/pillar"
17
+ # salt.temp_config_dir = "/existing/folder/on/basebox/"
18
+ # salt.salt_install_type = "git"
19
+ # salt.salt_install_args = "develop"
18
20
 
19
- ## If you have a remote master setup, you can add
20
- ## your preseeded minion key
21
- # salt.master = true
22
- # salt.minion_key = "salt/key/testing.pem"
23
- # salt.minion_pub = "salt/key/testing.pub"
21
+ ## If you have a remote master setup, you can add
22
+ ## your preseeded minion key
23
+ # salt.minion_key = "salt/key/minion.pem"
24
+ # salt.minion_pub = "salt/key/minion.pub"
24
25
  end
25
26
  end
@@ -2,26 +2,18 @@ module VagrantSalt
2
2
  class Provisioner < Vagrant::Provisioners::Base
3
3
  class Config < Vagrant::Config::Base
4
4
  attr_accessor :minion_config
5
+ attr_accessor :temp_config_dir
5
6
  attr_accessor :minion_key
6
7
  attr_accessor :minion_pub
7
- attr_accessor :master
8
8
  attr_accessor :run_highstate
9
- attr_accessor :salt_file_root_path
10
- attr_accessor :salt_file_root_guest_path
11
- attr_accessor :salt_pillar_root_path
12
- attr_accessor :salt_pillar_root_guest_path
13
9
  attr_accessor :salt_install_type
14
10
  attr_accessor :salt_install_args
15
11
 
16
12
  def minion_config; @minion_config || "salt/minion.conf"; end
13
+ def temp_config_dir; @temp_config_dir || "/tmp/"; end
17
14
  def minion_key; @minion_key || false; end
18
15
  def minion_pub; @minion_pub || false; end
19
- def master; @master || false; end
20
16
  def run_highstate; @run_highstate || false; end
21
- def salt_file_root_path; @salt_file_root_path || "salt/roots/salt"; end
22
- def salt_file_root_guest_path; @salt_file_root_guest_path || "/srv/salt"; end
23
- def salt_pillar_root_path; @salt_pillar_root_path || "salt/roots/pillar"; end
24
- def salt_pillar_root_guest_path; @salt_pillar_root_guest_path || "/srv/pillar"; end
25
17
  def salt_install_type; @salt_install_type || ''; end
26
18
  def salt_install_args; @salt_install_args || ''; end
27
19
 
@@ -31,7 +23,12 @@ module VagrantSalt
31
23
  end
32
24
 
33
25
  def bootstrap_options
34
- '%s %s' % [salt_install_type, salt_install_args]
26
+ options = ''
27
+ if temp_config_dir
28
+ options = options + '-c %s' % temp_config_dir
29
+ end
30
+ options = options + ' %s %s' % [salt_install_type, salt_install_args]
31
+ return options
35
32
  end
36
33
  end
37
34
 
@@ -42,15 +39,6 @@ module VagrantSalt
42
39
  def prepare
43
40
  # Calculate the paths we're going to use based on the environment
44
41
  @expanded_minion_config_path = config.expanded_path(env[:root_path], config.minion_config)
45
- if !config.master
46
- env[:ui].info "Adding state tree folders."
47
- @expanded_salt_file_root_path = config.expanded_path(env[:root_path], config.salt_file_root_path)
48
- @expanded_salt_pillar_root_path = config.expanded_path(env[:root_path], config.salt_pillar_root_path)
49
- check_salt_file_root_path
50
- check_salt_pillar_root_path
51
- share_salt_file_root_path
52
- share_salt_pillar_root_path
53
- end
54
42
 
55
43
  if config.minion_key
56
44
  @expanded_minion_key_path = config.expanded_path(env[:root_path], config.minion_key)
@@ -58,28 +46,6 @@ module VagrantSalt
58
46
  end
59
47
  end
60
48
 
61
- def check_salt_file_root_path
62
- if !File.directory?(@expanded_salt_file_root_path)
63
- raise "Salt file root path does not exist: #{@expanded_salt_file_root_path}"
64
- end
65
- end
66
-
67
- def check_salt_pillar_root_path
68
- if !File.directory?(@expanded_salt_pillar_root_path)
69
- raise "Salt pillar root path does not exist: #{@expanded_salt_pillar_root_path}"
70
- end
71
- end
72
-
73
- def share_salt_file_root_path
74
- env[:ui].info "Sharing file root folder."
75
- env[:vm].config.vm.share_folder("salt_file_root", config.salt_file_root_guest_path, @expanded_salt_file_root_path)
76
- end
77
-
78
- def share_salt_pillar_root_path
79
- env[:ui].info "Sharing pillar root path."
80
- env[:vm].config.vm.share_folder("salt_pillar_root", config.salt_pillar_root_guest_path, @expanded_salt_pillar_root_path)
81
- end
82
-
83
49
  def salt_exists
84
50
  env[:ui].info "Checking for salt binaries..."
85
51
  if env[:vm].channel.test("which salt-call") and
@@ -97,8 +63,9 @@ module VagrantSalt
97
63
  env[:vm].channel.sudo("chmod +x /tmp/bootstrap-salt-minion.sh")
98
64
  bootstrap = env[:vm].channel.sudo("/tmp/bootstrap-salt-minion.sh %s" % config.bootstrap_options) do |type, data|
99
65
  if data[0] == "\n"
100
- # Remove any leading newline but not whitespace, for that one would use data.lstrip
101
- data = data[1..-1]
66
+ # Remove any leading newline but not whitespace. If we wanted to
67
+ # remove newlines and whitespace we would have used data.lstrip
68
+ data = data[1..-1]
102
69
  end
103
70
  env[:ui].info(data.rstrip)
104
71
  end
@@ -127,34 +94,27 @@ module VagrantSalt
127
94
 
128
95
  def upload_minion_config
129
96
  env[:ui].info "Copying salt minion config to vm."
130
- env[:vm].channel.upload(@expanded_minion_config_path.to_s, "/tmp/minion")
131
- env[:vm].channel.sudo("mv /tmp/minion /etc/salt/minion")
97
+ env[:vm].channel.upload(@expanded_minion_config_path.to_s, config.temp_config_dir + "minion")
132
98
  end
133
99
 
134
100
  def upload_minion_keys
135
101
  env[:ui].info "Uploading minion key."
136
- env[:vm].channel.upload(@expanded_minion_key_path.to_s, "/tmp/minion.pem")
137
- env[:vm].channel.sudo("mv /tmp/minion.pem /etc/salt/pki/minion.pem")
138
- env[:vm].channel.upload(@expanded_minion_pub_path.to_s, "/tmp/minion.pub")
139
- env[:vm].channel.sudo("mv /tmp/minion.pub /etc/salt/pki/minion.pub")
102
+ env[:vm].channel.upload(@expanded_minion_key_path.to_s, config.temp_config_dir + "minion.pem")
103
+ env[:vm].channel.upload(@expanded_minion_pub_path.to_s, config.temp_config_dir + "minion.pub")
140
104
  end
141
105
 
142
106
  def provision!
143
107
 
144
- if !config.master
145
- verify_shared_folders([config.salt_file_root_guest_path, config.salt_pillar_root_guest_path])
146
- end
147
-
148
- if !salt_exists
149
- bootstrap_salt_minion
150
- end
151
-
152
108
  upload_minion_config
153
109
 
154
110
  if config.minion_key
155
111
  upload_minion_keys
156
112
  end
157
113
 
114
+ if !salt_exists
115
+ bootstrap_salt_minion
116
+ end
117
+
158
118
  call_highstate
159
119
  end
160
120
 
@@ -168,4 +128,7 @@ module VagrantSalt
168
128
  end
169
129
  end
170
130
  end
131
+
171
132
  end
133
+
134
+ # vim: fenc=utf-8 spell spl=en cc=80 sts=2 sw=2 et
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # BUGS: https://github.com/saltstack/salty-vagrant/issues
11
11
  # AUTHOR: Pedro Algarvio (s0undt3ch), pedro@algarvio.me
12
- # Alec Koumjian (akoumjian)
12
+ # Alec Koumjian (akoumjian), akoumjian@gmail.com
13
13
  # ORGANIZATION: Salt Stack (saltstack.org)
14
14
  # CREATED: 10/15/2012 09:49:37 PM WEST
15
15
  #===============================================================================
@@ -45,20 +45,23 @@ usage() {
45
45
  Options:
46
46
  -h|help Display this message
47
47
  -v|version Display script version
48
+ -c|config-dir Temporary minion configuration directory
48
49
  EOT
49
50
  } # ---------- end of function usage ----------
50
51
 
51
52
  #-----------------------------------------------------------------------
52
53
  # Handle command line arguments
53
54
  #-----------------------------------------------------------------------
55
+ TEMP_CONFIG_DIR="null"
54
56
 
55
- while getopts ":hv" opt
57
+ while getopts ":hvc:" opt
56
58
  do
57
59
  case $opt in
58
60
 
59
- h|help ) usage; exit 0 ;;
61
+ h|help ) usage; exit 0 ;;
60
62
 
61
- v|version ) echo "$0 -- Version $ScriptVersion"; exit 0 ;;
63
+ v|version ) echo "$0 -- Version $ScriptVersion"; exit 0 ;;
64
+ c|config-dir ) TEMP_CONFIG_DIR="$OPTARG" ;;
62
65
 
63
66
  \? ) echo "\n Option does not exist : $OPTARG\n"
64
67
  usage; exit 1 ;;
@@ -84,7 +87,7 @@ if [ $ITYPE = "git" ]; then
84
87
  if [ "$#" -eq 0 ];then
85
88
  GIT_REV="master"
86
89
  else
87
- GIT_REV=$1
90
+ GIT_REV="$1"
88
91
  shift
89
92
  fi
90
93
  fi
@@ -103,15 +106,54 @@ if [ $(whoami) != "root" ] ; then
103
106
  fi
104
107
 
105
108
 
109
+ #--- FUNCTION ----------------------------------------------------------------
110
+ # NAME: __exit_cleanup
111
+ # DESCRIPTION: Cleanup any leftovers after script has ended
112
+ #-------------------------------------------------------------------------------
113
+ __exit_cleanup() {
114
+ EXIT_CODE=$?
115
+
116
+ # Remove the logging pipe when the script exits
117
+ echo " * Removing the logging pipe $LOGPIPE"
118
+ rm -f $LOGPIPE
119
+
120
+ # Kill tee when exiting, CentOS, at least requires this
121
+ TEE_PID=$(ps ax | grep tee | grep $LOGFILE | awk '{print $1}')
122
+
123
+ [ "x$TEE_PID" = "x" ] && exit $EXIT_CODE
124
+
125
+ echo " * Killing logging pipe tee's with pid(s): $TEE_PID"
126
+
127
+ # We need to trap errors since killing tee will cause a 127 errno
128
+ # We also do this as late as possible so we don't "mis-catch" other errors
129
+ __trap_errors() {
130
+ echo "Errors Trapped: $EXIT_CODE"
131
+ # Exit with the "original" exit code, not the trapped code
132
+ exit $EXIT_CODE
133
+ }
134
+ # Bash understands ERR trap signal, FreeBSD does not
135
+ trap "__trap_errors" ERR >/dev/null 2>&1 || trap "__trap_errors" INT KILL QUIT
136
+
137
+ # Now we're "good" to kill tee
138
+ kill -TERM $TEE_PID
139
+
140
+ # In case the 127 errno is not triggered, exit with the "original" exit code
141
+ exit $EXIT_CODE
142
+ }
143
+ trap "__exit_cleanup" EXIT
144
+
145
+
106
146
  # Define our logging file and pipe paths
107
147
  LOGFILE="/tmp/$(basename $0 | sed s/.sh/.log/g )"
108
148
  LOGPIPE="/tmp/$(basename $0 | sed s/.sh/.logpipe/g )"
109
149
 
110
- # Remove the logging pipe when the script exits
111
- trap "rm -f $LOGPIPE" EXIT
112
-
113
150
  # Create our logging pipe
114
- mknod $LOGPIPE p
151
+ # On FreeBSD we have to use mkfifo instead of mknod
152
+ mknod $LOGPIPE p >/dev/null 2>&1 || mkfifo $LOGPIPE >/dev/null 2>&1
153
+ if [ $? -ne 0 ]; then
154
+ echo " * Failed to create the named pipe required to log"
155
+ exit 1
156
+ fi
115
157
 
116
158
  # What ever is written to the logpipe gets written to the logfile
117
159
  tee < $LOGPIPE $LOGFILE &
@@ -124,6 +166,24 @@ exec 2>&-
124
166
  exec 2>$LOGPIPE
125
167
 
126
168
 
169
+ #--- FUNCTION ----------------------------------------------------------------
170
+ # NAME: __gather_hardware_info
171
+ # DESCRIPTION: Discover hardware information
172
+ #-------------------------------------------------------------------------------
173
+ __gather_hardware_info() {
174
+ if [ -f /proc/cpuinfo ]; then
175
+ CPU_VENDOR_ID=$( cat /proc/cpuinfo | grep vendor_id | head -n 1 | awk '{print $3}' )
176
+ else
177
+ CPU_VENDOR_ID=$( sysctl -n hw.model )
178
+ fi
179
+ CPU_VENDOR_ID_L=$( echo $CPU_VENDOR_ID | tr '[:upper:]' '[:lower:]' )
180
+ CPU_ARCH=$(uname -m 2>/dev/null || uname -p 2>/dev/null || echo "unknown")
181
+ CPU_ARCH_L=$( echo $CPU_ARCH | tr '[:upper:]' '[:lower:]' )
182
+
183
+ }
184
+ __gather_hardware_info
185
+
186
+
127
187
  #--- FUNCTION ----------------------------------------------------------------
128
188
  # NAME: __gather_os_info
129
189
  # DESCRIPTION: Discover operating system information
@@ -133,11 +193,29 @@ __gather_os_info() {
133
193
  OS_NAME_L=$( echo $OS_NAME | tr '[:upper:]' '[:lower:]' )
134
194
  OS_VERSION=$(uname -r)
135
195
  OS_VERSION_L=$( echo $OS_VERSION | tr '[:upper:]' '[:lower:]' )
136
- MACHINE=$(uname -m 2>/dev/null || uname -p 2>/dev/null || echo "unknown")
137
196
  }
138
197
  __gather_os_info
139
198
 
140
199
 
200
+ #--- FUNCTION ----------------------------------------------------------------
201
+ # NAME: __parse_version_string
202
+ # DESCRIPTION: Parse version strings ignoring the revision.
203
+ # MAJOR.MINOR.REVISION becomes MAJOR.MINOR
204
+ #-------------------------------------------------------------------------------
205
+ __parse_version_string() {
206
+ VERSION_STRING="$1"
207
+ PARSED_VERSION=$(
208
+ echo $VERSION_STRING |
209
+ sed -e 's/^/#/' \
210
+ -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\).*$/\1/' \
211
+ -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
212
+ -e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
213
+ -e 's/^#.*$//'
214
+ )
215
+ echo $PARSED_VERSION
216
+ }
217
+
218
+
141
219
  #--- FUNCTION ----------------------------------------------------------------
142
220
  # NAME: __gather_linux_system_info
143
221
  # DESCRIPTION: Discover Linux system information
@@ -148,7 +226,7 @@ __gather_linux_system_info() {
148
226
 
149
227
  if [ -f /etc/lsb-release ]; then
150
228
  DISTRO_NAME=$(grep DISTRIB_ID /etc/lsb-release | sed -e 's/.*=//')
151
- DISTRO_VERSION=$(grep DISTRIB_RELEASE /etc/lsb-release | sed -e 's/.*=//')
229
+ DISTRO_VERSION=$(__parse_version_string $(grep DISTRIB_RELEASE /etc/lsb-release | sed -e 's/.*=//'))
152
230
  fi
153
231
 
154
232
  if [ "x$DISTRO_NAME" != "x" -a "x$DISTRO_VERSION" != "x" ]; then
@@ -162,17 +240,11 @@ __gather_linux_system_info() {
162
240
  echo redhat-release lsb-release
163
241
  ); do
164
242
 
165
- [ ! -f "/etc/${rsource}" ] && continue
243
+ [ -L "/etc/${rsource}" ] && continue # Don't follow symlinks
244
+ [ ! -f "/etc/${rsource}" ] && continue # Does not exist
166
245
 
167
246
  n=$(echo ${rsource} | sed -e 's/[_-]release$//' -e 's/[_-]version$//')
168
- v=$(
169
- (grep VERSION /etc/${rsource}; cat /etc/${rsource}) | grep '[0-9]' | sed -e 'q' |\
170
- sed -e 's/^/#/' \
171
- -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\).*$/\1[\2]/' \
172
- -e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
173
- -e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
174
- -e 's/^#.*$//'
175
- )
247
+ v=$( __parse_version_string "$( (grep VERSION /etc/${rsource}; cat /etc/${rsource}) | grep '[0-9]' | sed -e 'q' )" )
176
248
  case $(echo ${n} | tr '[:upper:]' '[:lower:]') in
177
249
  redhat )
178
250
  if [ ".$(egrep '(Red Hat Enterprise Linux|CentOS)' /etc/${rsource})" != . ]; then
@@ -222,7 +294,7 @@ __gather_sunos_system_info() {
222
294
  #-------------------------------------------------------------------------------
223
295
  __gather_bsd_system_info() {
224
296
  DISTRO_NAME=${OS_NAME}
225
- DISTRO_VERSION=$(echo "${OS_VERSION}" | sed -e 's;[()];;' -e 's/\(-.*\)$/[\1]/')
297
+ DISTRO_VERSION=$(echo "${OS_VERSION}" | sed -e 's;[()];;' -e 's/-.*$//')
226
298
  }
227
299
 
228
300
 
@@ -258,25 +330,25 @@ __gather_system_info() {
258
330
  #-------------------------------------------------------------------------------
259
331
  __function_defined() {
260
332
  FUNC_NAME=$1
261
- if [ ${DISTRO_NAME} = "centos" ]; then
333
+ if [ "${DISTRO_NAME}" = "centos" ]; then
262
334
  if typeset -f $FUNC_NAME &>/dev/null ; then
263
335
  echo " * INFO: Found function $FUNC_NAME"
264
336
  return 0
265
337
  fi
266
- elif [ ${DISTRO_NAME} = "ubuntu" ]; then
338
+ elif [ "${DISTRO_NAME}" = "ubuntu" ]; then
267
339
  if $( type ${FUNC_NAME} | grep -q 'shell function' ); then
268
340
  echo " * INFO: Found function $FUNC_NAME"
269
341
  return 0
270
342
  fi
271
343
  # Last resorts try POSIXLY_CORRECT or not
272
344
  elif test -n "${POSIXLY_CORRECT+yes}"; then
273
- if typeset -f $FUNC_NAME &>/dev/null ; then
345
+ if typeset -f $FUNC_NAME >/dev/null 2>&1 ; then
274
346
  echo " * INFO: Found function $FUNC_NAME"
275
347
  return 0
276
348
  fi
277
349
  else
278
350
  # Arch linux seems to fall here
279
- if $( type ${FUNC_NAME} &>/dev/null ) ; then
351
+ if $( type ${FUNC_NAME} >/dev/null 2>&1 ) ; then
280
352
  echo " * INFO: Found function $FUNC_NAME"
281
353
  return 0
282
354
  fi
@@ -286,10 +358,27 @@ __function_defined() {
286
358
  }
287
359
  __gather_system_info
288
360
 
361
+
362
+ #--- FUNCTION ----------------------------------------------------------------
363
+ # NAME: __git_clone_and_checkout
364
+ # DESCRIPTION: (DRY) Helper function to clone and checkout salt to a
365
+ # specific revision.
366
+ #-------------------------------------------------------------------------------
367
+ __git_clone_and_checkout() {
368
+ SALT_GIT_CHECKOUT_DIR=/tmp/git/salt
369
+ [ -d /tmp/git ] || mkdir /tmp/git
370
+ cd /tmp/git
371
+ [ -d $SALT_GIT_CHECKOUT_DIR ] || git clone git://github.com/saltstack/salt.git salt
372
+ cd salt
373
+ git checkout $GIT_REV
374
+ }
375
+
376
+
289
377
  echo " * System Information:"
378
+ echo " CPU: ${CPU_VENDOR_ID}"
379
+ echo " CPU Arch: ${CPU_ARCH}"
290
380
  echo " OS Name: ${OS_NAME}"
291
381
  echo " OS Version: ${OS_VERSION}"
292
- echo " Machine: ${MACHINE}"
293
382
  echo " Distribution: ${DISTRO_NAME} ${DISTRO_VERSION}"
294
383
 
295
384
 
@@ -300,7 +389,16 @@ else
300
389
  DISTRO_VERSION_NO_DOTS="_$(echo $DISTRO_VERSION | tr -d '.')"
301
390
  fi
302
391
  # Simplify distro name naming on functions
303
- DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]')
392
+ DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]' | sed 's/[^a-zA-Z0-9_ ]//g' | sed -e 's|[:space:]+|_|g')
393
+
394
+ #--- FUNCTION ----------------------------------------------------------------
395
+ # NAME: __apt_get_noinput
396
+ # DESCRIPTION: (DRY) apt-get install with noinput options
397
+ #-------------------------------------------------------------------------------
398
+ __apt_get_noinput() {
399
+ apt-get install -y -o DPkg::Options::=--force-confold $@
400
+ }
401
+
304
402
 
305
403
  ##############################################################################
306
404
  #
@@ -317,10 +415,17 @@ DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]')
317
415
  #
318
416
  # To install salt, which, of course, is required, one of:
319
417
  # 1. install_<distro>_<distro_version>_<install_type>
320
- # 1. install_<distro>_<install_type>
418
+ # 2. install_<distro>_<install_type>
321
419
  #
420
+ # Optionally, define a minion configuration function, which will be called if
421
+ # the -c|config-dir option is passed. One of:
422
+ # 1. config_<distro>_<distro_version>_<install_type>_minion
423
+ # 2. config_<distro>_<distro_version>_minion
424
+ # 3. config_<distro>_<install_type>_minion
425
+ # 4. config_<distro>_minion
426
+ # 5. config_minion [THIS ONE IS ALREADY DEFINED AS THE DEFAULT]
322
427
  #
323
- # And optionally, define a post install function, one of:
428
+ # Also optionally, define a post install function, one of:
324
429
  # 1. install_<distro>_<distro_versions>_<install_type>_post
325
430
  # 2. install_<distro>_<distro_versions>_post
326
431
  # 3. install_<distro>_<install_type>_post
@@ -332,46 +437,82 @@ DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]')
332
437
  #
333
438
  # Ubuntu Install Functions
334
439
  #
335
- ##############################################################################
336
440
  install_ubuntu_deps() {
337
441
  apt-get update
338
- apt-get -y install python-software-properties
442
+ __apt_get_noinput python-software-properties
339
443
  add-apt-repository -y ppa:saltstack/salt
340
444
  apt-get update
341
445
  }
342
446
 
343
447
  install_ubuntu_1004_deps() {
344
448
  apt-get update
345
- apt-get -y install python-software-properties
449
+ __apt_get_noinput python-software-properties
346
450
  add-apt-repository ppa:saltstack/salt
347
451
  apt-get update
348
- apt-get -y install salt-minion
452
+ __apt_get_noinput salt-minion
453
+ }
454
+
455
+ install_ubuntu_1004_git_deps() {
456
+ install_ubuntu_1004_deps
457
+ __apt_get_noinput git-core
349
458
  }
350
459
 
351
460
  install_ubuntu_1110_deps() {
352
461
  apt-get update
353
- apt-get -y install python-software-properties
462
+ __apt_get_noinput python-software-properties
354
463
  add-apt-repository -y 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'
355
464
  add-apt-repository -y ppa:saltstack/salt
356
465
  }
357
466
 
358
467
  install_ubuntu_daily_deps() {
359
468
  apt-get update
360
- apt-get -y install python-software-properties
469
+ __apt_get_noinput python-software-properties
361
470
  add-apt-repository -y ppa:saltstack/salt-daily
362
471
  apt-get update
363
472
  }
364
473
 
474
+ install_ubuntu_git_deps() {
475
+ apt-get update
476
+ __apt_get_noinput python-software-properties
477
+ add-apt-repository ppa:saltstack/salt
478
+ apt-get update
479
+ __apt_get_noinput git-core python-yaml python-m2crypto python-crypto msgpack-python python-zmq python-jinja2
480
+ }
481
+
365
482
  install_ubuntu_1110_post() {
366
483
  add-apt-repository -y --remove 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'
367
484
  }
368
485
 
369
486
  install_ubuntu_stable() {
370
- apt-get -y install salt-minion
487
+ __apt_get_noinput salt-minion
371
488
  }
372
489
 
373
490
  install_ubuntu_daily() {
374
- apt-get -y install salt-minion
491
+ __apt_get_noinput salt-minion
492
+ }
493
+
494
+ install_ubuntu_git() {
495
+ __git_clone_and_checkout
496
+ python setup.py install --install-layout=deb
497
+ }
498
+
499
+ install_ubuntu_git_post() {
500
+ for fname in $(echo "minion master syndic"); do
501
+ if [ $fname != "minion" ]; then
502
+ # Guess we should only enable and start the minion service. Right??
503
+ continue
504
+ fi
505
+ if [ -f ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init ]; then
506
+ cp ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init /etc/init.d/salt-$fname
507
+ fi
508
+ if [ -f ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.upstart ]; then
509
+ cp ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.upstart /etc/init/salt-$fname.conf
510
+ elif [ -f ${SALT_GIT_CHECKOUT_DIR}/pkg/salt-$fname.upstart ]; then
511
+ cp ${SALT_GIT_CHECKOUT_DIR}/pkg/salt-$fname.upstart /etc/init/salt-$fname.conf
512
+ fi
513
+ chmod +x /etc/init.d/salt-$fname
514
+ service salt-$fname start
515
+ done
375
516
  }
376
517
  #
377
518
  # End of Ubuntu Install Functions
@@ -382,6 +523,15 @@ install_ubuntu_daily() {
382
523
  #
383
524
  # Debian Install Functions
384
525
  #
526
+
527
+ install_debian_deps() {
528
+ apt-get update
529
+ }
530
+
531
+ install_debian_stable() {
532
+ __apt_get_noinput salt-minion
533
+ }
534
+
385
535
  install_debian_60_stable_deps() {
386
536
  echo "deb http://backports.debian.org/debian-backports squeeze-backports main" >> \
387
537
  /etc/apt/sources.list.d/backports.list
@@ -389,19 +539,90 @@ install_debian_60_stable_deps() {
389
539
  }
390
540
 
391
541
  install_debian_60_stable() {
392
- apt-get -t squeeze-backports -y install salt-minion
542
+ __apt_get_noinput -t squeeze-backports salt-minion
543
+ }
544
+
545
+ install_debian_60_git_deps() {
546
+ install_debian_60_stable_deps
547
+ install_debian_60_stable
548
+ }
549
+
550
+ install_debian_60_git() {
551
+ __apt_get_noinput git
552
+ apt-get -y purge salt-minion
553
+
554
+ __git_clone_and_checkout
555
+
556
+ python setup.py install --install-layout=deb
557
+ mkdir -p /etc/salt
558
+ cp conf/minion.template /etc/salt/minion
393
559
  }
394
560
  #
395
561
  # Ended Debian Install Functions
396
562
  #
397
563
  ##############################################################################
398
564
 
565
+ ##############################################################################
566
+ #
567
+ # Fedora Install Functions
568
+ #
569
+ install_fedora_deps() {
570
+ yum install -y PyYAML libyaml m2crypto python-crypto python-jinja2 python-msgpack python-zmq
571
+ }
572
+
573
+ install_fedora_stable() {
574
+ yum install -y salt-minion
575
+ }
576
+
577
+
578
+ install_fedora_git_deps() {
579
+ install_fedora_deps
580
+ yum install -y git
581
+ }
582
+
583
+ install_fedora_git() {
584
+ __git_clone_and_checkout
585
+ python setup.py install
586
+ }
587
+
588
+ install_fedora_git_post() {
589
+ for fname in $(echo "minion master syndic"); do
590
+ if [ $fname != "minion" ]; then
591
+ # Guess we should only enable and start the minion service. Right??
592
+ continue
593
+ fi
594
+ #cp ${SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname /etc/rc.d/init.d/salt-$fname
595
+ cp ${SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname.service /lib/systemd/system/salt-$fname.service
596
+ #chmod +x /etc/rc.d/init.d/salt-$fname
597
+
598
+ # Switch from forking to simple, dunny why I can't make it work
599
+ sed -i 's/Type=forking/Type=simple/g' /lib/systemd/system/salt-$fname.service
600
+ # Remove the daemon flag because of the above
601
+ sed -ie 's;ExecStart=\(.*\) -d;ExecStart=\1;' /lib/systemd/system/salt-$fname.service
602
+ systemctl preset salt-$fname.service
603
+ systemctl enable salt-$fname.service
604
+ sleep 0.2
605
+ systemctl daemon-reload
606
+ sleep 0.2
607
+ systemctl start salt-$fname.service
608
+ done
609
+ }
610
+ #
611
+ # Ended Fedora Install Functions
612
+ #
613
+ ##############################################################################
614
+
399
615
  ##############################################################################
400
616
  #
401
617
  # CentOS Install Functions
402
618
  #
403
619
  install_centos_63_stable_deps() {
404
- rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/6/x86_64/epel-release-6-7.noarch.rpm
620
+ if [ $CPU_ARCH_L = "i686" ]; then
621
+ local ARCH="i386"
622
+ else
623
+ local ARCH=$CPU_ARCH_L
624
+ fi
625
+ rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/6/${ARCH}/epel-release-6-7.noarch.rpm
405
626
  yum -y update
406
627
  }
407
628
 
@@ -411,13 +632,185 @@ install_centos_63_stable() {
411
632
 
412
633
  install_centos_63_stable_post() {
413
634
  /sbin/chkconfig salt-minion on
414
- salt-minion start &
635
+ /etc/init.d/salt-minion start
636
+ }
637
+
638
+ install_centos_63_git_deps() {
639
+ install_centos_63_stable_deps
640
+ yum -y install git PyYAML m2crypto python-crypto python-msgpack python-zmq python-jinja2 --enablerepo=epel-testing
641
+ }
642
+
643
+ install_centos_63_git() {
644
+ rm -rf /usr/lib/python*/site-packages/salt
645
+ rm -rf /usr/bin/salt*
646
+
647
+ __git_clone_and_checkout
648
+ python2 setup.py install
649
+ mkdir -p /etc/salt/
650
+ }
651
+
652
+ install_centos_63_git_post() {
653
+ cp pkg/rpm/salt-{master,minion} /etc/init.d/
654
+ chmod +x /etc/init.d/salt-{master,minion}
655
+ /sbin/chkconfig salt-minion on
656
+ /etc/init.d/salt-minion start
415
657
  }
416
658
  #
417
659
  # Ended CentOS Install Functions
418
660
  #
419
661
  ##############################################################################
420
662
 
663
+
664
+ ##############################################################################
665
+ #
666
+ # Arch Install Functions
667
+ #
668
+ install_arch_stable_deps() {
669
+ echo '[salt]
670
+ Server = http://red45.org/archlinux
671
+ ' >> /etc/pacman.conf
672
+ }
673
+
674
+ install_arch_git_deps() {
675
+ echo '[salt]
676
+ Server = http://red45.org/archlinux
677
+ ' >> /etc/pacman.conf
678
+ }
679
+
680
+ install_arch_stable() {
681
+ pacman -Sy --noconfirm pacman
682
+ pacman -Syu --noconfirm salt
683
+ }
684
+
685
+ install_arch_git() {
686
+ pacman -Sy --noconfirm pacman
687
+ pacman -Syu --noconfirm salt git
688
+ rm -rf /usr/lib/python2.7/site-packages/salt*
689
+ rm -rf /usr/bin/salt-*
690
+
691
+ __git_clone_and_checkout
692
+
693
+ python2 setup.py install
694
+ }
695
+
696
+ install_arch_post() {
697
+ /etc/rc.d/salt-minion start
698
+ }
699
+ #
700
+ # Ended Arch Install Functions
701
+ #
702
+ ##############################################################################
703
+
704
+ ##############################################################################
705
+ #
706
+ # FreeBSD Install Functions
707
+ #
708
+ install_freebsd_90_stable_deps() {
709
+ if [ "$CPU_VENDOR_ID_L" = "AuthenticAMD" -a $CPU_ARCH_L = "x86_64" ]; then
710
+ local ARCH="amd64"
711
+ elif [ "$CPU_VENDOR_ID_L" = "GenuineIntel" -a $CPU_ARCH_L = "x86_64" ]; then
712
+ local ARCH="x86:64"
713
+ elif [ "$CPU_VENDOR_ID_L" = "GenuineIntel" -a $CPU_ARCH_L = "i386" ]; then
714
+ local ARCH="i386"
715
+ elif [ "$CPU_VENDOR_ID_L" = "GenuineIntel" -a $CPU_ARCH_L = "i686" ]; then
716
+ local ARCH="x86:32"
717
+ else
718
+ local ARCH=$CPU_ARCH
719
+ fi
720
+
721
+ portsnap fetch extract update
722
+ cd /usr/ports/ports-mgmt/pkg
723
+ make install clean
724
+ cd
725
+ /usr/local/sbin/pkg2ng
726
+ echo "PACKAGESITE: http://pkgbeta.freebsd.org/freebsd-9-${ARCH}/latest" > /usr/local/etc/pkg.conf
727
+ }
728
+
729
+ install_freebsd_git_deps() {
730
+ if [ "$CPU_VENDOR_ID_L" = "AuthenticAMD" -a $CPU_ARCH_L = "x86_64" ]; then
731
+ local ARCH="amd64"
732
+ elif [ "$CPU_VENDOR_ID_L" = "GenuineIntel" -a $CPU_ARCH_L = "x86_64" ]; then
733
+ local ARCH="x86:64"
734
+ elif [ "$CPU_VENDOR_ID_L" = "GenuineIntel" -a $CPU_ARCH_L = "i386" ]; then
735
+ local ARCH="i386"
736
+ elif [ "$CPU_VENDOR_ID_L" = "GenuineIntel" -a $CPU_ARCH_L = "i686" ]; then
737
+ local ARCH="x86:32"
738
+ else
739
+ local ARCH=$CPU_ARCH
740
+ fi
741
+
742
+ portsnap fetch extract update
743
+ cd /usr/ports/ports-mgmt/pkg
744
+ make install clean
745
+ cd
746
+ /usr/local/sbin/pkg2ng
747
+ echo "PACKAGESITE: http://pkgbeta.freebsd.org/freebsd-9-${ARCH}/latest" > /usr/local/etc/pkg.conf
748
+ }
749
+
750
+ install_freebsd_90_stable() {
751
+ /usr/local/sbin/pkg install -y salt
752
+ }
753
+
754
+ install_freebsd_git() {
755
+ /usr/local/sbin/pkg install -y git salt
756
+ /usr/local/sbin/pkg delete -y salt
757
+
758
+ __git_clone_and_checkout
759
+
760
+ /usr/local/bin/python setup.py install
761
+ }
762
+
763
+ install_freebsd_90_stable_post() {
764
+ salt-minion -d
765
+ }
766
+
767
+ install_freebsd_git_post() {
768
+ salt-minion -d
769
+ }
770
+ #
771
+ # Ended FreeBSD Install Functions
772
+ #
773
+ ##############################################################################
774
+
775
+
776
+ ##############################################################################
777
+ #
778
+ # Default minion configuration function. Matches ANY distribution as long as
779
+ # the -c options is passed.
780
+ #
781
+ config_minion() {
782
+ # If the configuration directory is not passed, return
783
+ [ "$TEMP_CONFIG_DIR" = "null" ] && return
784
+ # If the configuration directory does not exist, error out
785
+ if [ ! -d "$TEMP_CONFIG_DIR" ]; then
786
+ echo " * The configuration directory ${TEMP_CONFIG_DIR} does not exist."
787
+ exit 1
788
+ fi
789
+
790
+ # Let's create the necessary directories
791
+ [ -d /etc/salt ] || mkdir /etc/salt
792
+ [ -d /etc/salt/pki ] || mkdir /etc/salt/pki && chmod 700 /etc/salt/pki
793
+
794
+ # Copy the minions configuration if found
795
+ [ -f "$TEMP_CONFIG_DIR/minion" ] && mv "$TEMP_CONFIG_DIR/minion" /etc/salt
796
+
797
+ # Copy the minion's keys if found
798
+ if [ -f "$TEMP_CONFIG_DIR/minion.pem" ]; then
799
+ mv "$TEMP_CONFIG_DIR/minion.pem" /etc/salt/pki
800
+ chmod 400 /etc/salt/pki/minion.pem
801
+ fi
802
+ if [ -f "$TEMP_CONFIG_DIR/minion.pub" ]; then
803
+ mv "$TEMP_CONFIG_DIR/minion.pub" /etc/salt/pki
804
+ chmod 664 /etc/salt/pki/minion.pub
805
+ fi
806
+ }
807
+ #
808
+ # Ended Default Configuration function
809
+ #
810
+ ##############################################################################
811
+
812
+
813
+
421
814
  #=============================================================================
422
815
  # LET'S PROCEED WITH OUR INSTALLATION
423
816
  #=============================================================================
@@ -449,16 +842,34 @@ for FUNC_NAME in $INSTALL_FUNC_NAMES; do
449
842
  done
450
843
 
451
844
 
452
- # Let's get the dependencies install function
845
+ # Let's get the minion config function
846
+ CONFIG_MINION_FUNC="null"
847
+ if [ "$TEMP_CONFIG_DIR" != "null" ]; then
848
+ CONFIG_FUNC_NAMES="config_${DISTRO_NAME_L}${DISTRO_VERSION_NO_DOTS}_${ITYPE}_minion"
849
+ CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${DISTRO_VERSION_NO_DOTS}_minon"
850
+ CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_${ITYPE}_minion"
851
+ CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_minion"
852
+ CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_minion"
853
+
854
+ for FUNC_NAME in $CONFIG_FUNC_NAMES; do
855
+ if __function_defined $FUNC_NAME; then
856
+ CONFIG_MINION_FUNC=$FUNC_NAME
857
+ break
858
+ fi
859
+ done
860
+ fi
861
+
862
+
863
+ # Let's get the post install function
453
864
  POST_FUNC_NAMES="install_${DISTRO_NAME_L}${DISTRO_VERSION_NO_DOTS}_${ITYPE}_post"
454
- POST_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}${DISTRO_VERSION_NO_DOTS}_post"
455
- POST_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}_post"
456
- POST_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}_post"
865
+ POST_FUNC_NAMES="$POST_FUNC_NAMES install_${DISTRO_NAME_L}${DISTRO_VERSION_NO_DOTS}_post"
866
+ POST_FUNC_NAMES="$POST_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}_post"
867
+ POST_FUNC_NAMES="$POST_FUNC_NAMES install_${DISTRO_NAME_L}_post"
457
868
 
458
869
  POST_INSTALL_FUNC="null"
459
870
  for FUNC_NAME in $POST_FUNC_NAMES; do
460
871
  if __function_defined $FUNC_NAME; then
461
- DEPS_INSTALL_FUNC=$FUNC_NAME
872
+ POST_INSTALL_FUNC=$FUNC_NAME
462
873
  break
463
874
  fi
464
875
  done
@@ -469,7 +880,7 @@ if [ $DEPS_INSTALL_FUNC = "null" ]; then
469
880
  exit 1
470
881
  fi
471
882
 
472
- if [ $DEPS_INSTALL_FUNC = "null" ]; then
883
+ if [ $INSTALL_FUNC = "null" ]; then
473
884
  echo " * ERROR: No installation function found. Exiting..."
474
885
  exit 1
475
886
  fi
@@ -478,16 +889,39 @@ fi
478
889
  # Install dependencies
479
890
  echo " * Running ${DEPS_INSTALL_FUNC}()"
480
891
  $DEPS_INSTALL_FUNC
892
+ if [ $? -ne 0 ]; then
893
+ echo " * Failed to run ${DEPS_INSTALL_FUNC}()!!!"
894
+ exit 1
895
+ fi
481
896
 
482
897
  # Install Salt
483
898
  echo " * Running ${INSTALL_FUNC}()"
484
899
  $INSTALL_FUNC
900
+ if [ $? -ne 0 ]; then
901
+ echo " * Failed to run ${INSTALL_FUNC}()!!!"
902
+ exit 1
903
+ fi
904
+
905
+ # Configure Salt
906
+ if [ "$TEMP_CONFIG_DIR" != "null" -a "$CONFIG_MINION_FUNC" != "null" ]; then
907
+ echo " * Running ${CONFIG_MINION_FUNC}()"
908
+ $CONFIG_MINION_FUNC
909
+ if [ $? -ne 0 ]; then
910
+ echo " * Failed to run ${CONFIG_MINION_FUNC}()!!!"
911
+ exit 1
912
+ fi
913
+ fi
485
914
 
486
915
  # Run any post install function
487
916
  if [ "$POST_INSTALL_FUNC" != "null" ]; then
488
917
  echo " * Running ${POST_INSTALL_FUNC}()"
489
918
  $POST_INSTALL_FUNC
919
+ if [ $? -ne 0 ]; then
920
+ echo " * Failed to run ${POST_INSTALL_FUNC}()!!!"
921
+ exit 1
922
+ fi
490
923
  fi
491
924
 
492
925
  # Done!
493
926
  echo " * Salt installed!"
927
+ exit 0
data/vagrant-salt.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "vagrant-salt"
6
- s.version = "0.1.4"
6
+ s.version = "0.2.0"
7
7
  s.authors = ["Alec Koumjian", "Kiall Mac Innes", "Pedro Algarvio"]
8
8
  s.email = ["akoumjian@gmail.com", "kiall@managedit.ie", "pedro@algarvio.me"]
9
9
  s.homepage = "https://github.com/saltstack/salty-vagrant"
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 4
9
- version: 0.1.4
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alec Koumjian
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-10-19 00:00:00 -07:00
19
+ date: 2012-11-28 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency