OSDN Git Service

refactoring. ssl_cert-0.3.6
authorwhitestar <whitestar@gaea.test>
Tue, 7 Feb 2017 13:45:19 +0000 (22:45 +0900)
committerwhitestar <whitestar@gaea.test>
Tue, 7 Feb 2017 13:45:19 +0000 (22:45 +0900)
cookbooks/ssl_cert/.rubocop.yml
cookbooks/ssl_cert/CHANGELOG.md
cookbooks/ssl_cert/README.md
cookbooks/ssl_cert/libraries/helper.rb
cookbooks/ssl_cert/metadata.rb

index 335ab32..0296db2 100644 (file)
@@ -31,7 +31,7 @@ Style/WordArray:
   
 Style/AccessorMethodName:
   Enabled: false
-Style/MethodLength:
+Metrics/MethodLength:
   Max: 50
-Style/ModuleLength:
-  Max: 200
+Metrics/ModuleLength:
+  Max: 220
index 1546c2f..5da79ba 100644 (file)
@@ -1,6 +1,10 @@
 ssl_cert CHANGELOG
 ==================
 
+0.3.6
+-----
+- refactoring.
+
 0.3.5
 -----
 - bug fix: key access group modification.
index 3bb5689..2286a1e 100644 (file)
@@ -17,6 +17,7 @@ This cookbook deploys CA certificates, SSL server keys and/or certificates from
     - [SSH-CA KRL (0.3.0 or later)](#ssh-ca-krl-030-or-later)
     - [SSL server keys and certificates](#ssl-server-keys-and-certificates)
   - [References of deployed key and certificate file paths (with default attributes)](#references-of-deployed-key-and-certificate-file-paths-with-default-attributes)
+  - [Helper methods](#helper-methods)
 - [License and Authors](#license-and-authors)
 
 ## Requirements
@@ -187,11 +188,29 @@ override_attributes(
 
 ### References of deployed key and certificate file paths (with default attributes)
 
-- `node['ssl_cert']["#{ca}_cert_path"]` - e.g. `node['ssl_cert']['grid_ca_cert_path']`
-- `node['ssl_cert']["#{ca}_pubkey_path"]` - e.g. `node['ssl_cert']['grid_ssh_ca_pubkey_path']`
-- `node['ssl_cert']["#{ca}_krl_path"]` - e.g. `node['ssl_cert']['grid_ssh_ca_krl_path']`
-- `node['ssl_cert']["#{undotted_cn}_key_path"]` - e.g. `node['ssl_cert']['node_example_com_key_path']`
-- `node['ssl_cert']["#{undotted_cn}_cert_path"]` - e.g. `node['ssl_cert']['node_example_com_cert_path']`
+- `node['ssl_cert']["#{ca}_cert_path"]`: e.g. `node['ssl_cert']['grid_ca_cert_path']`
+- `node['ssl_cert']["#{ca}_pubkey_path"]`: e.g. `node['ssl_cert']['grid_ssh_ca_pubkey_path']`
+- `node['ssl_cert']["#{ca}_krl_path"]`: e.g. `node['ssl_cert']['grid_ssh_ca_krl_path']`
+- `node['ssl_cert']["#{undotted_cn}_key_path"]`: e.g. `node['ssl_cert']['node_example_com_key_path']`
+- `node['ssl_cert']["#{undotted_cn}_cert_path"]`: e.g. `node['ssl_cert']['node_example_com_cert_path']`
+
+### Helper methods
+
+- `SSLCert::Helper.ca_cert_path(ca_name)`: return CA certificate file path string.
+- `SSLCert::Helper.ca_pubkey_path(ca_name)`: return CA public key file path string.
+- `SSLCert::Helper.ca_krl_path(ca_name)`: return CA KRL file path string.
+- `SSLCert::Helper.server_key_path(common_name)`: return server private key file path string.
+- `SSLCert::Helper.server_cert_path(common_name)`: return server certificate file path string.
+- `SSLCert::Helper.append_members_to_key_access_group(members_array)`: append members to the key access group (default: `ssl-cert`).
+
+```ruby
+::Chef::Recipe.send(:include, SSLCert::Helper)
+
+append_members_to_key_access_group(['openldap'])
+grid_ca_cert_path = ca_cert_path('grid_ca')
+ldap_key_path = server_key_path('ldap.grid.example.com')
+ldap_cert_path = server_cert_path('ldap.grid.example.com')
+``` 
 
 ## License and Authors
 
index 64d8158..6153a8c 100644 (file)
@@ -61,6 +61,7 @@ module SSLCert
     end
 
     def append_members_to_key_access_group(mems)
+      mems = [mems] if mems.is_a?(String)
       key_group = get_private_key_group
       if key_group == 'root'
         Chef::Log.warn('Skip member adding because the key access group is root.')
@@ -248,12 +249,11 @@ module SSLCert
 
       key_path = server_key_path(cn)
       key_group = get_private_key_group
-      unless key_group == 'root'
-        resources(group: key_group) rescue group key_group do
-          system true
-          action :create
-          append true
-        end
+      resources(group: key_group) rescue group key_group do
+        system true
+        action :create
+        append true
+        not_if { key_group == 'root' }
       end
       key_mode = get_private_key_mode
 
index 958d7de..aff7e51 100644 (file)
@@ -5,7 +5,7 @@ maintainer_email ''
 license          'Apache 2.0'
 description      'Installs/Configures ssl_cert'
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version          '0.3.5'
+version          '0.3.6'
 source_url       'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
 issues_url       'https://osdn.jp/projects/metasearch/ticket'