from-scratch 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +1 -1
  3. data/Berksfile.lock +7 -4
  4. data/cookbooks/openssl/CHANGELOG.md +43 -2
  5. data/cookbooks/openssl/README.md +149 -55
  6. data/cookbooks/openssl/libraries/helpers.rb +60 -0
  7. data/cookbooks/openssl/libraries/matchers.rb +13 -0
  8. data/cookbooks/openssl/libraries/random_password.rb +82 -0
  9. data/cookbooks/openssl/libraries/secure_password.rb +3 -2
  10. data/cookbooks/openssl/metadata.json +1 -31
  11. data/cookbooks/openssl/providers/dhparam.rb +33 -0
  12. data/cookbooks/openssl/providers/rsa_key.rb +39 -0
  13. data/cookbooks/openssl/providers/x509.rb +44 -34
  14. data/cookbooks/openssl/recipes/upgrade.rb +13 -11
  15. data/cookbooks/openssl/resources/dhparam.rb +10 -0
  16. data/cookbooks/openssl/resources/rsa_key.rb +10 -0
  17. data/cookbooks/openssl/resources/x509.rb +11 -11
  18. data/cookbooks/postgresql/.gitignore +18 -0
  19. data/cookbooks/postgresql/.kitchen.yml +175 -0
  20. data/cookbooks/postgresql/.rspec +3 -0
  21. data/cookbooks/postgresql/CHANGELOG.md +1 -1
  22. data/cookbooks/postgresql/CONTRIBUTING.md +6 -0
  23. data/cookbooks/postgresql/Cheffile +6 -0
  24. data/cookbooks/postgresql/Gemfile +12 -0
  25. data/cookbooks/postgresql/LICENSE +201 -0
  26. data/cookbooks/postgresql/Rakefile +22 -0
  27. data/cookbooks/postgresql/TESTING.md +22 -0
  28. data/cookbooks/postgresql/attributes/default.rb +72 -1
  29. data/cookbooks/postgresql/metadata.json +7 -12
  30. data/cookbooks/postgresql/providers/database.rb +73 -0
  31. data/cookbooks/postgresql/providers/user.rb +82 -0
  32. data/cookbooks/postgresql/recipes/setup_databases.rb +36 -0
  33. data/cookbooks/postgresql/recipes/setup_users.rb +17 -0
  34. data/cookbooks/postgresql/resources/database.rb +20 -0
  35. data/cookbooks/postgresql/resources/user.rb +20 -0
  36. data/cookbooks/postgresql/test/unit/debian_server_spec.rb +72 -0
  37. data/cookbooks/postgresql/test/unit/default_spec.rb +37 -0
  38. data/cookbooks/postgresql/test/unit/server_spec.rb +41 -0
  39. data/cookbooks/postgresql/test/unit/spec_helper.rb +20 -0
  40. data/cookbooks/scratchify/Berksfile +1 -1
  41. data/cookbooks/scratchify/Berksfile.lock +5 -4
  42. data/cookbooks/scratchify/lib/from-scratch.rb +1 -0
  43. data/cookbooks/scratchify/lib/from-scratch/version.rb +1 -1
  44. data/cookbooks/scratchify/templates/node.json.erb +17 -0
  45. data/from-scratch.gemspec +2 -2
  46. data/lib/from-scratch.rb +7 -3
  47. data/lib/from-scratch/version.rb +1 -1
  48. data/templates/node.json.erb +33 -0
  49. metadata +33 -7
@@ -18,13 +18,14 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require 'openssl'
21
+ include OpenSSLCookbook::Helpers
22
22
 
23
23
  module Opscode
24
24
  module OpenSSL
25
+ # Generate secure passwords with OpenSSL
25
26
  module Password
26
27
  def secure_password(length = 20)
27
- pw = String.new
28
+ pw = ''
28
29
 
29
30
  while pw.length < length
30
31
  pw << ::OpenSSL::Random.random_bytes(1).gsub(/\W/, '')
