vagrant-salt 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/README.rst +131 -170
  2. data/example/complete/Vagrantfile +67 -0
  3. data/example/complete/salt/custom-bootstrap-salt.sh +2425 -0
  4. data/example/complete/salt/key/master.pem +30 -0
  5. data/example/complete/salt/key/master.pub +14 -0
  6. data/example/complete/salt/key/minion.pem +30 -0
  7. data/example/complete/salt/key/minion.pub +14 -0
  8. data/example/complete/salt/master +459 -0
  9. data/example/{salt/minion.conf → complete/salt/minion} +1 -2
  10. data/example/{salt → complete/salt}/roots/pillar/top.sls +0 -0
  11. data/example/complete/salt/roots/salt/nginx.sls +5 -0
  12. data/example/complete/salt/roots/salt/top.sls +3 -0
  13. data/example/masterless/Vagrantfile +18 -0
  14. data/example/masterless/salt/minion +219 -0
  15. data/example/{salt/roots/salt → masterless/salt/roots/pillar}/top.sls +0 -0
  16. data/example/masterless/salt/roots/salt/nginx.sls +5 -0
  17. data/example/masterless/salt/roots/salt/top.sls +3 -0
  18. data/lib/vagrant-salt.rb +16 -3
  19. data/lib/vagrant-salt/config.rb +103 -0
  20. data/lib/vagrant-salt/errors.rb +11 -0
  21. data/lib/vagrant-salt/plugin.rb +31 -0
  22. data/lib/vagrant-salt/provisioner.rb +211 -104
  23. data/lib/vagrant-salt/version.rb +5 -0
  24. data/scripts/.travis.yml +16 -0
  25. data/scripts/ChangeLog +39 -0
  26. data/scripts/LICENSE +16 -0
  27. data/scripts/README.rst +124 -35
  28. data/scripts/bootstrap-salt-minion.sh +1815 -381
  29. data/scripts/bootstrap-salt.sh +2425 -0
  30. data/scripts/salt-bootstrap.sh +2425 -0
  31. data/scripts/tests/README.rst +38 -0
  32. data/scripts/tests/bootstrap/__init__.py +11 -0
  33. data/{example/salt/key/KEYPAIR_GOES_HERE → scripts/tests/bootstrap/ext/__init__.py} +0 -0
  34. data/scripts/tests/bootstrap/ext/console.py +100 -0
  35. data/scripts/tests/bootstrap/ext/os_data.py +199 -0
  36. data/scripts/tests/bootstrap/test_install.py +586 -0
  37. data/scripts/tests/bootstrap/test_lint.py +27 -0
  38. data/scripts/tests/bootstrap/test_usage.py +28 -0
  39. data/scripts/tests/bootstrap/unittesting.py +216 -0
  40. data/scripts/tests/ext/checkbashisms +640 -0
  41. data/scripts/tests/install-testsuite-deps.py +99 -0
  42. data/scripts/tests/runtests.py +207 -0
  43. data/templates/locales/en.yml +14 -0
  44. data/vagrant-salt.gemspec +2 -2
  45. metadata +43 -10
  46. data/example/Vagrantfile +0 -26
  47. data/lib/vagrant_init.rb +0 -1
@@ -1,9 +1,8 @@
1
- # DO NOT MODIFY THIS FILE. Copy it to: /etc/salt/minion
2
1
  ##### Primary configuration settings #####
3
2
  ##########################################
4
3
  # Set the location of the salt master server, if the master server cannot be
5
4
  # resolved, then the minion will fail to start.
6
- #master: salt
5
+ master: localhost
7
6
 
8
7
  # Set the port used by the master reply and authentication server
9
8
  #master_port: 4506
