vagrant-salt 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.rst +54 -2
- data/example/Vagrantfile +3 -1
- data/lib/vagrant-salt/provisioner.rb +41 -14
- data/scripts/bootstrap-salt-minion.sh +493 -0
- data/vagrant-salt.gemspec +4 -4
- metadata +7 -4
data/.gitignore
CHANGED
data/README.rst
CHANGED
@@ -17,7 +17,7 @@ Just like Chef or Puppet, Salt can be used as a provisioning tool.
|
|
17
17
|
file to automatically build your dev environment the same way you use salt
|
18
18
|
to deploy for other environments.
|
19
19
|
|
20
|
-
.. _`Salty Vagrant`: https://github.com/
|
20
|
+
.. _`Salty Vagrant`: https://github.com/saltstack/salty-vagrant
|
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
|
@@ -97,7 +97,7 @@ vagrant minion in state.highstate.
|
|
97
97
|
|
98
98
|
|
99
99
|
Configuration
|
100
|
-
|
100
|
+
=============
|
101
101
|
|
102
102
|
Your ``Vagrantfile`` should look roughly like this::
|
103
103
|
|
@@ -151,4 +151,56 @@ salt_pillar_root_path : "salt/roots/pillar"
|
|
151
151
|
salt_pillar_root_guest_path : "/srv/pillar"
|
152
152
|
Path on VM where pillar tree will be shared. Only use with ``master=true``
|
153
153
|
|
154
|
+
Bootstrapping Salt
|
155
|
+
==================
|
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.
|
158
|
+
|
159
|
+
Adding support for other operating systems
|
160
|
+
------------------------------------------
|
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.
|
179
|
+
|
180
|
+
Supported Operating Systems
|
181
|
+
---------------------------
|
182
|
+
- Ubuntu 10.x/11.x/12.x
|
183
|
+
- Debian 6.x
|
184
|
+
|
185
|
+
Installation Notes
|
186
|
+
==================
|
187
|
+
Ubuntu & Debian
|
188
|
+
---------------
|
189
|
+
|
190
|
+
Users have reported that vagrant plugins do not work with the debian packaged vagrant
|
191
|
+
(such as Ubuntu repository). Installing vagrant with gem should work.
|
192
|
+
|
193
|
+
1. ``sudo apt-get remove vagrant``
|
194
|
+
2. ``sudo gem install vagrant``
|
195
|
+
3. ``vagrant gem install vagrant-salt``
|
196
|
+
|
197
|
+
That should get you up and running.
|
198
|
+
|
199
|
+
Installing from source
|
200
|
+
----------------------
|
154
201
|
|
202
|
+
1. ``wget https://github.com/saltstack/salty-vagrant/tarball/master -O salty-vagrant.tar.gz``
|
203
|
+
2. ``tar zxf salty-vagrant.tar.gz``
|
204
|
+
3. ``cd saltstack-salty-vagrant-[hash]``
|
205
|
+
4. ``gem build vagrant-salt.gemspec``
|
206
|
+
5. ``vagrant gem install vagrant-salt-[version].gem``
|
data/example/Vagrantfile
CHANGED
@@ -6,8 +6,10 @@ Vagrant::Config.run do |config|
|
|
6
6
|
config.vm.provision :salt do |salt|
|
7
7
|
salt.run_highstate = true
|
8
8
|
|
9
|
+
|
9
10
|
## Optional Settings:
|
10
|
-
|
11
|
+
# salt.minion_config = "salt/minion.conf"
|
12
|
+
# salt.salt_install_type = "daily"
|
11
13
|
|
12
14
|
## Only Use these with a masterless setup to
|
13
15
|
## load your state tree:
|
@@ -10,6 +10,8 @@ module VagrantSalt
|
|
10
10
|
attr_accessor :salt_file_root_guest_path
|
11
11
|
attr_accessor :salt_pillar_root_path
|
12
12
|
attr_accessor :salt_pillar_root_guest_path
|
13
|
+
attr_accessor :salt_install_type
|
14
|
+
attr_accessor :salt_install_args
|
13
15
|
|
14
16
|
def minion_config; @minion_config || "salt/minion.conf"; end
|
15
17
|
def minion_key; @minion_key || false; end
|
@@ -20,10 +22,17 @@ module VagrantSalt
|
|
20
22
|
def salt_file_root_guest_path; @salt_file_root_guest_path || "/srv/salt"; end
|
21
23
|
def salt_pillar_root_path; @salt_pillar_root_path || "salt/roots/pillar"; end
|
22
24
|
def salt_pillar_root_guest_path; @salt_pillar_root_guest_path || "/srv/pillar"; end
|
25
|
+
def salt_install_type; @salt_install_type || ''; end
|
26
|
+
def salt_install_args; @salt_install_args || ''; end
|
27
|
+
|
23
28
|
|
24
29
|
def expanded_path(root_path, rel_path)
|
25
30
|
Pathname.new(rel_path).expand_path(root_path)
|
26
31
|
end
|
32
|
+
|
33
|
+
def bootstrap_options
|
34
|
+
'%s %s' % [salt_install_type, salt_install_args]
|
35
|
+
end
|
27
36
|
end
|
28
37
|
|
29
38
|
def self.config_class
|
@@ -37,6 +46,8 @@ module VagrantSalt
|
|
37
46
|
env[:ui].info "Adding state tree folders."
|
38
47
|
@expanded_salt_file_root_path = config.expanded_path(env[:root_path], config.salt_file_root_path)
|
39
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
|
40
51
|
share_salt_file_root_path
|
41
52
|
share_salt_pillar_root_path
|
42
53
|
end
|
@@ -47,6 +58,18 @@ module VagrantSalt
|
|
47
58
|
end
|
48
59
|
end
|
49
60
|
|
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
|
+
|
50
73
|
def share_salt_file_root_path
|
51
74
|
env[:ui].info "Sharing file root folder."
|
52
75
|
env[:vm].config.vm.share_folder("salt_file_root", config.salt_file_root_guest_path, @expanded_salt_file_root_path)
|
@@ -67,17 +90,22 @@ module VagrantSalt
|
|
67
90
|
return false
|
68
91
|
end
|
69
92
|
|
70
|
-
def
|
71
|
-
env[:ui].info "
|
72
|
-
|
73
|
-
env[:vm].channel.
|
74
|
-
env[:vm].channel.sudo("
|
75
|
-
env[:vm].channel.sudo("
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
93
|
+
def bootstrap_salt_minion
|
94
|
+
env[:ui].info "Bootstrapping salt-minion on VM..."
|
95
|
+
@expanded_bootstrap_script_path = config.expanded_path(__FILE__, "../../../scripts/bootstrap-salt-minion.sh")
|
96
|
+
env[:vm].channel.upload(@expanded_bootstrap_script_path.to_s, "/tmp/bootstrap-salt-minion.sh")
|
97
|
+
env[:vm].channel.sudo("chmod +x /tmp/bootstrap-salt-minion.sh")
|
98
|
+
bootstrap = env[:vm].channel.sudo("/tmp/bootstrap-salt-minion.sh %s" % config.bootstrap_options) do |type, data|
|
99
|
+
if data[0] == "\n"
|
100
|
+
# Remove any leading newline but not whitespace, for that one would use data.lstrip
|
101
|
+
data = data[1..-1]
|
102
|
+
end
|
103
|
+
env[:ui].info(data.rstrip)
|
104
|
+
end
|
105
|
+
if !bootstrap
|
106
|
+
raise "Failed to bootstrap salt-minion on VM, see /var/log/bootstrap-salt-minion.log on VM."
|
107
|
+
end
|
108
|
+
env[:ui].info "Salt binaries installed on VM."
|
81
109
|
end
|
82
110
|
|
83
111
|
def accept_minion_key
|
@@ -118,8 +146,7 @@ module VagrantSalt
|
|
118
146
|
end
|
119
147
|
|
120
148
|
if !salt_exists
|
121
|
-
|
122
|
-
install_salt_minion
|
149
|
+
bootstrap_salt_minion
|
123
150
|
end
|
124
151
|
|
125
152
|
upload_minion_config
|
@@ -141,4 +168,4 @@ module VagrantSalt
|
|
141
168
|
end
|
142
169
|
end
|
143
170
|
end
|
144
|
-
end
|
171
|
+
end
|
@@ -0,0 +1,493 @@
|
|
1
|
+
#!/bin/bash -
|
2
|
+
#===============================================================================
|
3
|
+
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en
|
4
|
+
#===============================================================================
|
5
|
+
#
|
6
|
+
# FILE: bootstrap-salt-minion.sh
|
7
|
+
#
|
8
|
+
# DESCRIPTION: Bootstrap salt installation for various systems/distributions
|
9
|
+
#
|
10
|
+
# BUGS: https://github.com/saltstack/salty-vagrant/issues
|
11
|
+
# AUTHOR: Pedro Algarvio (s0undt3ch), pedro@algarvio.me
|
12
|
+
# Alec Koumjian (akoumjian)
|
13
|
+
# ORGANIZATION: Salt Stack (saltstack.org)
|
14
|
+
# CREATED: 10/15/2012 09:49:37 PM WEST
|
15
|
+
#===============================================================================
|
16
|
+
set -o nounset # Treat unset variables as an error
|
17
|
+
ScriptVersion="1.0"
|
18
|
+
|
19
|
+
#===============================================================================
|
20
|
+
# LET THE BLACK MAGIC BEGIN!!!!
|
21
|
+
#===============================================================================
|
22
|
+
|
23
|
+
#=== FUNCTION ================================================================
|
24
|
+
# NAME: usage
|
25
|
+
# DESCRIPTION: Display usage information.
|
26
|
+
#===============================================================================
|
27
|
+
usage() {
|
28
|
+
cat << EOT
|
29
|
+
|
30
|
+
Usage : ${0##/*/} [options] <install-type> <install-type-args>
|
31
|
+
|
32
|
+
Installation types:
|
33
|
+
- stable (default)
|
34
|
+
- daily (ubuntu specific)
|
35
|
+
- git
|
36
|
+
|
37
|
+
Examples:
|
38
|
+
$ ${0##/*/}
|
39
|
+
$ ${0##/*/} stable
|
40
|
+
$ ${0##/*/} daily
|
41
|
+
$ ${0##/*/} git
|
42
|
+
$ ${0##/*/} git develop
|
43
|
+
$ ${0##/*/} git 8c3fadf15ec183e5ce8c63739850d543617e4357
|
44
|
+
|
45
|
+
Options:
|
46
|
+
-h|help Display this message
|
47
|
+
-v|version Display script version
|
48
|
+
EOT
|
49
|
+
} # ---------- end of function usage ----------
|
50
|
+
|
51
|
+
#-----------------------------------------------------------------------
|
52
|
+
# Handle command line arguments
|
53
|
+
#-----------------------------------------------------------------------
|
54
|
+
|
55
|
+
while getopts ":hv" opt
|
56
|
+
do
|
57
|
+
case $opt in
|
58
|
+
|
59
|
+
h|help ) usage; exit 0 ;;
|
60
|
+
|
61
|
+
v|version ) echo "$0 -- Version $ScriptVersion"; exit 0 ;;
|
62
|
+
|
63
|
+
\? ) echo "\n Option does not exist : $OPTARG\n"
|
64
|
+
usage; exit 1 ;;
|
65
|
+
|
66
|
+
esac # --- end of case ---
|
67
|
+
done
|
68
|
+
shift $(($OPTIND-1))
|
69
|
+
|
70
|
+
# Define installation type
|
71
|
+
if [ "$#" -eq 0 ];then
|
72
|
+
ITYPE="stable"
|
73
|
+
else
|
74
|
+
ITYPE=$1
|
75
|
+
shift
|
76
|
+
fi
|
77
|
+
|
78
|
+
if [ "$ITYPE" != "stable" -a "$ITYPE" != "daily" -a "$ITYPE" != "git" ]; then
|
79
|
+
echo " ERROR: Installation type \"$ITYPE\" is not known..."
|
80
|
+
exit 1
|
81
|
+
fi
|
82
|
+
|
83
|
+
if [ $ITYPE = "git" ]; then
|
84
|
+
if [ "$#" -eq 0 ];then
|
85
|
+
GIT_REV="master"
|
86
|
+
else
|
87
|
+
GIT_REV=$1
|
88
|
+
shift
|
89
|
+
fi
|
90
|
+
fi
|
91
|
+
|
92
|
+
if [ "$#" -gt 0 ]; then
|
93
|
+
usage
|
94
|
+
echo
|
95
|
+
echo " * ERROR: Too many arguments."
|
96
|
+
exit 1
|
97
|
+
fi
|
98
|
+
|
99
|
+
# Root permissions are required to run this script
|
100
|
+
if [ $(whoami) != "root" ] ; then
|
101
|
+
echo " * ERROR: Salt requires root privileges to install. Please re-run this script as root."
|
102
|
+
exit 1
|
103
|
+
fi
|
104
|
+
|
105
|
+
|
106
|
+
# Define our logging file and pipe paths
|
107
|
+
LOGFILE="/tmp/$(basename $0 | sed s/.sh/.log/g )"
|
108
|
+
LOGPIPE="/tmp/$(basename $0 | sed s/.sh/.logpipe/g )"
|
109
|
+
|
110
|
+
# Remove the logging pipe when the script exits
|
111
|
+
trap "rm -f $LOGPIPE" EXIT
|
112
|
+
|
113
|
+
# Create our logging pipe
|
114
|
+
mknod $LOGPIPE p
|
115
|
+
|
116
|
+
# What ever is written to the logpipe gets written to the logfile
|
117
|
+
tee < $LOGPIPE $LOGFILE &
|
118
|
+
|
119
|
+
# Close STDOUT, reopen it directing it to the logpipe
|
120
|
+
exec 1>&-
|
121
|
+
exec 1>$LOGPIPE
|
122
|
+
# Close STDERR, reopen it directing it to the logpipe
|
123
|
+
exec 2>&-
|
124
|
+
exec 2>$LOGPIPE
|
125
|
+
|
126
|
+
|
127
|
+
#--- FUNCTION ----------------------------------------------------------------
|
128
|
+
# NAME: __gather_os_info
|
129
|
+
# DESCRIPTION: Discover operating system information
|
130
|
+
#-------------------------------------------------------------------------------
|
131
|
+
__gather_os_info() {
|
132
|
+
OS_NAME=$(uname -s 2>/dev/null)
|
133
|
+
OS_NAME_L=$( echo $OS_NAME | tr '[:upper:]' '[:lower:]' )
|
134
|
+
OS_VERSION=$(uname -r)
|
135
|
+
OS_VERSION_L=$( echo $OS_VERSION | tr '[:upper:]' '[:lower:]' )
|
136
|
+
MACHINE=$(uname -m 2>/dev/null || uname -p 2>/dev/null || echo "unknown")
|
137
|
+
}
|
138
|
+
__gather_os_info
|
139
|
+
|
140
|
+
|
141
|
+
#--- FUNCTION ----------------------------------------------------------------
|
142
|
+
# NAME: __gather_linux_system_info
|
143
|
+
# DESCRIPTION: Discover Linux system information
|
144
|
+
#-------------------------------------------------------------------------------
|
145
|
+
__gather_linux_system_info() {
|
146
|
+
DISTRO_NAME=""
|
147
|
+
DISTRO_VERSION=""
|
148
|
+
|
149
|
+
if [ -f /etc/lsb-release ]; then
|
150
|
+
DISTRO_NAME=$(grep DISTRIB_ID /etc/lsb-release | sed -e 's/.*=//')
|
151
|
+
DISTRO_VERSION=$(grep DISTRIB_RELEASE /etc/lsb-release | sed -e 's/.*=//')
|
152
|
+
fi
|
153
|
+
|
154
|
+
if [ "x$DISTRO_NAME" != "x" -a "x$DISTRO_VERSION" != "x" ]; then
|
155
|
+
# We already have the distribution name and version
|
156
|
+
return
|
157
|
+
fi
|
158
|
+
|
159
|
+
for rsource in $(
|
160
|
+
cd /etc && /bin/ls *[_-]release *[_-]version 2>/dev/null | env -i sort | \
|
161
|
+
sed -e '/^redhat-release$/d' -e '/^lsb-release$/d'; \
|
162
|
+
echo redhat-release lsb-release
|
163
|
+
); do
|
164
|
+
|
165
|
+
[ ! -f "/etc/${rsource}" ] && continue
|
166
|
+
|
167
|
+
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
|
+
)
|
176
|
+
case $(echo ${n} | tr '[:upper:]' '[:lower:]') in
|
177
|
+
redhat )
|
178
|
+
if [ ".$(egrep '(Red Hat Enterprise Linux|CentOS)' /etc/${rsource})" != . ]; then
|
179
|
+
n="<R>ed <H>at <E>nterprise <L>inux"
|
180
|
+
else
|
181
|
+
n="<R>ed <H>at <L>inux"
|
182
|
+
fi
|
183
|
+
;;
|
184
|
+
arch ) n="Arch" ;;
|
185
|
+
centos ) n="CentOS" ;;
|
186
|
+
debian ) n="Debian" ;;
|
187
|
+
ubuntu ) n="Ubuntu" ;;
|
188
|
+
fedora ) n="Fedora" ;;
|
189
|
+
suse ) n="SUSE" ;;
|
190
|
+
mandrake*|mandriva ) n="Mandriva" ;;
|
191
|
+
gentoo ) n="Gentoo" ;;
|
192
|
+
slackware ) n="Slackware" ;;
|
193
|
+
turbolinux ) n="TurboLinux" ;;
|
194
|
+
unitedlinux ) n="UnitedLinux" ;;
|
195
|
+
* ) n="${n}" ;
|
196
|
+
esac
|
197
|
+
DISTRO_NAME=$n
|
198
|
+
DISTRO_VERSION=$v
|
199
|
+
break
|
200
|
+
done
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
#--- FUNCTION ----------------------------------------------------------------
|
205
|
+
# NAME: __gather_sunos_system_info
|
206
|
+
# DESCRIPTION: Discover SunOS system info
|
207
|
+
#-------------------------------------------------------------------------------
|
208
|
+
__gather_sunos_system_info() {
|
209
|
+
DISTRO_NAME="Solaris"
|
210
|
+
DISTRO_VERSION=$(
|
211
|
+
echo "${OS_VERSION}" |
|
212
|
+
sed -e 's;^4\.;1.;' \
|
213
|
+
-e 's;^5\.\([0-6]\)[^0-9]*$;2.\1;' \
|
214
|
+
-e 's;^5\.\([0-9][0-9]*\).*;\1;'
|
215
|
+
)
|
216
|
+
}
|
217
|
+
|
218
|
+
|
219
|
+
#--- FUNCTION ----------------------------------------------------------------
|
220
|
+
# NAME: __gather_bsd_system_info
|
221
|
+
# DESCRIPTION: Discover OpenBSD, NetBSD and FreeBSD systems information
|
222
|
+
#-------------------------------------------------------------------------------
|
223
|
+
__gather_bsd_system_info() {
|
224
|
+
DISTRO_NAME=${OS_NAME}
|
225
|
+
DISTRO_VERSION=$(echo "${OS_VERSION}" | sed -e 's;[()];;' -e 's/\(-.*\)$/[\1]/')
|
226
|
+
}
|
227
|
+
|
228
|
+
|
229
|
+
#--- FUNCTION ----------------------------------------------------------------
|
230
|
+
# NAME: __gather_system_info
|
231
|
+
# DESCRIPTION: Discover which system and distribution we are running.
|
232
|
+
#-------------------------------------------------------------------------------
|
233
|
+
__gather_system_info() {
|
234
|
+
case ${OS_NAME_L} in
|
235
|
+
linux )
|
236
|
+
__gather_linux_system_info
|
237
|
+
;;
|
238
|
+
sunos )
|
239
|
+
__gather_sunos_system_info
|
240
|
+
;;
|
241
|
+
openbsd|freebsd|netbsd )
|
242
|
+
__gather_bsd_system_info
|
243
|
+
;;
|
244
|
+
* )
|
245
|
+
echo " * ERROR: $OS_NAME not supported.";
|
246
|
+
exit 1
|
247
|
+
;;
|
248
|
+
esac
|
249
|
+
|
250
|
+
}
|
251
|
+
|
252
|
+
|
253
|
+
#--- FUNCTION ----------------------------------------------------------------
|
254
|
+
# NAME: __function_defined
|
255
|
+
# DESCRIPTION: Checks if a function is defined within this scripts scope
|
256
|
+
# PARAMETERS: function name
|
257
|
+
# RETURNS: 0 or 1 as in defined or not defined
|
258
|
+
#-------------------------------------------------------------------------------
|
259
|
+
__function_defined() {
|
260
|
+
FUNC_NAME=$1
|
261
|
+
if [ ${DISTRO_NAME} = "centos" ]; then
|
262
|
+
if typeset -f $FUNC_NAME &>/dev/null ; then
|
263
|
+
echo " * INFO: Found function $FUNC_NAME"
|
264
|
+
return 0
|
265
|
+
fi
|
266
|
+
elif [ ${DISTRO_NAME} = "ubuntu" ]; then
|
267
|
+
if $( type ${FUNC_NAME} | grep -q 'shell function' ); then
|
268
|
+
echo " * INFO: Found function $FUNC_NAME"
|
269
|
+
return 0
|
270
|
+
fi
|
271
|
+
# Last resorts try POSIXLY_CORRECT or not
|
272
|
+
elif test -n "${POSIXLY_CORRECT+yes}"; then
|
273
|
+
if typeset -f $FUNC_NAME &>/dev/null ; then
|
274
|
+
echo " * INFO: Found function $FUNC_NAME"
|
275
|
+
return 0
|
276
|
+
fi
|
277
|
+
else
|
278
|
+
# Arch linux seems to fall here
|
279
|
+
if $( type ${FUNC_NAME} &>/dev/null ) ; then
|
280
|
+
echo " * INFO: Found function $FUNC_NAME"
|
281
|
+
return 0
|
282
|
+
fi
|
283
|
+
fi
|
284
|
+
echo " * INFO: $FUNC_NAME not found...."
|
285
|
+
return 1
|
286
|
+
}
|
287
|
+
__gather_system_info
|
288
|
+
|
289
|
+
echo " * System Information:"
|
290
|
+
echo " OS Name: ${OS_NAME}"
|
291
|
+
echo " OS Version: ${OS_VERSION}"
|
292
|
+
echo " Machine: ${MACHINE}"
|
293
|
+
echo " Distribution: ${DISTRO_NAME} ${DISTRO_VERSION}"
|
294
|
+
|
295
|
+
|
296
|
+
# Simplify version naming on functions
|
297
|
+
if [ "x${DISTRO_VERSION}" = "x" ]; then
|
298
|
+
DISTRO_VERSION_NO_DOTS=""
|
299
|
+
else
|
300
|
+
DISTRO_VERSION_NO_DOTS="_$(echo $DISTRO_VERSION | tr -d '.')"
|
301
|
+
fi
|
302
|
+
# Simplify distro name naming on functions
|
303
|
+
DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]')
|
304
|
+
|
305
|
+
##############################################################################
|
306
|
+
#
|
307
|
+
# Distribution install functions
|
308
|
+
#
|
309
|
+
# In order to install salt for a distribution you need to define:
|
310
|
+
#
|
311
|
+
# To Install Dependencies, which is required, one of:
|
312
|
+
# 1. install_<distro>_<distro_version>_<install_type>_deps
|
313
|
+
# 2. install_<distro>_<distro_version>_deps
|
314
|
+
# 3. install_<distro>_<install_type>_deps
|
315
|
+
# 4. install_<distro>_deps
|
316
|
+
#
|
317
|
+
#
|
318
|
+
# To install salt, which, of course, is required, one of:
|
319
|
+
# 1. install_<distro>_<distro_version>_<install_type>
|
320
|
+
# 1. install_<distro>_<install_type>
|
321
|
+
#
|
322
|
+
#
|
323
|
+
# And optionally, define a post install function, one of:
|
324
|
+
# 1. install_<distro>_<distro_versions>_<install_type>_post
|
325
|
+
# 2. install_<distro>_<distro_versions>_post
|
326
|
+
# 3. install_<distro>_<install_type>_post
|
327
|
+
# 4. install_<distro>_post
|
328
|
+
#
|
329
|
+
##############################################################################
|
330
|
+
|
331
|
+
##############################################################################
|
332
|
+
#
|
333
|
+
# Ubuntu Install Functions
|
334
|
+
#
|
335
|
+
##############################################################################
|
336
|
+
install_ubuntu_deps() {
|
337
|
+
apt-get update
|
338
|
+
apt-get -y install python-software-properties
|
339
|
+
add-apt-repository -y ppa:saltstack/salt
|
340
|
+
apt-get update
|
341
|
+
}
|
342
|
+
|
343
|
+
install_ubuntu_1004_deps() {
|
344
|
+
apt-get update
|
345
|
+
apt-get -y install python-software-properties
|
346
|
+
add-apt-repository ppa:saltstack/salt
|
347
|
+
apt-get update
|
348
|
+
apt-get -y install salt-minion
|
349
|
+
}
|
350
|
+
|
351
|
+
install_ubuntu_1110_deps() {
|
352
|
+
apt-get update
|
353
|
+
apt-get -y install python-software-properties
|
354
|
+
add-apt-repository -y 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'
|
355
|
+
add-apt-repository -y ppa:saltstack/salt
|
356
|
+
}
|
357
|
+
|
358
|
+
install_ubuntu_daily_deps() {
|
359
|
+
apt-get update
|
360
|
+
apt-get -y install python-software-properties
|
361
|
+
add-apt-repository -y ppa:saltstack/salt-daily
|
362
|
+
apt-get update
|
363
|
+
}
|
364
|
+
|
365
|
+
install_ubuntu_1110_post() {
|
366
|
+
add-apt-repository -y --remove 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'
|
367
|
+
}
|
368
|
+
|
369
|
+
install_ubuntu_stable() {
|
370
|
+
apt-get -y install salt-minion
|
371
|
+
}
|
372
|
+
|
373
|
+
install_ubuntu_daily() {
|
374
|
+
apt-get -y install salt-minion
|
375
|
+
}
|
376
|
+
#
|
377
|
+
# End of Ubuntu Install Functions
|
378
|
+
#
|
379
|
+
##############################################################################
|
380
|
+
|
381
|
+
##############################################################################
|
382
|
+
#
|
383
|
+
# Debian Install Functions
|
384
|
+
#
|
385
|
+
install_debian_60_stable_deps() {
|
386
|
+
echo "deb http://backports.debian.org/debian-backports squeeze-backports main" >> \
|
387
|
+
/etc/apt/sources.list.d/backports.list
|
388
|
+
apt-get update
|
389
|
+
}
|
390
|
+
|
391
|
+
install_debian_60_stable() {
|
392
|
+
apt-get -t squeeze-backports -y install salt-minion
|
393
|
+
}
|
394
|
+
#
|
395
|
+
# Ended Debian Install Functions
|
396
|
+
#
|
397
|
+
##############################################################################
|
398
|
+
|
399
|
+
##############################################################################
|
400
|
+
#
|
401
|
+
# CentOS Install Functions
|
402
|
+
#
|
403
|
+
install_centos_63_stable_deps() {
|
404
|
+
rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/6/x86_64/epel-release-6-7.noarch.rpm
|
405
|
+
yum -y update
|
406
|
+
}
|
407
|
+
|
408
|
+
install_centos_63_stable() {
|
409
|
+
yum -y install salt-minion --enablerepo=epel-testing
|
410
|
+
}
|
411
|
+
|
412
|
+
install_centos_63_stable_post() {
|
413
|
+
/sbin/chkconfig salt-minion on
|
414
|
+
salt-minion start &
|
415
|
+
}
|
416
|
+
#
|
417
|
+
# Ended CentOS Install Functions
|
418
|
+
#
|
419
|
+
##############################################################################
|
420
|
+
|
421
|
+
#=============================================================================
|
422
|
+
# LET'S PROCEED WITH OUR INSTALLATION
|
423
|
+
#=============================================================================
|
424
|
+
# Let's get the dependencies install function
|
425
|
+
DEP_FUNC_NAMES="install_${DISTRO_NAME_L}${DISTRO_VERSION_NO_DOTS}_${ITYPE}_deps"
|
426
|
+
DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}${DISTRO_VERSION_NO_DOTS}_deps"
|
427
|
+
DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}_deps"
|
428
|
+
DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}_deps"
|
429
|
+
|
430
|
+
DEPS_INSTALL_FUNC="null"
|
431
|
+
for DEP_FUNC_NAME in $DEP_FUNC_NAMES; do
|
432
|
+
if __function_defined $DEP_FUNC_NAME; then
|
433
|
+
DEPS_INSTALL_FUNC=$DEP_FUNC_NAME
|
434
|
+
break
|
435
|
+
fi
|
436
|
+
done
|
437
|
+
|
438
|
+
|
439
|
+
# Let's get the install function
|
440
|
+
INSTALL_FUNC_NAMES="install_${DISTRO_NAME_L}${DISTRO_VERSION_NO_DOTS}_${ITYPE}"
|
441
|
+
INSTALL_FUNC_NAMES="$INSTALL_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}"
|
442
|
+
|
443
|
+
INSTALL_FUNC="null"
|
444
|
+
for FUNC_NAME in $INSTALL_FUNC_NAMES; do
|
445
|
+
if __function_defined $FUNC_NAME; then
|
446
|
+
INSTALL_FUNC=$FUNC_NAME
|
447
|
+
break
|
448
|
+
fi
|
449
|
+
done
|
450
|
+
|
451
|
+
|
452
|
+
# Let's get the dependencies install function
|
453
|
+
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"
|
457
|
+
|
458
|
+
POST_INSTALL_FUNC="null"
|
459
|
+
for FUNC_NAME in $POST_FUNC_NAMES; do
|
460
|
+
if __function_defined $FUNC_NAME; then
|
461
|
+
DEPS_INSTALL_FUNC=$FUNC_NAME
|
462
|
+
break
|
463
|
+
fi
|
464
|
+
done
|
465
|
+
|
466
|
+
|
467
|
+
if [ $DEPS_INSTALL_FUNC = "null" ]; then
|
468
|
+
echo " * ERROR: No dependencies installation function found. Exiting..."
|
469
|
+
exit 1
|
470
|
+
fi
|
471
|
+
|
472
|
+
if [ $DEPS_INSTALL_FUNC = "null" ]; then
|
473
|
+
echo " * ERROR: No installation function found. Exiting..."
|
474
|
+
exit 1
|
475
|
+
fi
|
476
|
+
|
477
|
+
|
478
|
+
# Install dependencies
|
479
|
+
echo " * Running ${DEPS_INSTALL_FUNC}()"
|
480
|
+
$DEPS_INSTALL_FUNC
|
481
|
+
|
482
|
+
# Install Salt
|
483
|
+
echo " * Running ${INSTALL_FUNC}()"
|
484
|
+
$INSTALL_FUNC
|
485
|
+
|
486
|
+
# Run any post install function
|
487
|
+
if [ "$POST_INSTALL_FUNC" != "null" ]; then
|
488
|
+
echo " * Running ${POST_INSTALL_FUNC}()"
|
489
|
+
$POST_INSTALL_FUNC
|
490
|
+
fi
|
491
|
+
|
492
|
+
# Done!
|
493
|
+
echo " * Salt installed!"
|
data/vagrant-salt.gemspec
CHANGED
@@ -3,10 +3,10 @@ $:.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.
|
7
|
-
s.authors = ["Alec Koumjian", "Kiall Mac Innes"]
|
8
|
-
s.email = ["akoumjian@gmail.com", "kiall@managedit.ie"]
|
9
|
-
s.homepage = "https://github.com/
|
6
|
+
s.version = "0.1.4"
|
7
|
+
s.authors = ["Alec Koumjian", "Kiall Mac Innes", "Pedro Algarvio"]
|
8
|
+
s.email = ["akoumjian@gmail.com", "kiall@managedit.ie", "pedro@algarvio.me"]
|
9
|
+
s.homepage = "https://github.com/saltstack/salty-vagrant"
|
10
10
|
s.summary = %q{Vagrant Salt Stack provisioner plugin}
|
11
11
|
s.description = %q{Vagrant Salt Stack provisioner plugin}
|
12
12
|
|
metadata
CHANGED
@@ -5,17 +5,18 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alec Koumjian
|
13
13
|
- Kiall Mac Innes
|
14
|
+
- Pedro Algarvio
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2012-
|
19
|
+
date: 2012-10-19 00:00:00 -07:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
@@ -34,6 +35,7 @@ description: Vagrant Salt Stack provisioner plugin
|
|
34
35
|
email:
|
35
36
|
- akoumjian@gmail.com
|
36
37
|
- kiall@managedit.ie
|
38
|
+
- pedro@algarvio.me
|
37
39
|
executables: []
|
38
40
|
|
39
41
|
extensions: []
|
@@ -54,9 +56,10 @@ files:
|
|
54
56
|
- lib/vagrant-salt.rb
|
55
57
|
- lib/vagrant-salt/provisioner.rb
|
56
58
|
- lib/vagrant_init.rb
|
59
|
+
- scripts/bootstrap-salt-minion.sh
|
57
60
|
- vagrant-salt.gemspec
|
58
61
|
has_rdoc: true
|
59
|
-
homepage: https://github.com/
|
62
|
+
homepage: https://github.com/saltstack/salty-vagrant
|
60
63
|
licenses: []
|
61
64
|
|
62
65
|
post_install_message:
|