puppetclassify 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -0
- data/lib/puppetclassify/groups.rb +22 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 629f0cea233dad57716d3e00801a3b358ef5da4c
|
4
|
+
data.tar.gz: 8d152b9204474c9af61a5efa37f06329b1e5ba66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17e9ce78366de5cf1416610dc5c6049f3985848eb21303a0d6925dc56b91c227f538cec3ac1c81e7eb433da1b966a99078b79ddac809892b0a5cda0e54952a3a
|
7
|
+
data.tar.gz: 97a064d5eed5b8b6c95e5a12246293eb9663ddf0f2575ed812c186c39c553a50aff6b408b173f473c0ffd6aa8f1f0a60c5d2cf56441bd01001b0821bc78647a7
|
data/README.md
CHANGED
@@ -17,6 +17,12 @@ gem build puppetclassify.gemspec
|
|
17
17
|
gem install puppetclassify-0.1.0.gem
|
18
18
|
```
|
19
19
|
|
20
|
+
## Maintenance
|
21
|
+
|
22
|
+
Maintainers: [Brian Cain](https://github.com/briancain) <brian.cain@puppetlabs.com>
|
23
|
+
|
24
|
+
Tickets: Open an issue or pull request directly on this repository
|
25
|
+
|
20
26
|
## How to use
|
21
27
|
|
22
28
|
### Basic case
|
@@ -109,6 +115,34 @@ facts = { 'fact' => Facter.to_hash }
|
|
109
115
|
puppetclassify.classification.get('myhostname.puppetlabs.vm', facts)
|
110
116
|
```
|
111
117
|
|
118
|
+
### Pinning and unpinning nodes to a group in Puppet enterprise
|
119
|
+
|
120
|
+
If you want to "pin" a node to a specific group so it gets that classification, you can
|
121
|
+
invoke the pin_nodes command. And if you want to remove nodes from that group, you can run
|
122
|
+
the unpin_nodes command.
|
123
|
+
|
124
|
+
```
|
125
|
+
require 'puppetclassify'
|
126
|
+
# URL of classifier as well as certificates and private key for auth
|
127
|
+
auth_info = {
|
128
|
+
"ca_certificate_path" => "/etc/puppetlabs/puppet/ssl/certs/ca.pem",
|
129
|
+
"certificate_path" => "/etc/puppetlabs/puppet/ssl/certs/myhostname.vm.pem",
|
130
|
+
"private_key_path" => "/etc/puppetlabs/puppet/ssl/private_keys/myhostname.vm.pem"
|
131
|
+
}
|
132
|
+
|
133
|
+
classifier_url = 'https://puppetmaster.local:4433/classifier-api'
|
134
|
+
puppetclassify = PuppetClassify.new(classifier_url, auth_info)
|
135
|
+
|
136
|
+
my_group_id = puppetclassify.groups.get_group_id("My Super Awesome Group Name")
|
137
|
+
|
138
|
+
nodes = ["hostname.com", "myotherhost.com", "anotherhost.com"]
|
139
|
+
# pin nodes to group
|
140
|
+
puppetclassify.groups.pin_nodes(my_group_id, nodes)
|
141
|
+
|
142
|
+
# unpin nodes from group
|
143
|
+
puppetclassify.groups.unpin_nodes(my_group_id, nodes)
|
144
|
+
```
|
145
|
+
|
112
146
|
## Library Docs
|
113
147
|
|
114
148
|
[rubydoc](http://www.rubydoc.info/gems/puppetclassify/0.1.0)
|
@@ -81,4 +81,26 @@ class Groups
|
|
81
81
|
STDERR.puts group_res.body
|
82
82
|
end
|
83
83
|
end
|
84
|
+
|
85
|
+
def pin_nodes(group_id, node_hash)
|
86
|
+
request_body = {}
|
87
|
+
request_body["nodes"] = node_hash # expects node_hash to be array, i.e. ["foo", "bar", "baz"]
|
88
|
+
group_response = @puppet_https.post("#{@nc_api_url}/v1/groups/#{group_id}/pin", request_body.to_json)
|
89
|
+
|
90
|
+
unless group_response.code.to_i == 204
|
91
|
+
STDERR.puts "An error occured pinning nodes the group: HTTP #{group_response.code} #{group_response.message}"
|
92
|
+
STDERR.puts group_response.body
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def unpin_nodes(group_id, node_hash)
|
97
|
+
request_body = {}
|
98
|
+
request_body["nodes"] = node_hash # expects node_hash to be array, i.e. ["foo", "bar", "baz"]
|
99
|
+
group_response = @puppet_https.post("#{@nc_api_url}/v1/groups/#{group_id}/unpin", request_body.to_json)
|
100
|
+
|
101
|
+
unless group_response.code.to_i == 204
|
102
|
+
STDERR.puts "An error occured unpinning nodes the group: HTTP #{group_response.code} #{group_response.message}"
|
103
|
+
STDERR.puts group_response.body
|
104
|
+
end
|
105
|
+
end
|
84
106
|
end
|