@@ -0,0 +1,5 @@
1
+ nginx:
2
+ pkg:
3
+ - installed
4
+ service:
5
+ - running
@@ -0,0 +1,3 @@
1
+ base:
2
+ '*':
3
+ - nginx
@@ -0,0 +1,18 @@
1
+ Vagrant.configure("2") do |config|
2
+ ## Choose your base box
3
+ config.vm.box = "precise64"
4
+
5
+ ## For masterless, mount your file roots file root
6
+ config.vm.synced_folder "salt/roots/", "/srv/"
7
+
8
+ ## Set your salt configs here
9
+ config.vm.provision :salt do |salt|
10
+
11
+ ## Minion config is set to ``file_client: local`` for masterless
12
+ salt.minion_config = "salt/minion"
13
+
14
+ ## Installs our example formula in "salt/roots/salt"
15
+ salt.run_highstate = true
16
+
17
+ end
18
+ end
@@ -0,0 +1,219 @@
1
+ ##### Primary configuration settings #####
2
+ ##########################################
3
+ # Set the location of the salt master server, if the master server cannot be
4
+ # resolved, then the minion will fail to start.
5
+ master: localhost
6
+
7
+ # Set the port used by the master reply and authentication server
8
+ #master_port: 4506
9
+
10
+ # The user to run salt
11
+ #user: root
12
+
13
+ # The root directory prepended to these options: pki_dir, cachedir, log_file.
14
+ #root_dir: /
15
+
16
+ # The directory to store the pki information in
17
+ #pki_dir: /etc/salt/pki
18
+
19
+ # Explicitly declare the id for this minion to use, if left commented the id
20
+ # will be the hostname as returned by the python call: socket.getfqdn()
21
+ # Since salt uses detached ids it is possible to run multiple minions on the
22
+ # same machine but with different ids, this can be useful for salt compute
23
+ # clusters.
24
+ #id: testing
25
+
26
+ # Append a domain to a hostname in the event that it does not exist. This is
27
+ # usefule for systems where socket.getfqdn() does not actually result in a
28
+ # FQDN (for instance, Solaris).
29
+ #append_domain:
30
+
31
+ # If the the connection to the server is interrupted, the minion will
32
+ # attempt to reconnect. sub_timeout allows you to control the rate
33
+ # of reconnection attempts (in seconds). To disable reconnects, set
34
+ # this value to 0.
35
+ #sub_timeout: 60
36
+
37
+ # Where cache data goes
38
+ #cachedir: /var/cache/salt
39
+
40
+ # The minion can locally cache the return data from jobs sent to it, this
41
+ # can be a good way to keep track of jobs the minion has executed
42
+ # (on the minion side). By default this feature is disabled, to enable
43
+ # set cache_jobs to True
44
+ #cache_jobs: False
45
+
46
+ # When waiting for a master to accept the minion's public key, salt will
47
+ # continuously attempt to reconnect until successful. This is the time, in
48
+ # seconds, between those reconnection attempts.
49
+ #acceptance_wait_time = 10
50
+
51
+ # When healing a dns_check is run, this is to make sure that the originally
52
+ # resolved dns has not changed, if this is something that does not happen in
53
+ # your environment then set this value to False.
54
+ #dns_check: True
55
+
56
+
57
+ ##### Minion module management #####
58
+ ##########################################
59
+ # Disable specific modules. This allows the admin to limit the level of
60
+ # access the master has to the minion
61
+ #disable_modules: [cmd,test]
62
+ #disable_returners: []
63
+ #
64
+ # Modules can be loaded from arbitrary paths. This enables the easy deployment
65
+ # of third party modules. Modules for returners and minions can be loaded.
66
+ # Specify a list of extra directories to search for minion modules and
67
+ # returners. These paths must be fully qualified!
68
+ #module_dirs: []
69
+ #returner_dirs: []
70
+ #states_dirs: []
71
+ #render_dirs: []
72
+ #
73
+ # A module provider can be statically overwritten or extended for the minion
74
+ # via the providers option, in this case the default module will be
75
+ # overwritten by the specified module. In this example the pkg module will
76
+ # be provided by the yumpkg5 module instead of the system default.
77
+ #
78
+ # providers:
79
+ # pkg: yumpkg5
80
+ #
81
+ # Enable Cython modules searching and loading. (Default: False)
82
+ #cython_enable: False
83
+
84
+ ##### State Management Settings #####
85
+ ###########################################
86
+ # The state management system executes all of the state templates on the minion
87
+ # to enable more granular control of system state management. The type of
88
+ # template and serialization used for state management needs to be configured
89
+ # on the minion, the default renderer is yaml_jinja. This is a yaml file
90
+ # rendered from a jinja template, the available options are:
91
+ # yaml_jinja
92
+ # yaml_mako
93
+ # json_jinja
94
+ # json_mako
95
+ #
96
+ #renderer: yaml_jinja
97
+ #
98
+ # state_verbose allows for the data returned from the minion to be more
99
+ # verbose. Normaly only states that fail or states that have changes are
100
+ # returned, but setting state_verbose to True will return all states that
101
+ # were checked
102
+ #state_verbose: False
103
+ #
104
+ # autoload_dynamic_modules Turns on automatic loading of modules found in the
105
+ # environments on the master. This is turned on by default, to turn of
106
+ # autoloading modules when states run set this value to False
107
+ #autoload_dynamic_modules: True
108
+ #
109
+ # clean_dynamic_modules keeps the dynamic modules on the minion in sync with
110
+ # the dynamic modules on the master, this means that if a dynamic module is
111
+ # not on the master it will be deleted from the minion. By default this is
112
+ # enabled and can be disabled by changing this value to False
113
+ #clean_dynamic_modules: True
114
+ #
115
+ # Normally the minion is not isolated to any single environment on the master
116
+ # when running states, but the environment can be isolated on the minion side
117
+ # by statically setting it. Remember that the recommended way to manage
118
+ # environments is to issolate via the top file.
119
+ #environment: None
120
+ #
121
+ # If using the local file directory, then the state top file name needs to be
122
+ # defined, by default this is top.sls.
123
+ #state_top: top.sls
124
+
125
+ ##### File Directory Settings #####
126
+ ##########################################
127
+ # The Salt Minion can redirect all file server operations to a local directory,
128
+ # this allows for the same state tree that is on the master to be used if
129
+ # coppied completely onto the minion. This is a literal copy of the settings on
130
+ # the master but used to reference a local directory on the minion.
131
+
132
+ # Set the file client, the client defaults to looking on the master server for
133
+ # files, but can be directed to look at the local file directory setting
134
+ # defined below by setting it to local.
135
+ file_client: local
136
+
137
+ # The file directory works on environments passed to the minion, each environment
138
+ # can have multiple root directories, the subdirectories in the multiple file
139
+ # roots cannot match, otherwise the downloaded files will not be able to be
140
+ # reliably ensured. A base environment is required to house the top file.
141
+ # Example:
142
+ # file_roots:
143
+ # base:
144
+ # - /srv/salt/
145
+ # dev:
146
+ # - /srv/salt/dev/services
147
+ # - /srv/salt/dev/states
148
+ # prod:
149
+ # - /srv/salt/prod/services
150
+ # - /srv/salt/prod/states
151
+ #
152
+ # Default:
153
+ #file_roots:
154
+ # base:
155
+ # - /srv/salt
156
+
157
+ # The hash_type is the hash to use when discovering the hash of a file in
158
+ # the minion directory, the default is md5, but sha1, sha224, sha256, sha384
159
+ # and sha512 are also supported.
160
+ #hash_type: md5
161
+
162
+ # The Salt pillar is searched for locally if file_client is set to local. If
163
+ # this is the case, and pillar data is defined, then the pillar_roots need to
164
+ # also be configured on the minion:
165
+ #pillar_roots:
166
+ # base:
167
+ # - /srv/pillar
168
+
169
+ ###### Security settings #####
170
+ ###########################################
171
+ # Enable "open mode", this mode still maintains encryption, but turns off
172
+ # authentication, this is only intended for highly secure environments or for
173
+ # the situation where your keys end up in a bad state. If you run in open mode
174
+ # you do so at your own risk!
175
+ #open_mode: False
176
+
177
+
178
+ ###### Thread settings #####
179
+ ###########################################
180
+ # Disable multiprocessing support, by default when a minion receives a
181
+ # publication a new process is spawned and the command is executed therein.
182
+ #multiprocessing: True
183
+
184
+ ###### Logging settings #####
185
+ ###########################################
186
+ # The location of the minion log file
187
+ #log_file: /var/log/salt/minion
188
+ #
189
+ # The level of messages to send to the log file.
190
+ # One of 'info', 'quiet', 'critical', 'error', 'debug', 'warning'.
191
+ # Default: 'warning'
192
+ #log_level: warning
193
+ #
194
+ # Logger levels can be used to tweak specific loggers logging levels.
195
+ # For example, if you want to have the salt library at the 'warning' level,
196
+ # but you still wish to have 'salt.modules' at the 'debug' level:
197
+ # log_granular_levels: {
198
+ # 'salt': 'warning',
199
+ # 'salt.modules': 'debug'
200
+ # }
201
+ #
202
+ #log_granular_levels: {}
203
+
204
+ ###### Module configuration #####
205
+ ###########################################
206
+ # Salt allows for modules to be passed arbitrary configuration data, any data
207
+ # passed here in valid yaml format will be passed on to the salt minion modules
208
+ # for use. It is STRONGLY recommended that a naming convention be used in which
209
+ # the module name is followed by a . and then the value. Also, all top level
210
+ # data must be applied via the yaml dict construct, some examples:
211
+ #
212
+ # A simple value for the test module:
213
+ #test.foo: foo
214
+ #
215
+ # A list for the test module:
216
+ #test.bar: [baz,quo]
217
+ #
218
+ # A dict for the test module:
219
+ #test.baz: {spam: sausage, cheese: bread}
@@ -0,0 +1,5 @@
1
+ nginx:
2
+ pkg:
3
+ - installed
4
+ service:
5
+ - running
@@ -0,0 +1,3 @@
1
+ base:
2
+ '*':
3
+ - nginx
@@ -1,4 +1,17 @@
1
- require "vagrant"
2
- require "vagrant-salt/provisioner"
1
+ require "pathname"
2
+ require "i18n"
3
+ require "vagrant-salt/plugin"
3
4
 
