from-scratch 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Berksfile.lock +11 -0
  4. data/chefignore +1 -0
  5. data/cookbooks/apt/CHANGELOG.md +248 -0
  6. data/cookbooks/apt/README.md +294 -0
  7. data/cookbooks/apt/attributes/default.rb +51 -0
  8. data/cookbooks/apt/files/default/15update-stamp +1 -0
  9. data/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
  10. data/cookbooks/apt/libraries/helpers.rb +61 -0
  11. data/cookbooks/apt/libraries/matchers.rb +17 -0
  12. data/cookbooks/apt/libraries/network.rb +31 -0
  13. data/cookbooks/apt/metadata.json +1 -0
  14. data/cookbooks/apt/providers/preference.rb +84 -0
  15. data/cookbooks/apt/providers/repository.rb +246 -0
  16. data/cookbooks/apt/recipes/cacher-client.rb +83 -0
  17. data/cookbooks/apt/recipes/cacher-ng.rb +43 -0
  18. data/cookbooks/apt/recipes/default.rb +112 -0
  19. data/cookbooks/apt/recipes/unattended-upgrades.rb +47 -0
  20. data/cookbooks/apt/resources/preference.rb +37 -0
  21. data/cookbooks/apt/resources/repository.rb +60 -0
  22. data/cookbooks/apt/templates/debian-6.0/acng.conf.erb +173 -0
  23. data/cookbooks/apt/templates/default/01proxy.erb +9 -0
  24. data/cookbooks/apt/templates/default/10recommends.erb +3 -0
  25. data/cookbooks/apt/templates/default/20auto-upgrades.erb +2 -0
  26. data/cookbooks/apt/templates/default/50unattended-upgrades.erb +68 -0
  27. data/cookbooks/apt/templates/default/acng.conf.erb +275 -0
  28. data/cookbooks/apt/templates/default/unattended-upgrades.seed.erb +1 -0
  29. data/cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +269 -0
  30. data/cookbooks/build-essential/CHANGELOG.md +136 -0
  31. data/cookbooks/build-essential/README.md +108 -0
  32. data/cookbooks/build-essential/attributes/default.rb +20 -0
  33. data/cookbooks/build-essential/libraries/matchers.rb +5 -0
  34. data/cookbooks/build-essential/libraries/timing.rb +124 -0
  35. data/cookbooks/build-essential/libraries/xcode_command_line_tools.rb +210 -0
  36. data/cookbooks/build-essential/metadata.json +1 -0
  37. data/cookbooks/build-essential/recipes/_debian.rb +28 -0
  38. data/cookbooks/build-essential/recipes/_fedora.rb +32 -0
  39. data/cookbooks/build-essential/recipes/_freebsd.rb +24 -0
  40. data/cookbooks/build-essential/recipes/_mac_os_x.rb +22 -0
  41. data/cookbooks/build-essential/recipes/_omnios.rb +33 -0
  42. data/cookbooks/build-essential/recipes/_rhel.rb +36 -0
  43. data/cookbooks/build-essential/recipes/_smartos.rb +27 -0
  44. data/cookbooks/build-essential/recipes/_solaris2.rb +48 -0
  45. data/cookbooks/build-essential/recipes/_suse.rb +29 -0
  46. data/cookbooks/build-essential/recipes/default.rb +29 -0
  47. data/cookbooks/chef-sugar/CHANGELOG.md +159 -0
  48. data/cookbooks/chef-sugar/README.md +464 -0
  49. data/cookbooks/chef-sugar/metadata.json +1 -0
  50. data/cookbooks/chef-sugar/recipes/default.rb +34 -0
  51. data/cookbooks/openssl/CHANGELOG.md +30 -0
  52. data/cookbooks/openssl/README.md +115 -0
  53. data/cookbooks/openssl/attributes/default.rb +21 -0
  54. data/cookbooks/openssl/libraries/secure_password.rb +37 -0
  55. data/cookbooks/openssl/metadata.json +31 -0
  56. data/cookbooks/openssl/providers/x509.rb +94 -0
  57. data/cookbooks/openssl/recipes/default.rb +18 -0
  58. data/cookbooks/openssl/recipes/upgrade.rb +39 -0
  59. data/cookbooks/openssl/resources/x509.rb +16 -0
  60. data/cookbooks/postgresql/CHANGELOG.md +220 -0
  61. data/cookbooks/postgresql/README.md +464 -0
  62. data/cookbooks/postgresql/attributes/default.rb +549 -0
  63. data/cookbooks/postgresql/files/default/tests/minitest/apt_pgdg_postgresql_test.rb +39 -0
  64. data/cookbooks/postgresql/files/default/tests/minitest/default_test.rb +27 -0
  65. data/cookbooks/postgresql/files/default/tests/minitest/ruby_test.rb +28 -0
  66. data/cookbooks/postgresql/files/default/tests/minitest/server_test.rb +43 -0
  67. data/cookbooks/postgresql/files/default/tests/minitest/support/helpers.rb +29 -0
  68. data/cookbooks/postgresql/libraries/default.rb +377 -0
  69. data/cookbooks/postgresql/metadata.json +56 -0
  70. data/cookbooks/postgresql/recipes/apt_pgdg_postgresql.rb +18 -0
  71. data/cookbooks/postgresql/recipes/client.rb +32 -0
  72. data/cookbooks/postgresql/recipes/config_initdb.rb +148 -0
  73. data/cookbooks/postgresql/recipes/config_pgtune.rb +284 -0
  74. data/cookbooks/postgresql/recipes/contrib.rb +44 -0
  75. data/cookbooks/postgresql/recipes/default.rb +18 -0
  76. data/cookbooks/postgresql/recipes/ruby.rb +117 -0
  77. data/cookbooks/postgresql/recipes/server.rb +89 -0
  78. data/cookbooks/postgresql/recipes/server_conf.rb +34 -0
  79. data/cookbooks/postgresql/recipes/server_debian.rb +38 -0
  80. data/cookbooks/postgresql/recipes/server_redhat.rb +100 -0
  81. data/cookbooks/postgresql/recipes/yum_pgdg_postgresql.rb +45 -0
  82. data/cookbooks/postgresql/templates/default/pg_hba.conf.erb +35 -0
  83. data/cookbooks/postgresql/templates/default/pgsql.sysconfig.erb +4 -0
  84. data/cookbooks/postgresql/templates/default/postgresql.conf.erb +21 -0
  85. data/cookbooks/scratchify/.chef/knife.rb +2 -5
  86. data/cookbooks/scratchify/Berksfile +2 -1
  87. data/cookbooks/scratchify/Berksfile.lock +11 -0
  88. data/cookbooks/scratchify/README.md +34 -17
  89. data/cookbooks/scratchify/bin/scratchify +1 -1
  90. data/cookbooks/scratchify/chefignore +1 -0
  91. data/cookbooks/scratchify/from-scratch.gemspec +2 -5
  92. data/cookbooks/scratchify/lib/from-scratch.rb +25 -0
  93. data/cookbooks/scratchify/lib/{from/scratch → from-scratch}/version.rb +1 -1
  94. data/cookbooks/scratchify/metadata.json +2 -1
  95. data/cookbooks/scratchify/templates/node.json.erb +34 -0
  96. data/cookbooks/scratchify/templates/user.json.erb +6 -0
  97. data/lib/from-scratch.rb +2 -2
  98. data/lib/from-scratch/version.rb +1 -1
  99. data/templates/node.json.erb +6 -3
  100. metadata +85 -10
  101. data/cookbooks/scratchify/bin/console +0 -14
  102. data/cookbooks/scratchify/bin/setup +0 -7
  103. data/cookbooks/scratchify/data_bags/users/deploy.json +0 -6
  104. data/cookbooks/scratchify/environments/.gitkeep +0 -0
  105. data/cookbooks/scratchify/lib/from/scratch.rb +0 -31
  106. data/cookbooks/scratchify/lib/from/scratch/interviewer.rb +0 -35
  107. data/cookbooks/scratchify/nodes/normfood.ru.json +0 -75
  108. data/cookbooks/scratchify/roles/.gitkeep +0 -0