@@ -1,31 +1 @@
1
- {
2
- "name": "openssl",
3
- "version": "4.0.0",
4
- "description": "Provides a library with a method for generating secure random passwords.",
5
- "long_description": "openssl Cookbook\n================\n\nThis cookbook provides a library method to generate secure random passwords in recipes using the Ruby OpenSSL library.\n\nIt also provides an attribute-driven recipe for upgrading OpenSSL packages.\n\nRequirements\n------------\n\nThe `secure_password` works on any platform with OpenSSL Ruby bindings installed, which are a requirement for Chef anyway.\n\nThe upgrade recipe works on the following tested platforms:\n\n* Ubuntu 12.04, 14.04\n* Debian 7.4\n* CentOS 6.5\n\nIt may work on other platforms or versions of the above platforms with or without modification.\n\n[Chef Sugar](https://github.com/sethvargo/chef-sugar) was introduced as a dependency to provide helpers that make the default attribute settings (see Attributes) easier to reason about.\n\nAttributes\n----------\n\n* `node['openssl']['packages']` - An array of packages of openssl. The default attributes attempt to be smart about which packages are the default, but this may need to be changed by users of the `openssl::upgrade` recipe.\n* `node['openssl']['restart_services']` - An array of service resources that use the `node['openssl']['packages']`. This is empty by default as Chef has no reliably reasonable way to detect which applications or services are compiled against these packages. *Note* These each need to be \"`service`\" resources specified somewhere in the recipes in the node's run list.\n\nRecipes\n-------\n\n### upgrade\n\nThe upgrade recipe iterates over the list of packages in the `node['openssl']['packages']` attribute and manages them with the `:upgrade` action. Each package will send `:restart` notification to service resources named by the `node['openssl']['restart_services']` attribute.\n\nUsage\n-----\n\nMost often this will be used to generate a secure password for an attribute. In a recipe:\n\n```ruby\n::Chef::Recipe.send(:include, Chef::OpenSSL::Password)\nnode.set_unless[:my_password] = secure_password\n```\n\nTo use the `openssl::upgrade` recipe, set the attributes as mentioned above. For example, we have a \"stats_collector\" service that uses openssl. It has a recipe that looks like this:\n\nLWRP\n==== \n\nThis cookbook includes an LWRP for generating Self Signed Certificates\n\n## openssl_x509\ngenerate a pem formatted x509 cert + key \n\n### Attributes\n`common_name` A String representing the `CN` ssl field\n`org` A String representing the `O` ssl field\n`org_unit` A String representing the `OU` ssl field\n`country` A String representing the `C` ssl field\n`expire` A Fixnum reprenting the number of days from _now_ to expire the cert\n`key_file` Optional A string to the key file to use. If no key is present it will generate and store one. \n`key_pass` A String that is the key's passphrase\n`key_length` A Fixnum reprenting your desired Bit Length _Default: 2048_\n`owner` The owner of the files _Default: \"root\"_\n`group` The group of the files _Default: \"root\"_\n`mode` The mode to store the files in _Default: \"0400\"_\n\n### Example usage\n\n openssl_x509 \"/tmp/mycert.pem\" do\n common_name \"www.f00bar.com\"\n org \"Foo Bar\"\n org_unit \"Lab\"\n country \"US\"\n end\n\n \nLicense and Author\n==================\n\nAuthor:: Jesse Nelson (<spheromak@gmail.com>)\nAuthor:: Joshua Timberman (<joshua@chef.io>)\n=======\n\n\n```ruby\nnode.default['openssl']['restart_services'] = ['stats_collector']\n\n# other recipe code here...\nservice 'stats_collector' do\n action [:enable, :start]\nend\n\ninclude_recipe 'openssl::upgrade'\n```\n\nThis will ensure that openssl is upgraded to the latest version so the `stats_collector` service won't be exploited (hopefully!).\n\n```text\nCopyright:: 2009-2011, Chef Software, Inc\nCopyright:: 2014, Chef Software, Inc <legal@chef.io>\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
6
- "maintainer": "Chef Software, Inc.",
7
- "maintainer_email": "cookbooks@chef.io",
8
- "license": "Apache 2.0",
9
- "platforms": {
10
- },
11
- "dependencies": {
12
- "chef-sugar": ">= 0.0.0"
13
- },
14
- "recommendations": {
15
- },
16
- "suggestions": {
17
- },
18
- "conflicting": {
19
- },
20
- "providing": {
21
- },
22
- "replacing": {
23
- },
24
- "attributes": {
25
- },
26
- "groupings": {
27
- },
28
- "recipes": {
29
- "openssl": "Empty, this cookbook provides a library, see README.md"
30
- }
31
- }
1
+ {"name":"openssl","version":"4.4.0","description":"Provides a library with a method for generating secure random passwords.","long_description":"OpenSSL Cookbook\n================\n[![Build Status](https://travis-ci.org/opscode-cookbooks/openssl.svg?branch=master)](https://travis-ci.org/opscode-cookbooks/openssl)\n\nThis cookbook provides tools for working with the Ruby OpenSSL library. It includes:\n- A library method to generate secure random passwords in recipes, using the Ruby SecureRandom library.\n- An LWRP for generating RSA private keys.\n- An LWRP for generating x509 certificates.\n- An LWRP for generating dhparam.pem files.\n- An attribute-driven recipe for upgrading OpenSSL packages.\n\nRequirements\n------------\n\nThe `random_password` mixin works on any platform with the Ruby SecureRandom module. This module is already included with Chef.\n\nThe `openssl_x509`, `openssl_rsa_key` and `openssl_dhparam` LWRPs work on any platform with the OpenSSL Ruby bindings installed. These bindings are already included with Chef.\n\nThe `upgrade` recipe has been tested on the following platforms:\n\n* Ubuntu 12.04, 14.04\n* Debian 7.4\n* CentOS 6.5\n\nThe recipe may work on other platforms or different versions of the above platforms, but this has not been tested.\n\nDependencies\n------------\n\nThis cookbook depends on the [Chef Sugar](http://supermarket.chef.io/cookbooks/chef-sugar/) cookbook. [Chef Sugar](http://supermarket.chef.io/cookbooks/chef-sugar/) is used to make the default attribute settings easier to reason about. (See [Attributes](#attributes))\n\nAttributes\n----------\n\n* `node['openssl']['packages']` - An array of packages required to use openssl. The default attributes attempt to be smart about which packages are the default, but this may need to be changed by users of the `openssl::upgrade` recipe.\n* `node['openssl']['restart_services']` - An array of service resources that depend on the packages listed in the `node['openssl']['packages']` attribute. This array is empty by default, as Chef has no reasonable way to detect which applications or services are compiled against these packages. *Note* Each service listed in this array should represent a \"`service`\" resource specified in the recipes of the node's run list.\n\nRecipes\n-------\n\n### default\n\nAn empty placeholder recipe. Takes no action.\n\n### upgrade\n\nThe upgrade recipe iterates over the list of packages in the `node['openssl']['packages']` attribute, and manages them with the `:upgrade` action. Each package will send a `:restart` notification to service resources named in the `node['openssl']['restart_services']` attribute.\n\n#### Example Usage\n\nIn this example, assume the node is running the `stats_collector` daemon, which depends on the openssl library. Imagine that a new openssl vulnerability has been disclosed, and the operating system vendor has released an update to openssl to address this vulnerability. In order to protect the node, an administrator crafts this recipe:\n\n```ruby\nnode.default['openssl']['restart_services'] = ['stats_collector']\n\n# other recipe code here...\nservice 'stats_collector' do\n action [:enable, :start]\nend\n\ninclude_recipe 'openssl::upgrade'\n```\n\nWhen executed, this recipe will ensure that openssl is upgraded to the latest version, and that the `stats_collector` service is restarted to pick up the latest security fixes released in the openssl package.\n\nLibraries & LWRPs\n-----------------\n\nThere are two mixins packaged with this cookbook.\n\n### random_password (`OpenSSLCookbook::RandomPassword`)\n\nThe `RandomPassword` mixin can be used to generate secure random passwords in Chef cookbooks, usually for assignment to a variable or an attribute. `random_password` uses Ruby's SecureRandom library and is customizable.\n\n#### Example Usage\n```ruby\nChef::Recipe.send(:include, OpenSSLCookbook::RandomPassword)\nnode.set['my_secure_attribute'] = random_password\nnode.set_unless['my_secure_attribute'] = random_password\nnode.set['my_secure_attribute'] = random_password(length: 50)\nnode.set['my_secure_attribute'] = random_password(length: 50, mode: :base64)\nnode.set['my_secure_attribute'] = random_password(length: 50, mode: :base64, encoding: 'ASCII')\n```\n\nNote that node attributes are widely accessible. Storing unencrypted passwords in node attributes, as in this example, carries risk.\n\n### ~~secure_password (`Opscode::OpenSSL::Password`)~~\n\nThis library should be considered deprecated and will be removed in a future version. Please use `OpenSSLCookbook::RandomPassword` instead. The documentation is kept here for historical reasons.\n\n#### ~~Example Usage~~\n```ruby\n::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)\nnode.set_unless['my_password'] = secure_password\n```\n\n~~Note that node attributes are widely accessible. Storing unencrypted passwords in node attributes, as in this example, carries risk.~~\n\n### openssl_x509\n\nThis LWRP generates self-signed, PEM-formatted x509 certificates. If no existing key is specified, the LWRP will automatically generate a passwordless key with the certificate.\n\n#### Attributes\n| Name | Type | Description |\n| ----- | ---- | ------------ |\n| `common_name` | String (Required) | Value for the `CN` certificate field. |\n| `org` | String (Required) | Value for the `O` certificate field. |\n| `org_unit` | String (Required) | Value for the `OU` certificate field. |\n| `country` | String (Required) | Value for the `C` ssl field. |\n| `expire` | Fixnum (Optional) | Value representing the number of days from _now_ through which the issued certificate cert will remain valid. The certificate will expire after this period. |\n| `key_file` | String (Optional) | The path to a certificate key file on the filesystem. If the `key_file` attribute is specified, the LWRP will attempt to source a key from this location. If no key file is found, the LWRP will generate a new key file at this location. If the `key_file` attribute is not specified, the LWRP will generate a key file in the same directory as the generated certificate, with the same name as the generated certificate.\n| `key_pass` | String (Optional) | The passphrase for an existing key's passphrase \n| `key_length` | Fixnum (Optional) | The desired Bit Length of the generated key. _Default: 2048_ |\n| `owner` | String (optional) | The owner of all files created by the LWRP. _Default: \"root\"_ |\n| `group` | String (optional) | The group of all files created by the LWRP. _Default: \"root\"_ |\n| `mode` | String or Fixnum (Optional) | The permission mode of all files created by the LWRP. _Default: \"0400\"_ |\n\n#### Example Usage\n\nIn this example, an administrator wishes to create a self-signed x509 certificate for use with a web server. In order to create the certificate, the administrator crafts this recipe:\n\n```ruby\nopenssl_x509 '/etc/httpd/ssl/mycert.pem' do\n common_name 'www.f00bar.com'\n org 'Foo Bar'\n org_unit 'Lab'\n country 'US'\nend\n```\n\nWhen executed, this recipe will generate a key certificate at `/etc/httpd/ssl/mycert.key`. It will then use that key to generate a new certificate file at `/etc/httpd/ssl/mycert.pem`.\n\n### openssl_dhparam\n\nThis LWRP generates dhparam.pem files. If a valid dhparam.pem file is found at the specified location, no new file will be created. If a file is found at the specified location but it is not a valid dhparam file, it will be overwritten.\n\n#### Attributes\n| Name | Type | Description |\n| ----- | ---- | ------------ |\n| `key_length` | Fixnum (Optional) | The desired Bit Length of the generated key. _Default: 2048_ |\n| `generator` | Fixnum (Optional) | The desired Diffie-Hellmann generator. Can be _2_ or _5_. |\n| `owner` | String (optional) | The owner of all files created by the LWRP. _Default: \"root\"_ |\n| `group` | String (optional) | The group of all files created by the LWRP. _Default: \"root\"_ |\n| `mode` | String or Fixnum (Optional) | The permission mode of all files created by the LWRP. _Default: \"0644\"_ |\n\n#### Example Usage\n\nIn this example, an administrator wishes to create a dhparam.pem file for use with a web server. In order to create the .pem file, the administrator crafts this recipe:\n\n```ruby\nopenssl_dhparam '/etc/httpd/ssl/dhparam.pem' do\n key_length 2048 \n generator 2\nend\n```\n\nWhen executed, this recipe will generate a dhparam file at `/etc/httpd/ssl/dhparam.pem`.\n\n### openssl_rsa_key\n\nThis LWRP generates rsa key files. If a valid rsa key file can be opened at the specified location, no new file will be created. If the RSA key file cannot be opened, either because it does not exist or because the password to the RSA key file does not match the password in the recipe, it will be overwritten.\n\n#### Attributes\n| Name | Type | Description |\n| ----- | ---- | ------------ |\n| `key_length` | Fixnum (Optional) | The desired Bit Length of the generated key. _Default: 2048_ |\n| `key_pass` | String (Optional) | The desired passphrase for the key. |\n| `owner` | String (optional) | The owner of all files created by the LWRP. _Default: \"root\"_ |\n| `group` | String (optional) | The group of all files created by the LWRP. _Default: \"root\"_ |\n| `mode` | String or Fixnum (Optional) | The permission mode of all files created by the LWRP. _Default: \"0644\"_ |\n\n#### Example Usage\n\nIn this example, an administrator wishes to create a new RSA private key file in order to generate other certificates and public keys. In order to create the key file, the administrator crafts this recipe:\n\n```ruby\nopenssl_rsa_key '/etc/httpd/ssl/server.key' do\n key_length 2048 \nend\n```\n\nWhen executed, this recipe will generate a passwordless RSA key file at `/etc/httpd/ssl/server.key`.\n\n\nLicense and Author\n------------------\n\nAuthor:: Jesse Nelson (<spheromak@gmail.com>) \nAuthor:: Seth Vargo (<sethvargo@gmail.com>) \nAuthor:: Charles Johnson (<charles@chef.io>) \nAuthor:: Joshua Timberman (<joshua@chef.io>)\n\n=======\n\n```text\nCopyright:: 2009-2015, Chef Software, Inc <lega@chef.io>\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{},"dependencies":{"chef-sugar":">= 3.1.1"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{"openssl":"Empty, this cookbook provides a library, see README.md","upgrade":"Upgrade OpenSSL library and restart dependent services"}}
@@ -0,0 +1,33 @@
1
+ #
2
+ # dhparam.pem provider
3
+ #
4
+ # Author:: Charles Johnson <charles@chef.io>
5
+ #
6
+
7
+ include OpenSSLCookbook::Helpers
8
+
9
+ use_inline_resources
10
+
11
+ def whyrun_supported?
12
+ true
13
+ end
14
+
15
+ action :create do
16
+ converge_by("Create a dhparam file #{@new_resource}") do
17
+ unless dhparam_pem_valid?(new_resource.name)
18
+ dhparam_content = gen_dhparam(new_resource.key_length, new_resource.generator).to_pem
19
+
20
+ log "Generating #{new_resource.key_length} bit "\
21
+ "dhparam file at #{new_resource.name}, this may take some time"
22
+
23
+ file new_resource.name do
24
+ action :create
25
+ owner new_resource.owner
26
+ group new_resource.group
27
+ mode new_resource.mode
28
+ sensitive true
29
+ content dhparam_content
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # dhparam.pem provider
3
+ #
4
+ # Author:: Charles Johnson <charles@chef.io>
5
+ #
6
+
7
+ include OpenSSLCookbook::Helpers
8
+
9
+ use_inline_resources
10
+
11
+ def whyrun_supported?
12
+ true
13
+ end
14
+
15
+ action :create do
16
+ converge_by("Create an RSA key #{@new_resource}") do
17
+ unless key_file_valid?(new_resource.name, new_resource.key_pass)
18
+
19
+ log "Generating #{new_resource.key_length} bit "\
20
+ "RSA key file at #{new_resource.name}, this may take some time"
21
+
22
+ if new_resource.key_pass
23
+ unencrypted_rsa_key = gen_rsa_key(new_resource.key_length)
24
+ rsa_key_content = encrypt_rsa_key(unencrypted_rsa_key, new_resource.key_pass)
25
+ else
26
+ rsa_key_content = gen_rsa_key(new_resource.key_length).to_pem
27
+ end
28
+
29
+ file new_resource.name do
30
+ action :create
31
+ owner new_resource.owner
32
+ group new_resource.group
33
+ mode new_resource.mode
34
+ sensitive true
35
+ content rsa_key_content
36
+ end
37
+ end
38
+ end
39
+ end
@@ -3,51 +3,61 @@
3
3
  #
4
4
  # Author:: Jesse Nelson <spheromak@gmail.com>
5
5
  #
6
- require 'openssl'
6
+
7
+ include OpenSSLCookbook::Helpers
7
8
 
8
9
  use_inline_resources
9
10
 
11
+ def whyrun_supported?
12
+ true
13
+ end
14
+
10
15
  attr_reader :key_file, :key, :cert, :ef
11
16
 
12
- action :create do
13
- unless ::File.exists? new_resource.name
14
- create_keys
15
- cert_content = cert.to_pem
16
- key_content = key.to_pem
17
+ action :create do
18
+ converge_by("Create #{@new_resource}") do
19
+ unless ::File.exist? new_resource.name
20
+ create_keys
21
+ cert_content = cert.to_pem
22
+ key_content = key.to_pem
17
23
 
18
- file new_resource.name do
19
- action :create_if_missing
20
- mode new_resource.mode
21
- owner new_resource.owner
22
- group new_resource.group
23
- content cert_content
24
- end
24
+ file new_resource.name do
25
+ action :create_if_missing
26
+ mode new_resource.mode
27
+ owner new_resource.owner
28
+ group new_resource.group
29
+ sensitive true
30
+ content cert_content
31
+ end
25
32
 
26
- file new_resource.key_file do
27
- action :create_if_missing
28
- mode new_resource.mode
29
- owner new_resource.owner
30
- group new_resource.group
31
- content key_content
33
+ file new_resource.key_file do
34
+ action :create_if_missing
35
+ mode new_resource.mode
36
+ owner new_resource.owner
37
+ group new_resource.group
38
+ sensitive true
39
+ content key_content
40
+ end
41
+ new_resource.updated_by_last_action(true)
32
42
  end
33
-
34
43
  end
35
44
  end
36
45
 
37
46
  protected
38
47
 
48
+ # rubocop:disable Metrics/AbcSize, Style/IndentationConsistency
39
49
  def key_file
40
50
  unless new_resource.key_file
41
- path, file= ::File.split(new_resource.name)
42
- filename = ::File.basename(file, ::File.extname(file) )
43
- new_resource.key_file path + "/" + filename + ".key"
51
+ path, file = ::File.split(new_resource.name)
52
+ filename = ::File.basename(file, ::File.extname(file))
53
+ new_resource.key_file path + '/' + filename + '.key'
44
54
  end
45
55
  new_resource.key_file
46
56
  end
47
57
 
48
58
  def key
49
- @key ||= if ::File.exists? key_file
50
- OpenSSL::PKey::RSA.new File.read(key_file), new_resource.key_pass
59
+ @key ||= if key_file_valid?(key_file, new_resource.key_pass)
60
+ OpenSSL::PKey::RSA.new ::File.read(key_file), new_resource.key_pass
51
61
  else
52
62
  OpenSSL::PKey::RSA.new(new_resource.key_length)
53
63
  end
@@ -69,16 +79,16 @@ protected
69
79
  end
70
80
 
71
81
  def subject
72
- @subject ||= "/C=" + new_resource.country +
73
- "/O=" + new_resource.org +
74
- "/OU=" + new_resource.org_unit +
75
- "/CN=" + new_resource.common_name
82
+ @subject ||= '/C=' + new_resource.country +
83
+ '/O=' + new_resource.org +
84
+ '/OU=' + new_resource.org_unit +
85
+ '/CN=' + new_resource.common_name
76
86
  end
77
87
 
78
88
  def extensions
79
89
  [
80
- ef.create_extension("basicConstraints","CA:TRUE", true),
81
- ef.create_extension("subjectKeyIdentifier", "hash"),
90
+ ef.create_extension('basicConstraints', 'CA:TRUE', true),
91
+ ef.create_extension('subjectKeyIdentifier', 'hash')
82
92
  ]
83
93
  end
84
94
 
@@ -88,7 +98,7 @@ protected
88
98
  ef.subject_certificate = cert
89
99
  ef.issuer_certificate = cert
90
100
  cert.extensions = extensions
91
- cert.add_extension ef.create_extension("authorityKeyIdentifier",
92
- "keyid:always,issuer:always")
93
- cert.sign key, OpenSSL::Digest::SHA1.new
101
+ cert.add_extension ef.create_extension('authorityKeyIdentifier',
102
+ 'keyid:always,issuer:always')
103
+ cert.sign key, OpenSSL::Digest::SHA256.new
94
104
  end
@@ -2,7 +2,7 @@
2
2
  # Cookbook Name:: openssl
3
3
  # Recipe:: upgrade
4
4
  #
5
- # Copyright 2014, Chef Software, Inc. <legal@chef.io>
5
+ # Copyright 2015, Chef Software, Inc. <legal@chef.io>
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
8
8
  # you may not use this file except in compliance with the License.
@@ -18,16 +18,18 @@
18
18
  #
19
19
  include_recipe 'chef-sugar'
20
20
 
21
- node.default['openssl']['packages'] = case
22
- when debian_before_or_at_squeeze?, ubuntu_before_or_at_lucid?
23
- %w{libssl0.9.8 openssl}
24
- when debian_after_or_at_wheezy?, ubuntu_after_or_at_precise?
25
- %w{libssl1.0.0 openssl}
26
- when rhel?
27
- %w{openssl}
28
- else
29
- []
30
- end
21
+ # Attributes are set here and not in attributes/default.rb because of the
22
+ # chef-sugar dependency for the methods evaluated in the case statement.
23
+ case
24
+ when debian_before_or_at_squeeze?, ubuntu_before_or_at_lucid?
25
+ node.default['openssl']['packages'] = %w(libssl0.9.8 openssl)
26
+ when debian_after_or_at_wheezy?, ubuntu_after_or_at_precise?
27
+ node.default['openssl']['packages'] = %w(libssl1.0.0 openssl)
28
+ when rhel?
29
+ node.default['openssl']['packages'] = %w(openssl)
30
+ else
31
+ node.default['openssl']['packages'] = []
32
+ end
31
33
 
32
34
  node['openssl']['packages'].each do |ssl_pkg|
33
35
  package ssl_pkg do
@@ -0,0 +1,10 @@
1
+
2
+ actions [:create]
3
+ default_action :create
4
+
5
+ attribute :name, :kind_of => String, :name_attribute => true
6
+ attribute :key_length, :equal_to => [1024, 2048, 4096, 8192], :default => 2048
7
+ attribute :generator, :equal_to => [2, 5], :default => 2
8
+ attribute :owner, :kind_of => String
9
+ attribute :group, :kind_of => String
10
+ attribute :mode, :kind_of => [Integer, String]
@@ -0,0 +1,10 @@
1
+
2
+ actions [:create]
3
+ default_action :create
4
+
5
+ attribute :name, :kind_of => String, :name_attribute => true
6
+ attribute :key_length, :equal_to => [1024, 2048, 4096, 8192], :default => 2048
7
+ attribute :key_pass, :kind_of => String, :default => nil
8
+ attribute :owner, :kind_of => String
9
+ attribute :group, :kind_of => String
10
+ attribute :mode, :kind_of => [Integer, String]
@@ -1,16 +1,16 @@
1
1
 
2
- actions [ :create ]
2
+ actions [:create]
3
3
  default_action :create
4
4
 
5
- attribute :name, :kind_of => String, :name_attribute => true
5
+ attribute :name, :kind_of => String, :name_attribute => true
6
6
  attribute :owner, :kind_of => String
7
- attribute :group, :kind_of => String
8
- attribute :expire, :kind_of => Fixnum
9
- attribute :mode
10
- attribute :org, :kind_of => String, :required => true
11
- attribute :org_unit, :kind_of => String, :required => true
12
- attribute :country, :kind_of => String, :required => true
7
+ attribute :group, :kind_of => String
8
+ attribute :expire, :kind_of => Integer
9
+ attribute :mode, :kind_of => [Integer, String]
10
+ attribute :org, :kind_of => String, :required => true
11
+ attribute :org_unit, :kind_of => String, :required => true
12
+ attribute :country, :kind_of => String, :required => true
13
13
  attribute :common_name, :kind_of => String, :required => true
14
- attribute :key_file, :kind_of => String, :default => nil
15
- attribute :key_pass, :kind_of => String, :default => nil
16
- attribute :key_length, :kind_of => Fixnum, :default => 2048
14
+ attribute :key_file, :kind_of => String, :default => nil
15
+ attribute :key_pass, :kind_of => String, :default => nil
16
+ attribute :key_length, :equal_to => [1024, 2048, 4096, 8192], :default => 2048
@@ -0,0 +1,18 @@
1
+ .vagrant
2
+ Berksfile.lock
3
+ Cheffile.lock
4
+ Gemfile.lock
5
+ *~
6
+ *#
7
+ .#*
8
+ \#*#
9
+ .*.sw[a-z]
10
+ *.un~
11
+ .bundle
12
+ .cache
13
+ .kitchen
14
+ bin
15
+ .kitchen.local.yml
16
+ .kitchen/
17
+ .librarian/
18
+ tmp/
@@ -0,0 +1,175 @@
1
+ ---
2
+ driver_plugin: vagrant
3
+
4
+ platforms:
5
+ - name: ubuntu-14.04
6
+ run_list:
7
+ - recipe[apt]
8
+
9
+ - name: ubuntu-12.04
10
+ run_list:
11
+ - recipe[apt]
12
+
13
+ - name: ubuntu-10.04
14
+ run_list:
15
+ - recipe[apt]
16
+
17
+ - name: debian-7.4
18
+ run_list:
19
+ - recipe[apt]
20
+
21
+ - name: centos-7.0
22
+
23
+ - name: centos-6.4
24
+
25
+ - name: centos-5.10
26
+
27
+ suites:
28
+ - name: default
29
+ run_list:
30
+ - recipe[minitest-handler]
31
+ - recipe[postgresql]
32
+ attributes: {}
33
+
34
+ - name: contrib
35
+ run_list:
36
+ - recipe[postgresql::contrib]
37
+ attributes:
38
+ postgresql:
39
+ password:
40
+ postgres: "iloverandompasswordsbutthiswilldo"
41
+
42
+ - name: apt-pgdg-client
43
+ run_list:
44
+ - recipe[minitest-handler]
45
+ - recipe[postgresql]
46
+ excludes: ["centos-5.10", "centos-6.4", "centos-7.0"]
47
+ attributes:
48
+ postgresql:
49
+ enable_pgdg_apt: true
50
+ version: "9.3"
51
+
52
+ - name: yum-pgdg-client
53
+ run_list:
54
+ - recipe[minitest-handler]
55
+ - recipe[postgresql]
56
+ excludes: ["ubuntu-10.04", "ubuntu-12.04", "ubuntu-14.04", "debian-7.4"]
57
+ attributes:
58
+ postgresql:
59
+ enable_pgdg_yum: true
60
+ version: "9.3"
61
+ client:
62
+ packages: ["postgresql93"]
63
+
64
+ - name: ruby
65
+ run_list:
66
+ - recipe[postgresql::ruby]
67
+ - recipe[minitest-handler]
68
+ attributes: {}
69
+
70
+ - name: server
71
+ run_list:
72
+ - recipe[postgresql::ruby]
73
+ - recipe[minitest-handler]
74
+ - recipe[postgresql::server]
75
+ attributes:
76
+ postgresql:
77
+ password:
78
+ postgres: "iloverandompasswordsbutthiswilldo"
79
+
80
+ - name: apt-pgdg-server
81
+ run_list:
82
+ - recipe[minitest-handler]
83
+ - recipe[postgresql::ruby]
84
+ - recipe[postgresql::server]
85
+ excludes: ["centos-5.10", "centos-6.4", "centos-7.0"]
86
+ attributes:
87
+ postgresql:
88
+ enable_pgdg_apt: true
89
+ version: "9.3"
90
+ password:
91
+ postgres: "iloverandompasswordsbutthiswilldo"
92
+ config:
93
+ ssl_cert_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem"
94
+ ssl_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key"
95
+
96
+ - name: yum-pgdg-server
97
+ run_list:
98
+ - recipe[minitest-handler]
99
+ - recipe[postgresql::ruby]
100
+ - recipe[postgresql::server]
101
+ excludes: ["ubuntu-10.04", "ubuntu-12.04", "ubuntu-14.04", "debian-7.4"]
102
+ attributes:
103
+ postgresql:
104
+ enable_pgdg_yum: true
105
+ version: "9.3"
106
+ server:
107
+ packages: ["postgresql93-server"]
108
+ service_name: "postgresql-9.3"
109
+ password:
110
+ postgres: "iloverandompasswordsbutthiswilldo"
111
+
112
+ - name: apt-pgdg-client-ruby
113
+ run_list:
114
+ - recipe[minitest-handler]
115
+ - recipe[postgresql]
116
+ - recipe[postgresql::ruby]
117
+ excludes: ["centos-5.10", "centos-6.4", "centos-7.0"]
118
+ attributes:
119
+ postgresql:
120
+ enable_pgdg_apt: true
121
+ version: "9.3"
122
+
123
+ - name: yum-pgdg-client-ruby
124
+ run_list:
125
+ - recipe[minitest-handler]
126
+ - recipe[postgresql]
127
+ - recipe[postgresql::ruby]
128
+ excludes: ["ubuntu-10.04", "ubuntu-12.04", "ubuntu-14.04", "debian-7.4"]
129
+ attributes:
130
+ postgresql:
131
+ enable_pgdg_yum: true
132
+ version: "9.3"
133
+ client:
134
+ packages: ["postgresql93", "postgresql93-devel"]
135
+
136
+ - name: apt-pgdg-server-pg_stat_statements
137
+ run_list:
138
+ - recipe[minitest-handler]
139
+ - recipe[postgresql::ruby]
140
+ - recipe[postgresql::contrib]
141
+ excludes: ["centos-5.9", "centos-6.4"]
142
+ attributes:
143
+ postgresql:
144
+ enable_pgdg_apt: true
145
+ version: "9.3"
146
+ password:
147
+ postgres: "iloverandompasswordsbutthiswilldo"
148
+ config:
149
+ shared_preload_libraries: "pg_stat_statements"
150
+ ssl_cert_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem"
151
+ ssl_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key"
152
+ contrib:
153
+ extensions:
154
+ - pg_stat_statements
155
+
156
+ - name: yum-pgdg-server-pg_stat_statements
157
+ run_list:
158
+ - recipe[minitest-handler]
159
+ - recipe[postgresql::ruby]
160
+ - recipe[postgresql::contrib]
161
+ excludes: ["ubuntu-10.04", "ubuntu-12.04", "debian-7.1.0"]
162
+ attributes:
163
+ postgresql:
164
+ enable_pgdg_yum: true
165
+ version: "9.3"
166
+ server:
167
+ packages: ["postgresql93-server"]
168
+ service_name: "postgresql-9.3"
169
+ password:
170
+ postgres: "iloverandompasswordsbutthiswilldo"
171
+ config:
172
+ shared_preload_libraries: "pg_stat_statements"
173
+ contrib:
174
+ extensions:
175
+ - pg_stat_statements