puppetclassify 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3f0656715672e681d21f438e317f3b59e3e936d
4
- data.tar.gz: e5cd2c0623b6d10ec7fc4ca5231277e0aa67a4d3
3
+ metadata.gz: e9e2eb765598c7b32a3580bc52c8d4bd3ab0a29d
4
+ data.tar.gz: 65c93e86f4110fc1d2527d833bc51ecfcf418a81
5
5
  SHA512:
6
- metadata.gz: d17542f290a25be6e75286edb3a247bc5df2be79e425732ad00f2226574e0db1e4928478730ea5813ea677c38772c7ed09be2fbc8e26d88ebf6d1c5368803e05
7
- data.tar.gz: fa560aeab7e6db465bd90c88b36e20850308a67a4899229ba60497ec942140b4dc5616076bfdce58fb1a39dac3ac053a6dab40b30f3f152ce3f17f57d519aeed
6
+ metadata.gz: f07e4e5b91bb7291f0171b68ca15013dde7a63222ca7a9c9015a4e4fa73e92752978e7a68adc64a960c2b415aba4c2b939ceecc5e25ff2ef3dca0a093c51acbe
7
+ data.tar.gz: 14f896ca22003d3074766e65b863da8bfa12e9dcc567497c2d7b3678c0aff7918e8ec836d4ab3a489a121ba127168772cc391d25d7993647b15c1dc67318e8a7
data/README.md CHANGED
@@ -17,13 +17,17 @@ gem install puppetclassify-0.1.0.gem
17
17
 
18
18
  ## How to use
19
19
 
20
+ ### Basic case
21
+
22
+ If you are wanting to get all of the groups the classifier knows about:
23
+
20
24
  ```ruby
21
25
  require 'puppetclassify'
22
26
  # URL of classifier as well as certificates and private key for auth
23
27
  auth_info = {
24
- "ca_certificate_path" => "/opt/puppet/share/puppet-dashboard/certs/ca_cert.pem",
25
- "certificate_path" => "/opt/puppet/share/puppet-dashboard/certs/pe-internal-dashboard.cert.pem",
26
- "private_key_path" => "/opt/puppet/share/puppet-dashboard/certs/pe-internal-dashboard.private_key.pem"
28
+ "ca_certificate_path" => "/etc/puppetlabs/puppet/ssl/certs/ca.pem",
29
+ "certificate_path" => "/etc/puppetlabs/puppet/ssl/certs/myhostname.vm.pem",
30
+ "private_key_path" => "/etc/puppetlabs/puppet/ssl/private_keys/myhostname.vm.pem"
27
31
  }
28
32
 
29
33
  classifier_url = 'https://puppetmaster.local:4433/classifier-api'
@@ -31,3 +35,28 @@ puppetclassify = PuppetClassify.new(classifier_url, auth_info)
31
35
  # Get all the groups
32
36
  puppetclassify.groups.get_groups
33
37
  ```
38
+
39
+ ### Taking action on a specific group by name
40
+
41
+ If you have a group you want to modify, but do not know the group ID:
42
+
43
+ ```ruby
44
+ require 'puppetclassify'
45
+ # URL of classifier as well as certificates and private key for auth
46
+ auth_info = {
47
+ "ca_certificate_path" => "/etc/puppetlabs/puppet/ssl/certs/ca.pem",
48
+ "certificate_path" => "/etc/puppetlabs/puppet/ssl/certs/myhostname.vm.pem",
49
+ "private_key_path" => "/etc/puppetlabs/puppet/ssl/private_keys/myhostname.vm.pem"
50
+ }
51
+
52
+ classifier_url = 'https://puppetmaster.local:4433/classifier-api'
53
+ puppetclassify = PuppetClassify.new(classifier_url, auth_info)
54
+
55
+ my_group_id = puppetclassify.groups.get_group_id("My Group Name")
56
+ group_delta = {"variables"=>{"key"=>"value"}, "id"=>my_group_id, "classes"=>{"motd"=>{"content"=>"hello!"}}} # an example to update a groups variables and classes
57
+ puppetclassify.groups.update_group(group_delta)
58
+ ```
59
+
60
+ ## Library Docs
61
+
62
+ [rubydoc](http://www.rubydoc.info/gems/puppetclassify/0.1.0)
@@ -21,7 +21,13 @@ class Groups
21
21
  def get_group_id(group_name)
22
22
  groups_res = @puppet_https.get("#{@nc_api_url}/v1/groups")
23
23
 
24
- groups = JSON.parse(groups_res.body)
24
+ unless groups_res.code.to_i != 200
25
+ groups = JSON.parse(groups_res.body)
26
+ else
27
+ STDERR.puts "An error occured with your request: HTTP #{groups_res.code} #{groups_res.message}"
28
+ STDERR.puts groups_res.body
29
+ exit 1
30
+ end
25
31
 
26
32
  group_info = groups.find { |group| group['name'] == group_name }
27
33
 
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cain
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  version: '0'
50
50
  requirements: []
51
51
  rubyforge_project:
52
- rubygems_version: 2.2.2
52
+ rubygems_version: 2.4.8
53
53
  signing_key:
54
54
  specification_version: 4
55
55
  summary: Puppet Classify!