master_manipulator 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 82c90ccb9f7a1f77f034cb73f4c8d758d961cf34
4
+ data.tar.gz: 8547f78eb24085267afec5fd669d6be03acb3a38
5
+ SHA512:
6
+ metadata.gz: 2ed736250d0ed64c218ede0274677eaa01b08079167f10f661a762aff0724f6285181e65326a3f777189bf7991bc4580abe47560c3409957f17c0595f83c364e
7
+ data.tar.gz: fa9927b9a7bd56d6a98ad6c1741c6eedd5415abb73544f0e756111d2691c7b1501a7e13ccf99163ea68dd2d5e31576792456d8b688f6223fd1df1330a743adf1
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+ #this will probably not be available on rubygems, at least initially
3
+ #will probably be only available at https://rubygems.delivery.puppetlabs.net
4
+ #TODO: Change this line when it is actually available internally
5
+
6
+ # Specify your gem's dependencies in master_manipulator.gemspec
7
+ gemspec
@@ -0,0 +1,267 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ master_manipulator (1.1.2)
5
+ beaker (~> 2.7, >= 2.7.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ CFPropertyList (2.3.1)
11
+ activesupport (4.2.3)
12
+ i18n (~> 0.7)
13
+ json (~> 1.7, >= 1.7.7)
14
+ minitest (~> 5.1)
15
+ thread_safe (~> 0.3, >= 0.3.4)
16
+ tzinfo (~> 1.1)
17
+ addressable (2.3.8)
18
+ autoparse (0.3.3)
19
+ addressable (>= 2.3.1)
20
+ extlib (>= 0.9.15)
21
+ multi_json (>= 1.0.0)
22
+ aws-sdk (1.64.0)
23
+ aws-sdk-v1 (= 1.64.0)
24
+ aws-sdk-v1 (1.64.0)
25
+ json (~> 1.4)
26
+ nokogiri (>= 1.4.4)
27
+ beaker (2.18.0)
28
+ aws-sdk (~> 1.57)
29
+ docker-api
30
+ fission (~> 0.4)
31
+ fog (~> 1.25)
32
+ google-api-client (~> 0.8)
33
+ hocon (~> 0.1)
34
+ inifile (~> 2.0)
35
+ json (~> 1.8)
36
+ minitest (~> 5.4)
37
+ net-scp (~> 1.2)
38
+ net-ssh (~> 2.9)
39
+ open_uri_redirections (~> 0.2.1)
40
+ rbvmomi (~> 1.8)
41
+ rsync (~> 1.0.9)
42
+ unf (~> 0.1)
43
+ builder (3.2.2)
44
+ coderay (1.1.0)
45
+ diff-lcs (1.2.5)
46
+ docile (1.1.5)
47
+ docker-api (1.21.4)
48
+ excon (>= 0.38.0)
49
+ json
50
+ excon (0.45.4)
51
+ extlib (0.9.16)
52
+ faraday (0.9.1)
53
+ multipart-post (>= 1.2, < 3)
54
+ fission (0.5.0)
55
+ CFPropertyList (~> 2.2)
56
+ fog (1.32.0)
57
+ fog-atmos
58
+ fog-aws (>= 0.6.0)
59
+ fog-brightbox (~> 0.4)
60
+ fog-core (~> 1.32)
61
+ fog-ecloud (= 0.1.1)
62
+ fog-google (>= 0.0.2)
63
+ fog-json
64
+ fog-local
65
+ fog-powerdns (>= 0.1.1)
66
+ fog-profitbricks
67
+ fog-radosgw (>= 0.0.2)
68
+ fog-riakcs
69
+ fog-sakuracloud (>= 0.0.4)
70
+ fog-serverlove
71
+ fog-softlayer
72
+ fog-storm_on_demand
73
+ fog-terremark
74
+ fog-vmfusion
75
+ fog-voxel
76
+ fog-xml (~> 0.1.1)
77
+ ipaddress (~> 0.5)
78
+ nokogiri (~> 1.5, >= 1.5.11)
79
+ fog-atmos (0.1.0)
80
+ fog-core
81
+ fog-xml
82
+ fog-aws (0.7.3)
83
+ fog-core (~> 1.27)
84
+ fog-json (~> 1.0)
85
+ fog-xml (~> 0.1)
86
+ ipaddress (~> 0.8)
87
+ fog-brightbox (0.7.2)
88
+ fog-core (~> 1.22)
89
+ fog-json
90
+ inflecto (~> 0.0.2)
91
+ fog-core (1.32.0)
92
+ builder
93
+ excon (~> 0.45)
94
+ formatador (~> 0.2)
95
+ mime-types
96
+ net-scp (~> 1.1)
97
+ net-ssh (>= 2.1.3)
98
+ fog-ecloud (0.1.1)
99
+ fog-core
100
+ fog-xml
101
+ fog-google (0.0.7)
102
+ fog-core
103
+ fog-json
104
+ fog-xml
105
+ fog-json (1.0.2)
106
+ fog-core (~> 1.0)
107
+ multi_json (~> 1.10)
108
+ fog-local (0.2.1)
109
+ fog-core (~> 1.27)
110
+ fog-powerdns (0.1.1)
111
+ fog-core (~> 1.27)
112
+ fog-json (~> 1.0)
113
+ fog-xml (~> 0.1)
114
+ fog-profitbricks (0.0.3)
115
+ fog-core
116
+ fog-xml
117
+ nokogiri
118
+ fog-radosgw (0.0.4)
119
+ fog-core (>= 1.21.0)
120
+ fog-json
121
+ fog-xml (>= 0.0.1)
122
+ fog-riakcs (0.1.0)
123
+ fog-core
124
+ fog-json
125
+ fog-xml
126
+ fog-sakuracloud (1.0.1)
127
+ fog-core
128
+ fog-json
129
+ fog-serverlove (0.1.2)
130
+ fog-core
131
+ fog-json
132
+ fog-softlayer (0.4.7)
133
+ fog-core
134
+ fog-json
135
+ fog-storm_on_demand (0.1.1)
136
+ fog-core
137
+ fog-json
138
+ fog-terremark (0.1.0)
139
+ fog-core
140
+ fog-xml
141
+ fog-vmfusion (0.1.0)
142
+ fission
143
+ fog-core
144
+ fog-voxel (0.1.0)
145
+ fog-core
146
+ fog-xml
147
+ fog-xml (0.1.2)
148
+ fog-core
149
+ nokogiri (~> 1.5, >= 1.5.11)
150
+ formatador (0.2.5)
151
+ google-api-client (0.8.6)
152
+ activesupport (>= 3.2)
153
+ addressable (~> 2.3)
154
+ autoparse (~> 0.3)
155
+ extlib (~> 0.9)
156
+ faraday (~> 0.9)
157
+ googleauth (~> 0.3)
158
+ launchy (~> 2.4)
159
+ multi_json (~> 1.10)
160
+ retriable (~> 1.4)
161
+ signet (~> 0.6)
162
+ googleauth (0.4.1)
163
+ faraday (~> 0.9)
164
+ jwt (~> 1.4)
165
+ logging (~> 2.0)
166
+ memoist (~> 0.12)
167
+ multi_json (= 1.11)
168
+ signet (~> 0.6)
169
+ hocon (0.9.2)
170
+ i18n (0.7.0)
171
+ inflecto (0.0.2)
172
+ inifile (2.0.2)
173
+ ipaddress (0.8.0)
174
+ json (1.8.3)
175
+ jwt (1.5.1)
176
+ kramdown (1.8.0)
177
+ launchy (2.4.3)
178
+ addressable (~> 2.3)
179
+ little-plugger (1.1.3)
180
+ logging (2.0.0)
181
+ little-plugger (~> 1.1)
182
+ multi_json (~> 1.10)
183
+ logutils (0.6.1)
184
+ markdown (0.4.0)
185
+ kramdown (>= 0.13.7)
186
+ props (>= 0.2.0)
187
+ textutils (>= 0.2.0)
188
+ memoist (0.12.0)
189
+ method_source (0.8.2)
190
+ mime-types (2.6.1)
191
+ mini_portile (0.6.2)
192
+ minitest (5.7.0)
193
+ multi_json (1.11.0)
194
+ multipart-post (2.0.0)
195
+ net-scp (1.2.1)
196
+ net-ssh (>= 2.6.5)
197
+ net-ssh (2.9.2)
198
+ nokogiri (1.6.6.2)
199
+ mini_portile (~> 0.6.0)
200
+ open_uri_redirections (0.2.1)
201
+ props (1.1.2)
202
+ pry (0.9.12.6)
203
+ coderay (~> 1.0)
204
+ method_source (~> 0.8)
205
+ slop (~> 3.4)
206
+ rake (10.4.2)
207
+ rbvmomi (1.8.2)
208
+ builder
209
+ nokogiri (>= 1.4.1)
210
+ trollop
211
+ retriable (1.4.1)
212
+ rspec (3.3.0)
213
+ rspec-core (~> 3.3.0)
214
+ rspec-expectations (~> 3.3.0)
215
+ rspec-mocks (~> 3.3.0)
216
+ rspec-core (3.3.1)
217
+ rspec-support (~> 3.3.0)
218
+ rspec-expectations (3.3.0)
219
+ diff-lcs (>= 1.2.0, < 2.0)
220
+ rspec-support (~> 3.3.0)
221
+ rspec-mocks (3.3.1)
222
+ diff-lcs (>= 1.2.0, < 2.0)
223
+ rspec-support (~> 3.3.0)
224
+ rspec-support (3.3.0)
225
+ rsync (1.0.9)
226
+ rubyzip (1.1.7)
227
+ signet (0.6.1)
228
+ addressable (~> 2.3)
229
+ extlib (~> 0.9)
230
+ faraday (~> 0.9)
231
+ jwt (~> 1.5)
232
+ multi_json (~> 1.10)
233
+ simplecov (0.10.0)
234
+ docile (~> 1.1.0)
235
+ json (~> 1.8)
236
+ simplecov-html (~> 0.10.0)
237
+ simplecov-html (0.10.0)
238
+ slop (3.6.0)
239
+ textutils (1.3.1)
240
+ activesupport
241
+ logutils (>= 0.6.1)
242
+ props (>= 1.1.2)
243
+ rubyzip
244
+ thread_safe (0.3.5)
245
+ trollop (2.1.2)
246
+ tzinfo (1.2.2)
247
+ thread_safe (~> 0.1)
248
+ unf (0.1.4)
249
+ unf_ext
250
+ unf_ext (0.0.7.1)
251
+ yard (0.8.7.6)
252
+
253
+ PLATFORMS
254
+ ruby
255
+
256
+ DEPENDENCIES
257
+ bundler (~> 1.6)
258
+ markdown (~> 0)
259
+ master_manipulator!
260
+ pry (~> 0.9.12)
261
+ rake
262
+ rspec (>= 3.0.0)
263
+ simplecov
264
+ yard (~> 0)
265
+
266
+ BUNDLED WITH
267
+ 1.10.5
@@ -0,0 +1,98 @@
1
+ # default - History
2
+ ## Tags
3
+ * [LATEST - 1 Jul, 2015 (14ceb0e8)](#LATEST)
4
+ * [1.1.0 - 30 Jun, 2015 (c33bac06)](#1.1.0)
5
+ * [1.0.1 - 17 Jun, 2015 (33c2182d)](#1.0.1)
6
+ * [1.0.0 - 6 May, 2015 (8ae50d90)](#1.0.0)
7
+
8
+ ## Details
9
+ ### <a name = "LATEST">LATEST - 1 Jul, 2015 (14ceb0e8)
10
+
11
+ * (GEM) update master_manipulator version to 1.1.1 (14ceb0e8)
12
+
13
+ * Merge pull request #10 from cowofevil/bug/master/QA-1935/fix_perms_on_site_pp (ebb0e478)
14
+
15
+
16
+ ```
17
+ Merge pull request #10 from cowofevil/bug/master/QA-1935/fix_perms_on_site_pp
18
+
19
+ (QA-1935) Fix "inject_site_pp" Issue
20
+ ```
21
+ * (QA-1935) Fix "inject_site_pp" Issue (338a6d40)
22
+
23
+
24
+ ```
25
+ (QA-1935) Fix "inject_site_pp" Issue
26
+
27
+ The wrong mode was being set on the "site.pp" which made Puppet unable
28
+ to read the file.
29
+ ```
30
+ ### <a name = "1.1.0">1.1.0 - 30 Jun, 2015 (c33bac06)
31
+
32
+ * (HISTORY) update master_manipulator history for gem release 1.1.0 (c33bac06)
33
+
34
+ * (GEM) update master_manipulator version to 1.1.0 (53e5d02b)
35
+
36
+ * Merge pull request #9 from cowofevil/feature/master/QA-1934/get_manifests_path (0f86d431)
37
+
38
+
39
+ ```
40
+ Merge pull request #9 from cowofevil/feature/master/QA-1934/get_manifests_path
41
+
42
+ (QA-1934) Add New Methods
43
+ ```
44
+ * (QA-1934) Add New Methods (27c1d815)
45
+
46
+
47
+ ```
48
+ (QA-1934) Add New Methods
49
+
50
+ Add methods for retrieving the location of environment manifests.
51
+ Update the README to include actual documentation.
52
+ ```
53
+ * Merge pull request #8 from zreichert/improve_restart-puppet-server (f245c951)
54
+
55
+
56
+ ```
57
+ Merge pull request #8 from zreichert/improve_restart-puppet-server
58
+
59
+ Improve restart puppet server
60
+ ```
61
+ * (QA-1930) add option is_pe? (14184e40)
62
+
63
+ * (QA-1930) simplify curl call (5d0b0362)
64
+
65
+ * (QA-1930) update restart_puppet_server timeout default to 60 (f9435b7c)
66
+
67
+ * (QA-1930) improve error msg & new spec test (6eec120d)
68
+
69
+ * (QA-1930) refactor to use case statement (d9d5f428)
70
+
71
+ ### <a name = "1.0.1">1.0.1 - 17 Jun, 2015 (33c2182d)
72
+
73
+ * (HISTORY) update master_manipulator history for gem release 1.0.1 (33c2182d)
74
+
75
+ * (GEM) update master_manipulator version to 1.0.1 (a2140d3d)
76
+
77
+ * Merge pull request #7 from cowofevil/bug/master/QA-1928_fix_bug (51950027)
78
+
79
+
80
+ ```
81
+ Merge pull request #7 from cowofevil/bug/master/QA-1928_fix_bug
82
+
83
+ (QA-1928) Fix Bug
84
+ ```
85
+ * (QA-1928) Fix for the fix (e6c4bb69)
86
+
87
+ * (QA-1928) Fix Bug (d2f56fdd)
88
+
89
+
90
+ ```
91
+ (QA-1928) Fix Bug
92
+
93
+ The "set_perms_on_remote" method fails to set ownership on a file and is
94
+ now fixed!
95
+ ```
96
+ ### <a name = "1.0.0">1.0.0 - 6 May, 2015 (8ae50d90)
97
+
98
+ * Initial release.
@@ -0,0 +1,15 @@
1
+ Copyright (C) 2011-2013 Puppet Labs Inc
2
+
3
+ Puppet Labs can be contacted at: info@puppetlabs.com
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
@@ -0,0 +1,127 @@
1
+ # Master Manipulator
2
+
3
+ This Gem extends the Beaker DSL for the purpose of changing things on a
4
+ Puppet Master.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'master_manipulator'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install master_manipulator
19
+
20
+ ## Methods
21
+
22
+ ### disable_node_classifier
23
+
24
+ Disable the node classifier on a Puppet Enterprise master and use the "site.pp"
25
+ manifest instead for node classification.
26
+
27
+ #### Example
28
+
29
+ disable_node_classifier(master)
30
+
31
+ ### disable_env_cache
32
+
33
+ Disable environment caching on a Puppet Enterprise master to allow for dynamic
34
+ updates to environments without waiting for cache purge.
35
+
36
+ #### Example
37
+
38
+ disable_env_cache(master)
39
+
40
+ ### restart_puppet_server
41
+
42
+ Restart the Puppet Server service to pickup configuration changes made to the
43
+ "puppet.conf" file.
44
+
45
+ #### Example
46
+
47
+ Restart the Puppet Server service on Puppet Enterprise:
48
+
49
+ restart_puppet_server(master)
50
+
51
+ ### get_manifests_path
52
+
53
+ Retrieve the path to the manifests folder for an environment on a master.
54
+
55
+ #### Example 1
56
+
57
+ Retrieve the path to the manifests folder for the "production" environment.
58
+
59
+ prod_env_manifests_path = get_manifests_path(master)
60
+
61
+ #### Example 2
62
+
63
+ Retrieve the path to the manifests folder for the "staging" environment.
64
+
65
+ stage_env_manifests_path = get_manifests_path(master, :env => 'staging')
66
+
67
+ ### get_site_pp_path
68
+
69
+ Retrieve the path to the "site.pp" manifest for an environment on a master.
70
+
71
+ #### Example 1
72
+
73
+ Retrieve the path to the "site.pp" manifest for the "production" environment.
74
+
75
+ prod_env_site_pp_path = get_site_pp_path(master)
76
+
77
+ #### Example 2
78
+
79
+ Retrieve the path to the "site.pp" manifest for the "production" environment.
80
+
81
+ stage_env_site_pp_path = get_site_pp_path(master, :env => 'staging')
82
+
83
+ ### create_site_pp
84
+
85
+ Create a "site.pp" file with file bucket enabled. Also, allow the creation of a
86
+ custom node definition or use the 'default' node definition.
87
+
88
+ #### Example 1
89
+
90
+ Create a "site.pp" manifest with the default node definition using a simple
91
+ manifest.
92
+
93
+ site_pp = create_site_pp(master, :manifest => 'notify { hello: }')
94
+
95
+ #### Example 2
96
+
97
+ Create a "site.pp" manifest with a custom node definition using a simple
98
+ manifest.
99
+
100
+ site_pp = create_site_pp(master, :node_def_name => 'puppet_agent', :manifest => 'notify { hello: }')
101
+
102
+ ### set_perms_on_remote
103
+
104
+ Set permissions and ownership on a remote file.
105
+
106
+ #### Example 1
107
+
108
+ Set permissions on the "site.pp" manifest with default ownership of Pupppet
109
+ user and group.
110
+
111
+ set_perms_on_remote(master, get_site_pp_path(master), '644')
112
+
113
+ #### Example 2
114
+
115
+ Set permissions on the "site.pp" manifest with root ownership.
116
+
117
+ set_perms_on_remote(master, get_site_pp_path(master), '644', :owner => 'root', :group => 'root')
118
+
119
+ ### inject_site_pp
120
+
121
+ Inject a "site.pp" manifest onto a master.
122
+
123
+ #### Example
124
+
125
+ prod_env_site_pp_path = get_site_pp_path(master)
126
+ site_pp = create_site_pp(master, :manifest => 'notify { hello: }')
127
+ inject_site_pp(master, prod_env_site_pp_path, site_pp)
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ task :default => :test
6
+
7
+ desc "Run spec tests"
8
+ RSpec::Core::RakeTask.new(:test) do |t|
9
+ t.rspec_opts = ['--color']
10
+ t.pattern = 'spec/'
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'master_manipulator/version'
2
+ require 'beaker'
3
+
4
+ module Beaker
5
+ class TestCase
6
+ %w( config service site ).each do |lib|
7
+ require "master_manipulator/#{lib}"
8
+ end
9
+ include MasterManipulator::Config
10
+ include MasterManipulator::Service
11
+ include MasterManipulator::Site
12
+ end
13
+ end
@@ -0,0 +1,39 @@
1
+ module MasterManipulator
2
+ module Config
3
+
4
+ # Disable the Node Classifier on the Puppet master.
5
+ # (Note: this requires a restart of Puppet Server to take affect.)
6
+ # ==== Attributes
7
+ #
8
+ # * +master_host+ - The master running Puppet Server.
9
+ #
10
+ # ==== Returns
11
+ #
12
+ # nil
13
+ #
14
+ # ==== Examples
15
+ #
16
+ # site_pp = disable_node_classifier(master_host)
17
+ def disable_node_classifier(master_host)
18
+ on(master_host, puppet('config set node_terminus plain --section master'))
19
+ end
20
+
21
+ # Disable environment caching on the Puppet master.
22
+ # (Note: this requires a restart of Puppet Server to take affect.)
23
+ # ==== Attributes
24
+ #
25
+ # * +master_host+ - The master running Puppet Server.
26
+ #
27
+ # ==== Returns
28
+ #
29
+ # nil
30
+ #
31
+ # ==== Examples
32
+ #
33
+ # site_pp = disable_node_classifier(master_host)
34
+ def disable_env_cache(master_host)
35
+ on(master_host, puppet('config set environment_timeout 0 --section main'))
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,51 @@
1
+ module MasterManipulator
2
+ module Service
3
+
4
+ # Restart the puppet server and wait for it to come back up
5
+ # ==== Attributes
6
+ # *+host+ - the host that this should operate on
7
+ # *+opts+ - an options hash - not required
8
+ # *+:timeout+ - the amount of time in seconds to wait for success
9
+ # *+:frequency+ - The time to wait between retries
10
+ # *+:is_pe?+ - Boolean : if the SUT is PE, defaults to true
11
+ #
12
+ # Raises a standard error if the wait is unsuccessful
13
+ #
14
+ # ==== Example
15
+ # restart_puppet_server(master)
16
+ # restart_puppet_server(master, {:time_out => 200, :frequency => 10})
17
+ def restart_puppet_server(host, opts = {})
18
+
19
+ opts[:is_pe?] ||= true
20
+ opts[:is_pe?] ? service_name = 'pe-puppetserver' : service_name = 'puppetserver'
21
+
22
+ on(host, puppet("resource service #{service_name} ensure=stopped"))
23
+ on(host, puppet("resource service #{service_name} ensure=running"))
24
+ masterHostName = on(host, 'hostname').stdout.chomp
25
+ opts[:time_out] ||= 60
26
+ opts[:frequency] ||= 5
27
+ i = 0
28
+
29
+ # -k to ignore HTTPS error that isn't relevant to us
30
+ curl_call = "-I -k https://#{masterHostName}:8140"
31
+
32
+ while i < opts[:time_out] do
33
+ i += 1
34
+ exit_code = curl_on(host, curl_call, :acceptable_exit_codes => [0,1,7]).exit_code
35
+ case exit_code.to_s
36
+ when '0'
37
+ sleep 20
38
+ return
39
+ when '1' || '7'
40
+ # Exit code 7 is "connection refused"
41
+ sleep opts[:frequency]
42
+ end
43
+ end
44
+
45
+ message = "Attempted to restart #{i} times, waited #{opts[:frequency]} seconds between attempts."
46
+ raise message
47
+
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,146 @@
1
+ module MasterManipulator
2
+ module Site
3
+
4
+ # Get the location of an environment's manifests path. (Defaults to "production" environment.)
5
+ #
6
+ # ==== Attributes
7
+ #
8
+ # * +master_host+ - The master host that contains environments.
9
+ # * +opts:env+ - The environment from which to discover the manifests path.
10
+ #
11
+ # ==== Returns
12
+ #
13
+ # +string+ - An absolute path to the manifests for an environment on the master host.
14
+ #
15
+ # ==== Examples
16
+ #
17
+ # prod_env_manifests_path = get_manifests_path(master)
18
+ def get_manifests_path(master_host, opts = {})
19
+ opts[:env] ||= 'production'
20
+
21
+ environment_base_path = on(master_host, puppet('config print environmentpath')).stdout.rstrip
22
+
23
+ return File.join(environment_base_path, opts[:env], 'manifests')
24
+ end
25
+
26
+ # Get the location of an environment's "site.pp" path. (Defaults to "production" environment.)
27
+ #
28
+ # ==== Attributes
29
+ #
30
+ # * +master_host+ - The master host that contains environments.
31
+ # * +opts:env+ - The environment from which to discover the "site.pp" path.
32
+ #
33
+ # ==== Returns
34
+ #
35
+ # +string+ - An absolute path to the "site.pp" for an environment on the master host.
36
+ #
37
+ # ==== Examples
38
+ #
39
+ # prod_env_site_pp_path = get_site_pp_path(master)
40
+ def get_site_pp_path(master_host, opts = {})
41
+ opts[:env] ||= 'production'
42
+
43
+ return File.join(get_manifests_path(master_host, opts), 'site.pp')
44
+ end
45
+
46
+ # Create a "site.pp" file with file bucket enabled. Also, allow
47
+ # the creation of a custom node definition or use the 'default'
48
+ # node definition.
49
+ #
50
+ # ==== Attributes
51
+ #
52
+ # * +master_host+ - The target master for "site.pp" injection.
53
+ # * +opts:manifest+ - A Puppet manifest to inject into the node definition.
54
+ # * +opts:node_def_name+ - A node definition pattern or name.
55
+ #
56
+ # ==== Returns
57
+ #
58
+ # +string+ - A combined manifest with node definition containing input manifest
59
+ #
60
+ # ==== Examples
61
+ #
62
+ # site_pp = create_site_pp(master, '', node_def_name='agent')
63
+ def create_site_pp(master_host, opts = {})
64
+ opts[:manifest] ||= ''
65
+ opts[:node_def_name] ||= 'default'
66
+ master_certname = on(master_host, puppet('config print certname')).stdout.rstrip
67
+
68
+ default_def = <<-MANIFEST
69
+ node default {
70
+ }
71
+ MANIFEST
72
+
73
+ node_def = <<-MANIFEST
74
+ node #{opts[:node_def_name]} {
75
+
76
+ #{opts[:manifest]}
77
+ }
78
+ MANIFEST
79
+
80
+ if opts[:node_def_name] != 'default'
81
+ node_def = "#{default_def}\n#{node_def}"
82
+ end
83
+
84
+ site_pp = <<-MANIFEST
85
+ filebucket { 'main':
86
+ server => '#{master_certname}',
87
+ path => false,
88
+ }
89
+
90
+ File { backup => 'main' }
91
+
92
+ #{node_def}
93
+ MANIFEST
94
+
95
+ return site_pp
96
+ end
97
+
98
+ # Set mode, owner and group on a remote path.
99
+ #
100
+ # ==== Attributes
101
+ #
102
+ # * +host+ - The remote host containing the target path.
103
+ # * +path+ - The path to set mode, user and group upon.
104
+ # * +mode+ - The desired mode to set on the path in as a string.
105
+ # * +opts:owner+ - The owner to set on the path. (Puppet user if not specified.)
106
+ # * +opts:group+ - The group to set on the path. (Puppet group if not specified.)
107
+ #
108
+ # ==== Returns
109
+ #
110
+ # nil
111
+ #
112
+ # ==== Examples
113
+ #
114
+ # set_perms_on_remote(master, "/tmp/test/site.pp", "777")
115
+ def set_perms_on_remote(host, path, mode, opts = {})
116
+ opts[:owner] ||= on(host, puppet('config print user')).stdout.rstrip
117
+ opts[:group] ||= on(host, puppet('config print group')).stdout.rstrip
118
+
119
+ on(host, "chmod -R #{mode} #{path}")
120
+ on(host, "chown -R #{opts[:owner]}:#{opts[:group]} #{path}")
121
+ end
122
+
123
+ # Inject a "site.pp" manifest onto a master.
124
+ #
125
+ # ==== Attributes
126
+ #
127
+ # * +master_host+ - The target master for injection.
128
+ # * +site_pp_path+ - A path on the remote host into which the site.pp will be injected.
129
+ # * +manifest+ - The manifest content to inject into "site.pp" to the host target path.
130
+ #
131
+ # ==== Returns
132
+ #
133
+ # nil
134
+ #
135
+ # ==== Examples
136
+ #
137
+ # site_pp = inject_site_pp(master_host, "/tmp/test/site.pp", manifest)
138
+ def inject_site_pp(master_host, site_pp_path, manifest)
139
+ site_pp_dir = File.dirname(site_pp_path)
140
+ create_remote_file(master_host, site_pp_path, manifest)
141
+
142
+ set_perms_on_remote(master_host, site_pp_dir, '744')
143
+ end
144
+
145
+ end
146
+ end
@@ -0,0 +1,5 @@
1
+ module MasterManipulator
2
+ module Version
3
+ STRING = '1.1.2'
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require 'simplecov'
2
+ require 'rspec'
3
+
4
+ SimpleCov.start
5
+
6
+ require 'master_manipulator'
7
+
8
+ RSpec.configure do |c|
9
+
10
+ end
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: master_manipulator
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Puppet Labs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.12
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.12
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: markdown
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: beaker
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.7'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 2.7.0
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '2.7'
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 2.7.0
131
+ description: This Gem extends the Beaker DSL for the purpose of changing things on
132
+ a Puppet Master.
133
+ email:
134
+ - qa@puppetlabs.com
135
+ executables: []
136
+ extensions: []
137
+ extra_rdoc_files: []
138
+ files:
139
+ - Gemfile
140
+ - Gemfile.lock
141
+ - HISTORY.md
142
+ - LICENSE.txt
143
+ - README.md
144
+ - Rakefile
145
+ - lib/master_manipulator.rb
146
+ - lib/master_manipulator/config.rb
147
+ - lib/master_manipulator/service.rb
148
+ - lib/master_manipulator/site.rb
149
+ - lib/master_manipulator/version.rb
150
+ - spec/spec_helper.rb
151
+ homepage: https://github.com/puppetlabs/master_manipulator
152
+ licenses:
153
+ - Apache-2.0
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.4.8
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Puppet Labs testing library for controlling a Puppet Master
175
+ test_files:
176
+ - spec/spec_helper.rb
177
+ has_rdoc: