puppetclassify 0.1.0 → 0.1.1
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 +4 -4
 - data/README.md +32 -3
 - data/lib/puppetclassify/groups.rb +7 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e9e2eb765598c7b32a3580bc52c8d4bd3ab0a29d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 65c93e86f4110fc1d2527d833bc51ecfcf418a81
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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" => "/ 
     | 
| 
       25 
     | 
    
         
            -
              "certificate_path"    => "/ 
     | 
| 
       26 
     | 
    
         
            -
              "private_key_path"    => "/ 
     | 
| 
      
 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 
     | 
    
         
            -
                 
     | 
| 
      
 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. 
     | 
| 
      
 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. 
     | 
| 
      
 52 
     | 
    
         
            +
            rubygems_version: 2.4.8
         
     | 
| 
       53 
53 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       54 
54 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       55 
55 
     | 
    
         
             
            summary: Puppet Classify!
         
     |