4
- Vagrant.provisioners.register(:salt) { VagrantSalt::Provisioner }
5
+ module VagrantPlugins
6
+ module Salt
7
+
8
+ lib_path = Pathname.new(File.expand_path("../vagrant-salt", __FILE__))
9
+ autoload :Errors, lib_path.join("errors")
10
+
11
+ @source_root = Pathname.new(File.expand_path("../../", __FILE__))
12
+
13
+ I18n.load_path << File.expand_path("templates/locales/en.yml", @source_root)
14
+ I18n.reload!
15
+
16
+ end
17
+ end
@@ -0,0 +1,103 @@
1
+ require "i18n"
2
+ require "vagrant"
3
+
4
+ module VagrantPlugins
5
+ module Salt
6
+ class Config < Vagrant.plugin("2", :config)
7
+
8
+ ## salty-vagrant options
9
+ attr_accessor :minion_config
10
+ attr_accessor :minion_key
11
+ attr_accessor :minion_pub
12
+ attr_accessor :master_config
13
+ attr_accessor :master_key
14
+ attr_accessor :master_pub
15
+ attr_accessor :run_highstate
16
+ attr_accessor :always_install
17
+ attr_accessor :accept_keys
18
+ attr_accessor :bootstrap_script
19
+ attr_accessor :verbose
20
+
21
+ ## bootstrap options
22
+ attr_accessor :temp_config_dir
23
+ attr_accessor :install_type
24
+ attr_accessor :install_args
25
+ attr_accessor :install_master
26
+ attr_accessor :install_syndic
27
+ attr_accessor :no_minion
28
+ attr_accessor :bootstrap_options
29
+
30
+ def initialize
31
+ @minion_config = UNSET_VALUE
32
+ @minion_key = UNSET_VALUE
33
+ @minion_pub = UNSET_VALUE
34
+ @master_config = UNSET_VALUE
35
+ @master_key = UNSET_VALUE
36
+ @master_pub = UNSET_VALUE
37
+ @run_highstate = UNSET_VALUE
38
+ @always_install = UNSET_VALUE
39
+ @accept_keys = UNSET_VALUE
40
+ @bootstrap_script = UNSET_VALUE
41
+ @verbose = UNSET_VALUE
42
+ @temp_config_dir = UNSET_VALUE
43
+ @install_type = UNSET_VALUE
44
+ @install_args = UNSET_VALUE
45
+ @install_master = UNSET_VALUE
46
+ @install_syndic = UNSET_VALUE
47
+ @no_minion = UNSET_VALUE
48
+ @bootstrap_options = UNSET_VALUE
49
+ end
50
+
51
+ def finalize!
52
+ @minion_config = nil if @minion_config == UNSET_VALUE
53
+ @minion_key = nil if @minion_key == UNSET_VALUE
54
+ @minion_pub = nil if @minion_pub == UNSET_VALUE
55
+ @master_config = nil if @master_config == UNSET_VALUE
56
+ @master_key = nil if @master_key == UNSET_VALUE
57
+ @master_pub = nil if @master_pub == UNSET_VALUE
58
+ @run_highstate = nil if @run_highstate == UNSET_VALUE
59
+ @always_install = nil if @always_install == UNSET_VALUE
60
+ @accept_keys = nil if @accept_keys == UNSET_VALUE
61
+ @bootstrap_script = nil if @bootstrap_script == UNSET_VALUE
62
+ @verbose = nil if @verbose == UNSET_VALUE
63
+ @temp_config_dir = nil if @temp_config_dir == UNSET_VALUE
64
+ @install_type = nil if @install_type == UNSET_VALUE
65
+ @install_args = nil if @install_args == UNSET_VALUE
66
+ @install_master = nil if @install_master == UNSET_VALUE
67
+ @install_syndic = nil if @install_syndic == UNSET_VALUE
68
+ @no_minion = nil if @no_minion == UNSET_VALUE
69
+ @bootstrap_options = nil if @bootstrap_options == UNSET_VALUE
70
+
71
+ end
72
+
73
+ def validate(machine)
74
+ errors = []
75
+ if @minion_key || @minion_pub
76
+ if !@minion_key || !@minion_pub
77
+ errors << @minion_pub
78
+ end
79
+ end
80
+
81
+ if @master_key && @master_pub
82
+ if !@minion_key && !@minion_pub
83
+ errors << I18n.t("salt.missing_key")
84
+ end
85
+ end
86
+
87
+ if @accept_keys && @no_minion
88
+ errors << I18n.t("salt.accept_key_no_minion")
89
+ elsif @accept_keys && !@install_master
90
+ errors << I18n.t("salt.accept_key_no_master")
91
+ end
92
+
93
+ if @install_master && !@no_minion && !@accept_keys && @run_highstate
94
+ errors << I18n.t("salt.must_accept_keys")
95
+ end
96
+
97
+ return {"salt" => errors}
98
+ end
99
+
100
+
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,11 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module Salt
5
+ module Errors
6
+ class SaltError < Vagrant::Errors::VagrantError
7
+ error_namespace("salt")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Vagrant Salt plugin must be run within Vagrant."
5
+ end
6
+
7
+ if Vagrant::VERSION < "1.1.0"
8
+ raise "Please install vagrant-salt gem <=0.3.4 for Vagrant < 1.1.0"
9
+ end
10
+
11
+ module VagrantPlugins
12
+ module Salt
13
+ class Plugin < Vagrant.plugin("2")
14
+ name "salt"
15
+ description <<-DESC
16
+ Provisions virtual machines using SaltStack
17
+ DESC
18
+
19
+ config(:salt, :provisioner) do
20
+ require File.expand_path("../config", __FILE__)
21
+ Config
22
+ end
23
+
24
+ provisioner(:salt) do
25
+ require File.expand_path("../provisioner", __FILE__)
26
+ Provisioner
27
+ end
28
+
29
+ end
30
+ end
31
+ end