master_manipulator 1.2.4 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/HISTORY.md +77 -2
- data/README.md +16 -110
- data/Rakefile +0 -1
- data/lib/master_manipulator/config.rb +14 -26
- data/lib/master_manipulator/service.rb +33 -41
- data/lib/master_manipulator/site.rb +61 -85
- data/lib/master_manipulator/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDZjYzhmMTQ2OGU3OTdhYWI3OWI3NzRkOWE0NzliZTZiY2NmNDdlOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjU0MjQ0NTQzMjNhYzM1NzE0MzljN2QwNjI1YTlmMDY2ODAzMWUwNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTZlNDBkZTk3ZjJkYWZkNGQwNTUwYmJmMzYxOTk0ZGM0NjJhNDM1ZThkNjc5
|
10
|
+
YmE0ZDhjY2ZiZGMwYWM3ZGYxYjFiZTYzMWI4OGIxODc3YTc4OGVhMmI1NzNk
|
11
|
+
OTZiNzkyOWUwMmU2YTYzNWZlNWVmNDk1YjZhODMwZTNjNjk2OTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjcxMzIxZDgzYzk1NzJiOTA1MzQyYjhkMTFiNDE5NmRjMjU1ODRhNTcyNzA0
|
14
|
+
NjRmOTQ1YTlhOTcyYWM2MzUwMDkzYjg3NzU1NDI1YWI1MmY2MTgyOGE5YmVk
|
15
|
+
MDRjYTU0OTdhNDk5YTVkZDhiNjYwYjE5NzRiNjcxNmEzZGY3ZDk=
|
data/HISTORY.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# default - History
|
2
2
|
## Tags
|
3
|
-
* [LATEST -
|
3
|
+
* [LATEST - 10 Jan, 2017 (e3ff6153)](#LATEST)
|
4
|
+
* [1.2.4 - 27 Sep, 2016 (48017488)](#1.2.4)
|
4
5
|
* [1.2.3 - 20 Nov, 2015 (f31e884e)](#1.2.3)
|
5
6
|
* [1.2.2 - 30 Oct, 2015 (31450d3c)](#1.2.2)
|
6
7
|
* [1.2.1 - 30 Oct, 2015 (b59fd2cf)](#1.2.1)
|
@@ -12,7 +13,81 @@
|
|
12
13
|
* [1.0.0 - 6 May, 2015 (8ae50d90)](#1.0.0)
|
13
14
|
|
14
15
|
## Details
|
15
|
-
### <a name = "LATEST">LATEST -
|
16
|
+
### <a name = "LATEST">LATEST - 10 Jan, 2017 (e3ff6153)
|
17
|
+
|
18
|
+
* (GEM) update master_manipulator version to 1.2.6 (e3ff6153)
|
19
|
+
|
20
|
+
* Merge pull request #25 from kurtwall/release-gem (838e4850)
|
21
|
+
|
22
|
+
|
23
|
+
```
|
24
|
+
Merge pull request #25 from kurtwall/release-gem
|
25
|
+
|
26
|
+
(GEM) Release 1.2.5 gem
|
27
|
+
```
|
28
|
+
* (GEM) Release 1.2.5 gem (b6a81655)
|
29
|
+
|
30
|
+
* Merge pull request #24 from kurtwall/fix-apiref (cd46a323)
|
31
|
+
|
32
|
+
|
33
|
+
```
|
34
|
+
Merge pull request #24 from kurtwall/fix-apiref
|
35
|
+
|
36
|
+
(QA-2812) API ref missing #pe_version method
|
37
|
+
```
|
38
|
+
* (QA-2812) API ref missing #pe_version method (4f718a04)
|
39
|
+
|
40
|
+
* Merge pull request #23 from kurtwall/release-gem (6f2f8ed9)
|
41
|
+
|
42
|
+
|
43
|
+
```
|
44
|
+
Merge pull request #23 from kurtwall/release-gem
|
45
|
+
|
46
|
+
(maint) Fix YARD markup; modify a couple of variable names
|
47
|
+
```
|
48
|
+
* Update changelog (88fd7460)
|
49
|
+
|
50
|
+
* Fix spec failures (36910dd8)
|
51
|
+
|
52
|
+
* Various cleanups ahead of a 1.2.5 release (fdf54a20)
|
53
|
+
|
54
|
+
* Merge pull request #22 from kurtwall/seed-the-yard (49f6ca54)
|
55
|
+
|
56
|
+
|
57
|
+
```
|
58
|
+
Merge pull request #22 from kurtwall/seed-the-yard
|
59
|
+
|
60
|
+
(QA-2789) Convert API docs to use YARD markup
|
61
|
+
```
|
62
|
+
* Merge https://github.com/puppetlabs/master_manipulator into seed-the-yard (38cb1469)
|
63
|
+
|
64
|
+
* Merge pull request #21 from kurtwall/update-readme (1d75e909)
|
65
|
+
|
66
|
+
|
67
|
+
```
|
68
|
+
Merge pull request #21 from kurtwall/update-readme
|
69
|
+
|
70
|
+
(QA-2789) Revise Master Manipulator docs
|
71
|
+
```
|
72
|
+
* Start the initial conversion to YARD (169b5755)
|
73
|
+
|
74
|
+
* Update README.md (2159ad76)
|
75
|
+
|
76
|
+
* (QA-2789) Revise Master Manipulator docs (fc5cae87)
|
77
|
+
|
78
|
+
* Merge pull request #20 from kurtwall/fix-typo (eff5cdf0)
|
79
|
+
|
80
|
+
|
81
|
+
```
|
82
|
+
Merge pull request #20 from kurtwall/fix-typo
|
83
|
+
|
84
|
+
(MAINT) Fix typo
|
85
|
+
```
|
86
|
+
* (MAINT) Fix typo (d3a63069)
|
87
|
+
|
88
|
+
### <a name = "1.2.4">1.2.4 - 27 Sep, 2016 (48017488)
|
89
|
+
|
90
|
+
* (HISTORY) update master_manipulator history for gem release 1.2.4 (48017488)
|
16
91
|
|
17
92
|
* (GEM) update master_manipulator version to 1.2.4 (036a99e6)
|
18
93
|
|
data/README.md
CHANGED
@@ -1,127 +1,33 @@
|
|
1
1
|
# Master Manipulator
|
2
2
|
|
3
|
-
This
|
4
|
-
Puppet
|
3
|
+
This gem extends the Beaker DSL for the purpose of changing things on a
|
4
|
+
Puppet master
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
8
|
+
### Using a Gemfile
|
9
|
+
|
8
10
|
Add this line to your application's Gemfile:
|
9
11
|
|
12
|
+
```
|
10
13
|
gem 'master_manipulator'
|
14
|
+
```
|
11
15
|
|
12
16
|
And then execute:
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
18
|
+
```
|
19
|
+
bundle install
|
20
|
+
```
|
114
21
|
|
115
|
-
|
22
|
+
or your preferred invocation for installing gems.
|
116
23
|
|
117
|
-
|
24
|
+
### Using Rubygems
|
118
25
|
|
119
|
-
|
26
|
+
To install the gem yourself:
|
120
27
|
|
121
|
-
Inject a "site.pp" manifest onto a master.
|
122
28
|
|
123
|
-
|
29
|
+
```
|
30
|
+
gem install master_manipulator
|
31
|
+
```
|
124
32
|
|
125
|
-
|
126
|
-
site_pp = create_site_pp(master, :manifest => 'notify { hello: }')
|
127
|
-
inject_site_pp(master, prod_env_site_pp_path, site_pp)
|
33
|
+
Refer to [the API document](doc/apiref.md) for API information.
|
data/Rakefile
CHANGED
@@ -1,36 +1,24 @@
|
|
1
1
|
module MasterManipulator
|
2
2
|
module Config
|
3
3
|
|
4
|
-
# Disable the
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# ==== Returns
|
11
|
-
#
|
12
|
-
# nil
|
13
|
-
#
|
14
|
-
# ==== Examples
|
15
|
-
#
|
16
|
-
# site_pp = disable_node_classifier(master_host)
|
4
|
+
# Disable the node classifier on the Puppet master
|
5
|
+
# @param [Beaker::Host] master_host The master running the Puppet server.
|
6
|
+
# @return nil
|
7
|
+
# @example Disable the node classifier on the master
|
8
|
+
# disable_node_classifier(master)
|
9
|
+
# reload_puppetserver(master)
|
17
10
|
def disable_node_classifier(master_host)
|
18
11
|
on(master_host, puppet('config set node_terminus plain --section master'))
|
19
12
|
end
|
20
13
|
|
21
|
-
# Disable environment caching on the Puppet master.
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# nil
|
30
|
-
#
|
31
|
-
# ==== Examples
|
32
|
-
#
|
33
|
-
# site_pp = disable_node_classifier(master_host)
|
14
|
+
# Disable environment caching on the Puppet master. Modifying this
|
15
|
+
# this setting requires reloading (preferred) or restarting (not
|
16
|
+
# preferred) the Puppet server
|
17
|
+
# @param [Beaker::Host] master_host The master running the Puppet server.
|
18
|
+
# @return nil
|
19
|
+
# @example Disable the environment cache on master
|
20
|
+
# disable_env_cache(master)
|
21
|
+
# reload_puppetserver(master)
|
34
22
|
def disable_env_cache(master_host)
|
35
23
|
on(master_host, puppet('config set environment_timeout 0 --section main'))
|
36
24
|
end
|
@@ -3,31 +3,34 @@ require 'json'
|
|
3
3
|
module MasterManipulator
|
4
4
|
module Service
|
5
5
|
|
6
|
-
# Restart the puppet server and wait for it to come back up
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
|
6
|
+
# Restart the puppet server and wait for it to come back up or raise
|
7
|
+
# an error if the wait times out
|
8
|
+
# @param [Beaker::Host] master_host The host to manipulate.
|
9
|
+
# @param [Hash] opts Optional options hash containing options
|
10
|
+
# @option opts [Boolean] :is_pe? true if host is running PE, false otherwise
|
11
|
+
# @option opts [Integer] :wait_cycles How many attempt to make before failing
|
12
|
+
# @return nil
|
13
|
+
# @example Restart the puppetserver process on a PE master
|
14
|
+
# restart_puppet_server(master)
|
15
|
+
# @example Restart the puppetserver process on a FOSS master
|
16
|
+
# restart_puppet_server(master, {:is_pe? => false})
|
17
|
+
# @example Restart the puppetserver process on a PE master, timing out after 20 attempts
|
18
|
+
# restart_puppet_server(master, {:wait_cycles => 20})
|
19
|
+
# @example Restart the puppetserver process on a FOSS master, timing out after 20 attempts
|
20
|
+
# restart_puppet_server(master, {:is_pe? => false, :wait_cycles => 20})
|
21
|
+
def restart_puppet_server(master_host, opts = {})
|
19
22
|
|
20
23
|
start_time = Time.now
|
21
24
|
|
22
25
|
opts[:is_pe?] ||= true
|
23
26
|
opts[:is_pe?] ? service_name = 'pe-puppetserver' : service_name = 'puppetserver'
|
24
27
|
|
25
|
-
on(
|
26
|
-
on(
|
27
|
-
hostname = on(
|
28
|
+
on(master_host, puppet("resource service #{service_name} ensure=stopped"))
|
29
|
+
on(master_host, puppet("resource service #{service_name} ensure=running"))
|
30
|
+
hostname = on(master_host, 'hostname').stdout.chomp
|
28
31
|
opts[:wait_cycles] ||= 10
|
29
32
|
|
30
|
-
pe_ver = pe_version(
|
33
|
+
pe_ver = pe_version(master_host)
|
31
34
|
three_eight_regex = /^3\.8/
|
32
35
|
|
33
36
|
# This logic is not ideal refactor in the future
|
@@ -40,8 +43,7 @@ module MasterManipulator
|
|
40
43
|
end
|
41
44
|
|
42
45
|
(1..opts[:wait_cycles]).each do |i|
|
43
|
-
|
44
|
-
@result = curl_on(host, curl_call, :acceptable_exit_codes => [0,1,7])
|
46
|
+
@result = curl_on(master_host, curl_call, :acceptable_exit_codes => [0,1,7])
|
45
47
|
# parse body if we are using PE and we are not in PE 3.8
|
46
48
|
(pe_ver && !pe_ver.match(three_eight_regex)) ? @body = JSON.parse(@result.stdout) : @body = []
|
47
49
|
|
@@ -50,42 +52,32 @@ module MasterManipulator
|
|
50
52
|
sleep 20
|
51
53
|
pe_ver.match(/three_eight_regex/) ? return : (return if @body.all? { |k, v| v['state'] == 'running' })
|
52
54
|
when '1', '7'
|
53
|
-
# Exit code 7 is
|
55
|
+
# Exit code 7 is 'connection refused'
|
54
56
|
sleep (i**(1.2))
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
60
|
total_time = Time.now - start_time
|
59
|
-
|
60
61
|
message = "Attempted to restart #{opts[:wait_cycles]} times, waited #{total_time} seconds total."
|
61
|
-
|
62
|
-
message << "\nHere is the status reported by the puppetserver'"
|
62
|
+
message << "\nHere is the status reported by the puppetserver"
|
63
63
|
|
64
64
|
@body.each do |k,v|
|
65
65
|
message << "\n'#{k}' state: #{v['state']} "
|
66
66
|
end
|
67
|
-
|
68
67
|
raise message
|
69
68
|
|
70
69
|
end
|
71
70
|
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
#
|
83
|
-
# pe_version
|
84
|
-
def pe_version(host)
|
85
|
-
if on(host, 'test -f /opt/puppet/pe_version', :acceptable_exit_codes => [0,1]).exit_code == 0
|
86
|
-
return on(host, 'cat /opt/puppet/pe_version').stdout.chomp
|
87
|
-
elsif on(host, 'test -f /opt/puppetlabs/server/pe_version', :acceptable_exit_codes => [0,1]).exit_code == 0
|
88
|
-
return on(host, 'cat /opt/puppetlabs/server/pe_version').stdout.chomp
|
71
|
+
# Return the version of PE installed on the specified Puppet master
|
72
|
+
# @param [Beaker::Host] master_host the master to query.
|
73
|
+
# @return [String] The version of Puppet Enterprise, or 'version unknown' if undetermined
|
74
|
+
# @example Return the version of PE running on master
|
75
|
+
# ver = pe_version(master)
|
76
|
+
def pe_version(master_host)
|
77
|
+
if on(master_host, 'test -f /opt/puppet/pe_version', :acceptable_exit_codes => [0,1]).exit_code == 0
|
78
|
+
return on(master_host, 'cat /opt/puppet/pe_version').stdout.chomp
|
79
|
+
elsif on(master_host, 'test -f /opt/puppetlabs/server/pe_version', :acceptable_exit_codes => [0,1]).exit_code == 0
|
80
|
+
return on(master_host, 'cat /opt/puppetlabs/server/pe_version').stdout.chomp
|
89
81
|
else
|
90
82
|
return 'version unknown'
|
91
83
|
end
|
@@ -1,65 +1,51 @@
|
|
1
1
|
module MasterManipulator
|
2
2
|
module Site
|
3
3
|
|
4
|
-
# Get the location of an environment's manifests path
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
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)
|
4
|
+
# Get the location of an environment's manifests path; defaults to production environment.
|
5
|
+
# @param [Beaker::Host] master_host The master host that contains environments.
|
6
|
+
# @param [Hash] opts Optional options hash containing options.
|
7
|
+
# @option opts [String] :env The environment to query on the specified master
|
8
|
+
# @return [String] The absolute path to the manifests for the given environment on the given master
|
9
|
+
# @example Get the manifests path for the production environment on master
|
10
|
+
# prod_env_manifests_path = get_manifests_path(master)
|
11
|
+
# @example Get the manifests path for the testing environment on master
|
12
|
+
# test_env_manifests_path = get_manifests_path(master, {:env => 'test'})
|
18
13
|
def get_manifests_path(master_host, opts = {})
|
19
14
|
opts[:env] ||= 'production'
|
20
|
-
|
21
15
|
environment_base_path = on(master_host, puppet('config print environmentpath')).stdout.rstrip
|
22
16
|
|
23
17
|
return File.join(environment_base_path, opts[:env], 'manifests')
|
24
18
|
end
|
25
19
|
|
26
|
-
# Get the
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
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)
|
20
|
+
# Get the path to a given environment's site.pp; defaults to production environment.
|
21
|
+
# @param [Beaker::Host] master_host The master to query.
|
22
|
+
# @param [Hash] opts Optional options hash containing options.
|
23
|
+
# @option opts [String] :env opts The environment to query on the specified master
|
24
|
+
# @return [String] The absolute path to the site.pp for the given environment on the given master
|
25
|
+
# @example Return the path to the site.pp file for the production environment on master
|
26
|
+
# prod_env_site_pp_path = get_site_pp_path(master)
|
27
|
+
# @example Return the path to the site.pp file for the testing environment on master
|
28
|
+
# prod_env_site_pp_path = get_site_pp_path(master, {:env => 'testing'})
|
40
29
|
def get_site_pp_path(master_host, opts = {})
|
41
30
|
opts[:env] ||= 'production'
|
42
31
|
|
43
32
|
return File.join(get_manifests_path(master_host, opts), 'site.pp')
|
44
33
|
end
|
45
34
|
|
46
|
-
# Create a
|
47
|
-
# the creation of a custom node definition or use the
|
35
|
+
# Create a site.pp file with file bucket enabled. Also, allow
|
36
|
+
# the creation of a custom node definition or use the default
|
48
37
|
# node definition.
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
# ==== Examples
|
61
|
-
#
|
62
|
-
# site_pp = create_site_pp(master, '', node_def_name='agent')
|
38
|
+
# @param [Beaker::Host] master_host the target master for site.pp injection.
|
39
|
+
# @param [Hash] opts Optional options hash containing options.
|
40
|
+
# @option opts [String] :manifest The node definition to lay down
|
41
|
+
# @option opts [String] :node_def_name The node definition name
|
42
|
+
# @return [String] manifest A manifest containing the input node definition to lay down in site.pp
|
43
|
+
# @example Create a site.pp on master using the default node definition and an otherwise empty manifest
|
44
|
+
# site_pp = create_site_pp(master)
|
45
|
+
# @example Create a site.pp on master for a node named 'mailgrunt' with an otherwise empty manifest
|
46
|
+
# site_pp = create_site_pp(master, {:node_def_name => 'mailgrunt'})
|
47
|
+
# @example Create a site.pp on master for a node named 'mailgrunt' with a custom node definition in the manifest
|
48
|
+
# site_pp = create_site_pp(master, {:manifest => manifest_for_mailgrunt, :node_def_name => 'mailgrunt'})
|
63
49
|
def create_site_pp(master_host, opts = {})
|
64
50
|
opts[:manifest] ||= ''
|
65
51
|
opts[:node_def_name] ||= 'default'
|
@@ -72,8 +58,7 @@ MANIFEST
|
|
72
58
|
|
73
59
|
node_def = <<-MANIFEST
|
74
60
|
node #{opts[:node_def_name]} {
|
75
|
-
|
76
|
-
#{opts[:manifest]}
|
61
|
+
#{opts[:manifest]}
|
77
62
|
}
|
78
63
|
MANIFEST
|
79
64
|
|
@@ -96,50 +81,41 @@ MANIFEST
|
|
96
81
|
end
|
97
82
|
|
98
83
|
# Set mode, owner and group on a remote path.
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
|
115
|
-
|
116
|
-
opts[:
|
117
|
-
|
118
|
-
|
119
|
-
on(
|
120
|
-
on(host, "chown -R #{opts[:owner]}:#{opts[:group]} #{path}")
|
84
|
+
# @param [Beaker::Host] master_host The remote host containing the target path.
|
85
|
+
# @param [String] path The pathname on which to set mode, user and group.
|
86
|
+
# @param [String] mode The desired file mode in 4-digit octal string (e.g. '0644').
|
87
|
+
# @param [Hash] opts Optional options hash containing options.
|
88
|
+
# @option opts [String] :owner The user owner to assign
|
89
|
+
# @option opts [String] :group The group owner to assign
|
90
|
+
# @return nil
|
91
|
+
# @example Set perms on a file on master with the default user and group
|
92
|
+
# set_perms_on_remote(master, '/tmp/this_is_junk.pp', '0644')
|
93
|
+
# @example Set perms on a file on master with the default user and a custom group
|
94
|
+
# set_perms_on_remote(master, '/tmp/this_is_junk.pp', '0644', {:group => 'tutones')
|
95
|
+
# @example Set perms on a file on master with a custom user and the default group
|
96
|
+
# set_perms_on_remote(master, '/tmp/this_is_junk.pp', '0644', {:user => 'tommy')
|
97
|
+
# @example Set perms on a file on master with a custom user and a custom group
|
98
|
+
# set_perms_on_remote(master, '/tmp/this_is_junk.pp', '0644', {:user => 'tommy', :group => 'tutones')
|
99
|
+
def set_perms_on_remote(master_host, path, mode, opts = {})
|
100
|
+
opts[:owner] ||= on(master_host, puppet('config print user')).stdout.rstrip
|
101
|
+
opts[:group] ||= on(master_host, puppet('config print group')).stdout.rstrip
|
102
|
+
|
103
|
+
on(master_host, "chmod -Rv #{mode} #{path}")
|
104
|
+
on(master_host, "chown -Rv #{opts[:owner]}:#{opts[:group]} #{path}")
|
121
105
|
end
|
122
106
|
|
123
|
-
# Inject a
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
# ==== Returns
|
132
|
-
#
|
133
|
-
# nil
|
134
|
-
#
|
135
|
-
# ==== Examples
|
136
|
-
#
|
137
|
-
# site_pp = inject_site_pp(master_host, "/tmp/test/site.pp", manifest)
|
107
|
+
# Inject a site.pp manifest onto a master.
|
108
|
+
# @param [Beaker::Host] master_host the target master for injection.
|
109
|
+
# @param [String] site_pp_path a path on the remote host into which the site.pp will be injected.
|
110
|
+
# @param [String] manifest the manifest content to inject into site.pp to the host target path.
|
111
|
+
# @return nil
|
112
|
+
# @example Place this_is_junk.pp, with the contents defined in manifest, in /tmp on the master named compile_master
|
113
|
+
# site_pp = inject_site_pp(compile_master, '/tmp/this_is_junk.pp', manifest)
|
138
114
|
def inject_site_pp(master_host, site_pp_path, manifest)
|
139
115
|
site_pp_dir = File.dirname(site_pp_path)
|
140
116
|
create_remote_file(master_host, site_pp_path, manifest)
|
141
117
|
|
142
|
-
set_perms_on_remote(master_host, site_pp_dir, '
|
118
|
+
set_perms_on_remote(master_host, site_pp_dir, '0744')
|
143
119
|
end
|
144
120
|
|
145
121
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: master_manipulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Puppet
|
7
|
+
- Puppet, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,10 +136,10 @@ dependencies:
|
|
136
136
|
- - ! '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description: This
|
140
|
-
a Puppet
|
139
|
+
description: This gem extends the Beaker DSL for the purpose of changing things on
|
140
|
+
a Puppet master
|
141
141
|
email:
|
142
|
-
- qa@
|
142
|
+
- qa@puppet.com
|
143
143
|
executables: []
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
@@ -178,6 +178,6 @@ rubyforge_project:
|
|
178
178
|
rubygems_version: 2.4.6
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
|
-
summary: Puppet
|
181
|
+
summary: Puppet test library for modifying a Puppet master
|
182
182
|
test_files:
|
183
183
|
- spec/spec_helper.rb
|