chefdk-julia 0.4.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.
Files changed (66) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +2 -0
  5. data/.travis.yml +29 -0
  6. data/Berksfile +3 -0
  7. data/CHANGELOG.md +18 -0
  8. data/LICENSE +202 -0
  9. data/README.md +62 -0
  10. data/Rakefile +36 -0
  11. data/chefdk-julia.gemspec +41 -0
  12. data/files/default/.rspec +2 -0
  13. data/files/default/.rubocop.yml +2 -0
  14. data/files/default/Berksfile +3 -0
  15. data/files/default/Rakefile +21 -0
  16. data/files/default/chefignore +100 -0
  17. data/files/default/cookbook_readmes/README-policy.md +9 -0
  18. data/files/default/cookbook_readmes/README.md +54 -0
  19. data/files/default/gitignore +19 -0
  20. data/files/default/repo/README.md +28 -0
  21. data/files/default/repo/cookbooks/example/README.md +27 -0
  22. data/files/default/repo/cookbooks/example/attributes/default.rb +7 -0
  23. data/files/default/repo/cookbooks/example/metadata.rb +3 -0
  24. data/files/default/repo/cookbooks/example/recipes/default.rb +8 -0
  25. data/files/default/repo/data_bags/README.md +58 -0
  26. data/files/default/repo/data_bags/example/example_item.json +4 -0
  27. data/files/default/repo/dot-chef-repo.txt +6 -0
  28. data/files/default/repo/environments/README.md +9 -0
  29. data/files/default/repo/environments/example.json +13 -0
  30. data/files/default/repo/policies/README.md +24 -0
  31. data/files/default/repo/roles/README.md +9 -0
  32. data/files/default/repo/roles/example.json +13 -0
  33. data/files/default/serverspec_spec_helper.rb +8 -0
  34. data/lib/chefdk/julia.rb +22 -0
  35. data/lib/chefdk/julia/version.rb +20 -0
  36. data/metadata.rb +24 -0
  37. data/recipes/app.rb +109 -0
  38. data/recipes/attribute.rb +25 -0
  39. data/recipes/cookbook.rb +136 -0
  40. data/recipes/cookbook_file.rb +35 -0
  41. data/recipes/lwrp.rb +36 -0
  42. data/recipes/policyfile.rb +21 -0
  43. data/recipes/recipe.rb +42 -0
  44. data/recipes/repo.rb +81 -0
  45. data/recipes/template.rb +46 -0
  46. data/templates/default/LICENSE.all_rights.erb +3 -0
  47. data/templates/default/LICENSE.apache2.erb +201 -0
  48. data/templates/default/LICENSE.gplv2.erb +339 -0
  49. data/templates/default/LICENSE.gplv3.erb +674 -0
  50. data/templates/default/LICENSE.mit.erb +21 -0
  51. data/templates/default/Policyfile.rb.erb +25 -0
  52. data/templates/default/README.md.erb +4 -0
  53. data/templates/default/attribute.rb.erb +0 -0
  54. data/templates/default/cookbook_file.erb +0 -0
  55. data/templates/default/kitchen.yml.erb +21 -0
  56. data/templates/default/kitchen_policyfile.yml.erb +32 -0
  57. data/templates/default/metadata.rb.erb +7 -0
  58. data/templates/default/provider.rb.erb +0 -0
  59. data/templates/default/recipe.rb.erb +5 -0
  60. data/templates/default/recipe_spec.rb.erb +20 -0
  61. data/templates/default/repo/gitignore.erb +11 -0
  62. data/templates/default/resource.rb.erb +0 -0
  63. data/templates/default/serverspec_default_spec.rb.erb +9 -0
  64. data/templates/default/spec_spec_helper.rb.erb +94 -0
  65. data/templates/default/template.erb +0 -0
  66. metadata +111 -0
