puppetclassify 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f483cde63ad46f3c698a9777189eb30294a799a
4
- data.tar.gz: 1bd815ddd7911c47dac2fe888ff8cfda0d27bfae
3
+ metadata.gz: 629f0cea233dad57716d3e00801a3b358ef5da4c
4
+ data.tar.gz: 8d152b9204474c9af61a5efa37f06329b1e5ba66
5
5
  SHA512:
6
- metadata.gz: 1e7754f2bb28972767f75372bbc1ffca2c85143d57b3456fc1a9d8a796f1df0b54b656d6e495b1cf14bdf0231c046c9f5917b1f1941b58a4900ccd55be9950c1
7
- data.tar.gz: 93fbf3cd6a7e65157fe8b79de043d8be8b99b7593d7a52f99b5f5170ebbe7bfff94f39fd66aea02413457c4c1c88b31f53f1abdaf3e8ae636f1bb1133b73a8bc
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetclassify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cain