@@ -0,0 +1 @@
1
+ {"name":"chef-sugar","version":"3.1.1","description":"Installs chef-sugar. Please see the chef-sugar Ruby gem for more information.","long_description":"Chef Sugar is a Gem & Chef Recipe that includes series of helpful syntactic\nsugars on top of the Chef core and other resources to make a cleaner, more lean\nrecipe DSL, enforce DRY principles, and make writing Chef recipes an awesome and\nfun experience!\n\nFor the most up-to-date information and documentation, please visit the [Chef\nSugar project page on GitHub](https://github.com/sethvargo/chef-sugar).\n","maintainer":"Seth Vargo","maintainer_email":"sethvargo@gmail.com","license":"Apache 2.0","platforms":{},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}}
@@ -0,0 +1,34 @@
1
+ #
2
+ # Cookbook Name:: chef-sugar
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2013-2015, Seth Vargo <sethvargo@gmail.com>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ gem_version = run_context.cookbook_collection[cookbook_name].metadata.version
21
+
22
+ if Chef::Resource::ChefGem.instance_methods(false).include?(:compile_time)
23
+ chef_gem 'chef-sugar' do
24
+ version gem_version
25
+ compile_time true
26
+ end
27
+ else
28
+ chef_gem 'chef-sugar' do
29
+ version gem_version
30
+ action :nothing
31
+ end.run_action(:install)
32
+ end
33
+
34
+ require 'chef/sugar'
@@ -0,0 +1,30 @@
1
+ openssl Cookbook CHANGELOG
2
+ ==========================
3
+ This file is used to list changes made in each version of the openssl cookbook.
4
+
5
+ v4.0.0 (2014-02-19)
6
+ -------------------
7
+ - Reverting to Opscode module namespace
8
+
9
+ v3.0.2 (2014-12-30)
10
+ -------------------
11
+ - Accidently released 2.0.2 as 3.0.2
12
+
13
+ v2.0.2 (2014-12-30)
14
+ -------------------
15
+ - Call cert.to_pem before recipe DSL
16
+
17
+ v2.0.0 (2014-06-11)
18
+ -------------------
19
+
20
+ - #1 - **[COOK-847](https://tickets.chef.io/browse/COOK-847)** - Add LWRP for generating self signed certs
21
+ - #4 - **[COOK-4715](https://tickets.chef.io/browse/COOK-4715)** - add upgrade recipe and complete test harness
22
+
23
+ v1.1.0
24
+ ------
25
+ ### Improvement
26
+ - **[COOK-3222](https://tickets.chef.io/browse/COOK-3222)** - Allow setting length for `secure_password`
27
+
28
+ v1.0.2
29
+ ------
30
+ - Add name attribute to metadata
@@ -0,0 +1,115 @@
1
+ openssl Cookbook
2
+ ================
3
+
4
+ This cookbook provides a library method to generate secure random passwords in recipes using the Ruby OpenSSL library.
5
+
6
+ It also provides an attribute-driven recipe for upgrading OpenSSL packages.
7
+
8
+ Requirements
9
+ ------------
10
+
11
+ The `secure_password` works on any platform with OpenSSL Ruby bindings installed, which are a requirement for Chef anyway.
12
+
13
+ The upgrade recipe works on the following tested platforms:
14
+
15
+ * Ubuntu 12.04, 14.04
16
+ * Debian 7.4
17
+ * CentOS 6.5
18
+
19
+ It may work on other platforms or versions of the above platforms with or without modification.
20
+
21
+ [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.
22
+
23
+ Attributes
24
+ ----------
25
+
26
+ * `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.
27
+ * `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.
28
+
29
+ Recipes
30
+ -------
31
+
32
+ ### upgrade
33
+
34
+ The 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.
35
+
36
+ Usage
37
+ -----
38
+
39
+ Most often this will be used to generate a secure password for an attribute. In a recipe:
40
+
41
+ ```ruby
42
+ ::Chef::Recipe.send(:include, Chef::OpenSSL::Password)
43
+ node.set_unless[:my_password] = secure_password
44
+ ```
45
+
46
+ To 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:
47
+
48
+ LWRP
49
+ ====
50
+
51
+ This cookbook includes an LWRP for generating Self Signed Certificates
52
+
53
+ ## openssl_x509
54
+ generate a pem formatted x509 cert + key
55
+
56
+ ### Attributes
57
+ `common_name` A String representing the `CN` ssl field
58
+ `org` A String representing the `O` ssl field
59
+ `org_unit` A String representing the `OU` ssl field
60
+ `country` A String representing the `C` ssl field
61
+ `expire` A Fixnum reprenting the number of days from _now_ to expire the cert
62
+ `key_file` Optional A string to the key file to use. If no key is present it will generate and store one.
63
+ `key_pass` A String that is the key's passphrase
64
+ `key_length` A Fixnum reprenting your desired Bit Length _Default: 2048_
65
+ `owner` The owner of the files _Default: "root"_
66
+ `group` The group of the files _Default: "root"_
67
+ `mode` The mode to store the files in _Default: "0400"_
68
+
69
+ ### Example usage
70
+
71
+ openssl_x509 "/tmp/mycert.pem" do
72
+ common_name "www.f00bar.com"
73
+ org "Foo Bar"
74
+ org_unit "Lab"
75
+ country "US"
76
+ end
77
+
78
+
79
+ License and Author
80
+ ==================
81
+
82
+ Author:: Jesse Nelson (<spheromak@gmail.com>)
83
+ Author:: Joshua Timberman (<joshua@chef.io>)
84
+ =======
85
+
86
+
87
+ ```ruby
88
+ node.default['openssl']['restart_services'] = ['stats_collector']
89
+
90
+ # other recipe code here...
91
+ service 'stats_collector' do
92
+ action [:enable, :start]
93
+ end
94
+
95
+ include_recipe 'openssl::upgrade'
96
+ ```
97
+
98
+ This will ensure that openssl is upgraded to the latest version so the `stats_collector` service won't be exploited (hopefully!).
99
+
100
+ ```text
101
+ Copyright:: 2009-2011, Chef Software, Inc
102
+ Copyright:: 2014, Chef Software, Inc <legal@chef.io>
103
+
104
+ Licensed under the Apache License, Version 2.0 (the "License");
105
+ you may not use this file except in compliance with the License.
106
+ You may obtain a copy of the License at
107
+
108
+ http://www.apache.org/licenses/LICENSE-2.0
109
+
110
+ Unless required by applicable law or agreed to in writing, software
111
+ distributed under the License is distributed on an "AS IS" BASIS,
112
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
113
+ See the License for the specific language governing permissions and
114
+ limitations under the License.
115
+ ```
@@ -0,0 +1,21 @@
1
+ #
2
+ # Cookbook Name:: openssl
3
+ # Attributes:: default
4
+ #
5
+ # Copyright 2014, Chef Software, Inc. <legal@chef.io>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ default['openssl']['packages'] = []
21
+ default['openssl']['restart_services'] = []
@@ -0,0 +1,37 @@
1
+ #
2
+ # Cookbook Name:: openssl
3
+ # Library:: secure_password
4
+ # Author:: Joshua Timberman <joshua@chef.io>
5
+ #
6
+ # Copyright 2009, Chef Software, Inc.
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ require 'openssl'
22
+
23
+ module Opscode
24
+ module OpenSSL
25
+ module Password
26
+ def secure_password(length = 20)
27
+ pw = String.new
28
+
29
+ while pw.length < length
30
+ pw << ::OpenSSL::Random.random_bytes(1).gsub(/\W/, '')
31
+ end
32
+
33
+ pw
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,31 @@
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
+ }
@@ -0,0 +1,94 @@
1
+ #
2
+ # x509 self signed cert provider
3
+ #
4
+ # Author:: Jesse Nelson <spheromak@gmail.com>
5
+ #
6
+ require 'openssl'
7
+
8
+ use_inline_resources
9
+
10
+ attr_reader :key_file, :key, :cert, :ef
11
+
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
+
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
25
+
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
32
+ end
33
+
34
+ end
35
+ end
36
+
37
+ protected
38
+
39
+ def key_file
40
+ 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"
44
+ end
45
+ new_resource.key_file
46
+ end
47
+
48
+ def key
49
+ @key ||= if ::File.exists? key_file
50
+ OpenSSL::PKey::RSA.new File.read(key_file), new_resource.key_pass
51
+ else
52
+ OpenSSL::PKey::RSA.new(new_resource.key_length)
53
+ end
54
+ @key
55
+ end
56
+
57
+ def cert
58
+ @cert ||= OpenSSL::X509::Certificate.new
59
+ end
60
+
61
+ def gen_cert
62
+ cert
63
+ cert.subject = cert.issuer = OpenSSL::X509::Name.parse(subject)
64
+ cert.not_before = Time.now
65
+ cert.not_after = Time.now + (new_resource.expire.to_i * 24 * 60 * 60)
66
+ cert.public_key = key.public_key
67
+ cert.serial = 0x0
68
+ cert.version = 2
69
+ end
70
+
71
+ 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
76
+ end
77
+
78
+ def extensions
79
+ [
80
+ ef.create_extension("basicConstraints","CA:TRUE", true),
81
+ ef.create_extension("subjectKeyIdentifier", "hash"),
82
+ ]
83
+ end
84
+
85
+ def create_keys
86
+ gen_cert
87
+ @ef ||= OpenSSL::X509::ExtensionFactory.new
88
+ ef.subject_certificate = cert
89
+ ef.issuer_certificate = cert
90
+ cert.extensions = extensions
91
+ cert.add_extension ef.create_extension("authorityKeyIdentifier",
92
+ "keyid:always,issuer:always")
93
+ cert.sign key, OpenSSL::Digest::SHA1.new
94
+ end
@@ -0,0 +1,18 @@
1
+ #
2
+ # Cookbook Name:: openssl
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2009, Chef Software, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
@@ -0,0 +1,39 @@
1
+ #
2
+ # Cookbook Name:: openssl
3
+ # Recipe:: upgrade
4
+ #
5
+ # Copyright 2014, Chef Software, Inc. <legal@chef.io>
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ include_recipe 'chef-sugar'
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
31
+
32
+ node['openssl']['packages'].each do |ssl_pkg|
33
+ package ssl_pkg do
34
+ action :upgrade
35
+ node['openssl']['restart_services'].each do |ssl_svc|
36
+ notifies :restart, "service[#{ssl_svc}]"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,16 @@
1
+
2
+ actions [ :create ]
3
+ default_action :create
4
+
5
+ attribute :name, :kind_of => String, :name_attribute => true
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
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