@@ -0,0 +1,8 @@
1
+ require 'serverspec'
2
+
3
+ if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
4
+ set :backend, :exec
5
+ else
6
+ set :backend, :cmd
7
+ set :os, family: 'windows'
8
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2015 Nordstrom, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Chefdk
16
+ # namespace for path method
17
+ module Julia
18
+ def self.path
19
+ File.expand_path(File.join(File.dirname(__FILE__), *%w(.. ..)))
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ # Copyright 2015 Nordstrom, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Chefdk
16
+ # namespace for VERSION constant
17
+ module Julia
18
+ VERSION = '0.4.1'
19
+ end
20
+ end
data/metadata.rb ADDED
@@ -0,0 +1,24 @@
1
+ # Copyright 2015 Nordstrom, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'lib/chefdk/julia/version'
16
+
17
+ # ChefDK requires this metadata file to be able to load Julia as a cookbook, even
18
+ # though Julia isn't a traditional cookbook that gets uploaded to Chef Server
19
+ # and run by nodes.
20
+ name 'chefdk-julia'
21
+ description 'An Opinionated Cookbook Creator'
22
+ long_description 'An Opinionated Cookbook Creator, with spunk and a grin, by Nordstrom'
23
+
24
+ version Chefdk::Julia::VERSION
data/recipes/app.rb ADDED
@@ -0,0 +1,109 @@
1
+ # Copyright 2015 Nordstrom, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ context = ChefDK::Generator.context
16
+ app_dir = File.join(context.app_root, context.app_name)
17
+ cookbooks_dir = context.cookbook_root
18
+ cookbook_dir = File.join(cookbooks_dir, context.cookbook_name)
19
+
20
+ # app root dir
21
+ directory app_dir
22
+
23
+ # Top level files
24
+
25
+ # TK
26
+ template "#{app_dir}/.kitchen.yml" do
27
+ source 'kitchen.yml.erb'
28
+ helpers(ChefDK::Generator::TemplateHelper)
29
+ end
30
+
31
+ directory "#{app_dir}/test/integration/default/serverspec" do
32
+ recursive true
33
+ end
34
+
35
+ directory "#{app_dir}/test/integration/helpers/serverspec" do
36
+ recursive true
37
+ end
38
+
39
+ cookbook_file "#{app_dir}/test/integration/helpers/serverspec/spec_helper.rb" do
40
+ source 'serverspec_spec_helper.rb'
41
+ action :create_if_missing
42
+ end
43
+
44
+ template "#{app_dir}/test/integration/default/serverspec/default_spec.rb" do
45
+ source 'serverspec_default_spec.rb.erb'
46
+ helpers(ChefDK::Generator::TemplateHelper)
47
+ action :create_if_missing
48
+ end
49
+
50
+ # README
51
+ template "#{app_dir}/README.md" do
52
+ helpers(ChefDK::Generator::TemplateHelper)
53
+ end
54
+
55
+ # Generated Cookbook:
56
+
57
+ # cookbook collection dir
58
+ directory cookbooks_dir
59
+
60
+ # cookbook collection dir
61
+ directory cookbook_dir
62
+
63
+ # metadata.rb
64
+ template "#{cookbook_dir}/metadata.rb" do
65
+ helpers(ChefDK::Generator::TemplateHelper)
66
+ end
67
+
68
+ # chefignore
69
+ cookbook_file "#{cookbook_dir}/chefignore"
70
+
71
+ # Berks
72
+ cookbook_file "#{cookbook_dir}/Berksfile"
73
+
74
+ # Recipes
75
+
76
+ directory "#{cookbook_dir}/recipes"
77
+
78
+ template "#{cookbook_dir}/recipes/default.rb" do
79
+ source 'recipe.rb.erb'
80
+ helpers(ChefDK::Generator::TemplateHelper)
81
+ end
82
+
83
+ # Chefspec
84
+ directory "#{cookbook_dir}/spec/unit/recipes" do
85
+ recursive true
86
+ end
87
+
88
+ cookbook_file "#{cookbook_dir}/spec/spec_helper.rb" do
89
+ action :create_if_missing
90
+ end
91
+
92
+ template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
93
+ source 'recipe_spec.rb.erb'
94
+ helpers(ChefDK::Generator::TemplateHelper)
95
+ action :create_if_missing
96
+ end
97
+
98
+ # git
99
+ if context.have_git
100
+ unless context.skip_git_init
101
+ execute('initialize-git') do
102
+ command('git init .')
103
+ cwd app_dir
104
+ end
105
+ end
106
+ cookbook_file "#{app_dir}/.gitignore" do
107
+ source 'gitignore'
108
+ end
109
+ end
@@ -0,0 +1,25 @@
1
+ # Copyright 2015 Nordstrom, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ context = ChefDK::Generator.context
16
+ cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
17
+ attribute_dir = File.join(cookbook_dir, 'attributes')
18
+ attribute_path = File.join(cookbook_dir, 'attributes', "#{context.new_file_basename}.rb")
19
+
20
+ directory attribute_dir
21
+
22
+ template attribute_path do
23
+ source 'attribute.rb.erb'
24
+ helpers(ChefDK::Generator::TemplateHelper)
25
+ end
@@ -0,0 +1,136 @@
1
+ # Copyright 2015 Nordstrom, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ context = ChefDK::Generator.context
16
+ cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
17
+
18
+ # cookbook root dir
19
+ directory cookbook_dir
20
+
21
+ # metadata.rb
22
+ template "#{cookbook_dir}/metadata.rb" do
23
+ helpers(ChefDK::Generator::TemplateHelper)
24
+ action :create_if_missing
25
+ end
26
+
27
+ # README
28
+ template "#{cookbook_dir}/README.md" do
29
+ helpers(ChefDK::Generator::TemplateHelper)
30
+ action :create_if_missing
31
+ end
32
+
33
+ # chefignore
34
+ cookbook_file "#{cookbook_dir}/chefignore"
35
+
36
+ if context.use_berkshelf
37
+ cookbook_file "#{cookbook_dir}/Berksfile" do
38
+ action :create_if_missing
39
+ end
40
+ else
41
+ template "#{cookbook_dir}/Policyfile.rb" do
42
+ source 'Policyfile.rb.erb'
43
+ helpers(ChefDK::Generator::TemplateHelper)
44
+ end
45
+ end
46
+
47
+ # Test-kitchen and ServerSpec
48
+ template "#{cookbook_dir}/.kitchen.yml" do
49
+ if context.use_berkshelf
50
+ source 'kitchen.yml.erb'
51
+ else
52
+ source 'kitchen_policyfile.yml.erb'
53
+ end
54
+ helpers(ChefDK::Generator::TemplateHelper)
55
+ action :create_if_missing
56
+ end
57
+
58
+ directory "#{cookbook_dir}/test/integration/default/serverspec" do
59
+ recursive true
60
+ end
61
+
62
+ template "#{cookbook_dir}/test/integration/default/serverspec/default_spec.rb" do
63
+ source 'serverspec_default_spec.rb.erb'
64
+ helpers(ChefDK::Generator::TemplateHelper)
65
+ action :create_if_missing
66
+ end
67
+
68
+ directory "#{cookbook_dir}/test/integration/helpers/serverspec" do
69
+ recursive true
70
+ end
71
+
72
+ cookbook_file "#{cookbook_dir}/test/integration/helpers/serverspec/spec_helper.rb" do
73
+ source 'serverspec_spec_helper.rb'
74
+ action :create_if_missing
75
+ end
76
+
77
+ # ChefSpec
78
+ cookbook_file File.join(cookbook_dir, '.rspec') do
79
+ source '.rspec'
80
+ action :create_if_missing
81
+ end
82
+
83
+ directory "#{cookbook_dir}/spec/unit/recipes" do
84
+ recursive true
85
+ end
86
+
87
+ template File.join(cookbook_dir, 'spec', 'spec_helper.rb') do
88
+ source 'spec_spec_helper.rb.erb'
89
+ backup false
90
+ variables(
91
+ use_berkshelf: context.use_berkshelf
92
+ )
93
+ action :create_if_missing
94
+ end
95
+
96
+ template "#{cookbook_dir}/spec/unit/recipes/default_spec.rb" do
97
+ source 'recipe_spec.rb.erb'
98
+ helpers(ChefDK::Generator::TemplateHelper)
99
+ action :create_if_missing
100
+ end
101
+
102
+ # Rakefile
103
+ cookbook_file File.join(cookbook_dir, 'Rakefile') do
104
+ source 'Rakefile'
105
+ backup false
106
+ action :create_if_missing
107
+ end
108
+
109
+ cookbook_file File.join(cookbook_dir, '.rubocop.yml') do
110
+ source '.rubocop.yml'
111
+ backup false
112
+ action :create_if_missing
113
+ end
114
+
115
+ # Recipes
116
+ directory "#{cookbook_dir}/recipes"
117
+
118
+ template "#{cookbook_dir}/recipes/default.rb" do
119
+ source 'recipe.rb.erb'
120
+ helpers(ChefDK::Generator::TemplateHelper)
121
+ action :create_if_missing
122
+ end
123
+
124
+ # git
125
+ if context.have_git
126
+ unless context.skip_git_init
127
+ execute('initialize-git') do
128
+ command('git init .')
129
+ cwd cookbook_dir
130
+ end
131
+ end
132
+
133
+ cookbook_file "#{cookbook_dir}/.gitignore" do
134
+ source 'gitignore'
135
+ end
136
+ end
@@ -0,0 +1,35 @@
1
+ # Copyright 2015 Nordstrom, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ context = ChefDK::Generator.context
16
+ cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
17
+ files_dir = File.join(cookbook_dir, 'files', 'default')
18
+ cookbook_file_path = File.join(cookbook_dir, 'files', 'default', context.new_file_basename)
19
+
20
+ directory files_dir do
21
+ recursive true
22
+ end
23
+
24
+ source_file = context.content_source
25
+
26
+ if source_file
27
+ file cookbook_file_path do
28
+ content(IO.read(source_file))
29
+ end
30
+ else
31
+ template cookbook_file_path do
32
+ source 'cookbook_file.erb'
33
+ helpers(ChefDK::Generator::TemplateHelper)
34
+ end
35
+ end
data/recipes/lwrp.rb ADDED
@@ -0,0 +1,36 @@
1
+ # Copyright 2015 Nordstrom, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ context = ChefDK::Generator.context
16
+ cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
17
+
18
+ resource_dir = File.join(cookbook_dir, 'resources')
19
+ resource_path = File.join(resource_dir, "#{context.new_file_basename}.rb")
20
+
21
+ provider_dir = File.join(cookbook_dir, 'providers')
22
+ provider_path = File.join(provider_dir, "#{context.new_file_basename}.rb")
23
+
24
+ directory resource_dir
25
+
26
+ template resource_path do
27
+ source 'resource.rb.erb'
28
+ helpers(ChefDK::Generator::TemplateHelper)
29
+ end
30
+
31
+ directory provider_dir
32
+
33
+ template provider_path do
34
+ source 'provider.rb.erb'
35
+ helpers(ChefDK::Generator::TemplateHelper)
36
+ end
@@ -0,0 +1,21 @@
1
+ # Copyright 2015 Nordstrom, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ context = ChefDK::Generator.context
16
+ policyfile_path = File.join(context.policyfile_dir, "#{context.new_file_basename}.rb")
17
+
18
+ template policyfile_path do
19
+ source 'Policyfile.rb.erb'
20
+ helpers(ChefDK::Generator::TemplateHelper)
21
+ end