chef 17.2.29-universal-mingw32 → 17.3.48-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -3
  3. data/chef.gemspec +1 -0
  4. data/lib/chef/client.rb +1 -1
  5. data/lib/chef/data_bag.rb +1 -2
  6. data/lib/chef/data_bag_item.rb +1 -2
  7. data/lib/chef/deprecated.rb +10 -4
  8. data/lib/chef/dsl.rb +1 -0
  9. data/lib/chef/dsl/render_helpers.rb +44 -0
  10. data/lib/chef/dsl/secret.rb +64 -0
  11. data/lib/chef/dsl/toml.rb +116 -0
  12. data/lib/chef/dsl/universal.rb +5 -0
  13. data/lib/chef/exceptions.rb +22 -0
  14. data/lib/chef/handler/slow_report.rb +1 -1
  15. data/lib/chef/json_compat.rb +1 -1
  16. data/lib/chef/policy_builder/policyfile.rb +88 -45
  17. data/lib/chef/provider/file.rb +2 -2
  18. data/lib/chef/provider/lwrp_base.rb +1 -1
  19. data/lib/chef/provider/package/habitat.rb +168 -0
  20. data/lib/chef/provider/package/powershell.rb +5 -0
  21. data/lib/chef/providers.rb +1 -0
  22. data/lib/chef/resource/chef_client_config.rb +7 -2
  23. data/lib/chef/resource/chef_client_cron.rb +1 -1
  24. data/lib/chef/resource/chef_client_launchd.rb +1 -1
  25. data/lib/chef/resource/chef_client_scheduled_task.rb +1 -1
  26. data/lib/chef/resource/chef_client_systemd_timer.rb +1 -1
  27. data/lib/chef/resource/chef_client_trusted_certificate.rb +2 -2
  28. data/lib/chef/resource/chef_vault_secret.rb +2 -2
  29. data/lib/chef/resource/dsc_resource.rb +1 -1
  30. data/lib/chef/resource/execute.rb +3 -3
  31. data/lib/chef/resource/gem_package.rb +2 -1
  32. data/lib/chef/resource/habitat/_habitat_shared.rb +28 -0
  33. data/lib/chef/resource/habitat/habitat_package.rb +129 -0
  34. data/lib/chef/resource/habitat/habitat_sup.rb +329 -0
  35. data/lib/chef/resource/habitat/habitat_sup_systemd.rb +67 -0
  36. data/lib/chef/resource/habitat/habitat_sup_windows.rb +90 -0
  37. data/lib/chef/resource/habitat_config.rb +107 -0
  38. data/lib/chef/resource/habitat_install.rb +247 -0
  39. data/lib/chef/resource/habitat_service.rb +451 -0
  40. data/lib/chef/resource/habitat_user_toml.rb +92 -0
  41. data/lib/chef/resource/lwrp_base.rb +1 -1
  42. data/lib/chef/resource/support/HabService.dll.config.erb +19 -0
  43. data/lib/chef/resource/support/client.erb +8 -1
  44. data/lib/chef/resource/support/sup.toml.erb +179 -0
  45. data/lib/chef/resource/windows_defender.rb +163 -0
  46. data/lib/chef/resource/windows_defender_exclusion.rb +125 -0
  47. data/lib/chef/resource/windows_printer.rb +78 -44
  48. data/lib/chef/resource/windows_printer_port.rb +1 -1
  49. data/lib/chef/resource/windows_update_settings.rb +259 -0
  50. data/lib/chef/resources.rb +12 -1
  51. data/lib/chef/secret_fetcher.rb +54 -0
  52. data/lib/chef/secret_fetcher/aws_secrets_manager.rb +53 -0
  53. data/lib/chef/secret_fetcher/azure_key_vault.rb +56 -0
  54. data/lib/chef/secret_fetcher/base.rb +72 -0
  55. data/lib/chef/secret_fetcher/example.rb +46 -0
  56. data/lib/chef/version.rb +1 -1
  57. data/spec/functional/mixin/from_file_spec.rb +1 -1
  58. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  59. data/spec/integration/recipes/resource_action_spec.rb +4 -4
  60. data/spec/support/shared/unit/provider/file.rb +2 -8
  61. data/spec/unit/data_bag_item_spec.rb +2 -2
  62. data/spec/unit/data_bag_spec.rb +1 -1
  63. data/spec/unit/dsl/render_helpers_spec.rb +102 -0
  64. data/spec/unit/dsl/secret_spec.rb +65 -0
  65. data/spec/unit/policy_builder/dynamic_spec.rb +0 -5
  66. data/spec/unit/policy_builder/policyfile_spec.rb +144 -56
  67. data/spec/unit/provider/apt_update_spec.rb +3 -1
  68. data/spec/unit/provider/mount/aix_spec.rb +1 -1
  69. data/spec/unit/provider/package/powershell_spec.rb +74 -12
  70. data/spec/unit/resource/windows_defender_exclusion_spec.rb +62 -0
  71. data/spec/unit/resource/windows_defender_spec.rb +71 -0
  72. data/spec/unit/resource/windows_update_settings_spec.rb +64 -0
  73. data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +63 -0
  74. data/spec/unit/secret_fetcher_spec.rb +82 -0
  75. metadata +51 -7
@@ -157,7 +157,7 @@ class Chef
157
157
  end
158
158
 
159
159
  action :delete do
160
- if ::File.exists?(new_resource.path)
160
+ if ::File.exist?(new_resource.path)
161
161
  converge_by("delete file #{new_resource.path}") do
162
162
  do_backup unless file_class.symlink?(new_resource.path)
163
163
  ::File.delete(new_resource.path)
@@ -393,7 +393,7 @@ class Chef
393
393
  # a nil tempfile is okay, means the resource has no content or no new content
394
394
  return if tempfile.nil?
395
395
  # but a tempfile that has no path or doesn't exist should not happen
396
- if tempfile.path.nil? || !::File.exists?(tempfile.path)
396
+ if tempfile.path.nil? || !::File.exist?(tempfile.path)
397
397
  raise "#{ChefUtils::Dist::Infra::CLIENT} is confused, trying to deploy a file that has no path or does not exist..."
398
398
  end
399
399
 
@@ -45,7 +45,7 @@ class Chef
45
45
  def load_current_resource; end
46
46
 
47
47
  # class methods
48
- class <<self
48
+ class << self
49
49
  include Chef::Mixin::ConvertToClassName
50
50
  include Chef::Mixin::FromFile
51
51
 
@@ -0,0 +1,168 @@
1
+ #
2
+ # Copyright:: Chef Software Inc.
3
+ #
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ require_relative "../../http/simple"
19
+ require_relative "../../json_compat"
20
+ require_relative "../../exceptions"
21
+ require_relative "../package"
22
+ # Bring in needed shared methods
23
+
24
+ class Chef
25
+ class Provider
26
+ class Package
27
+ class Habitat < Chef::Provider::Package
28
+ use_multipackage_api
29
+ use "../../resource/habitat/habitat_shared"
30
+ provides :habitat_package
31
+
32
+ def load_current_resource
33
+ @current_resource = Chef::Resource::HabitatPackage.new(new_resource.name)
34
+ current_resource.package_name(strip_version(new_resource.package_name))
35
+
36
+ @candidate_version = candidate_versions
37
+ current_resource.version(current_versions)
38
+
39
+ current_resource
40
+ end
41
+
42
+ def install_package(names, versions)
43
+ names.zip(versions).map do |n, v|
44
+ opts = ["pkg", "install", "--channel", new_resource.channel, "--url", new_resource.bldr_url]
45
+ opts += ["--auth", new_resource.auth_token] if new_resource.auth_token
46
+ opts += ["#{strip_version(n)}/#{v}", new_resource.options]
47
+ opts += ["--binlink"] if new_resource.binlink
48
+ opts += ["--force"] if new_resource.binlink.eql? :force
49
+ hab(opts)
50
+ end
51
+ end
52
+
53
+ alias_method :upgrade_package, :install_package
54
+
55
+ def remove_package(names, versions)
56
+ # raise 'It is too dangerous to :remove packages with the habitat_package resource right now. This functionality should be deferred to the hab cli.'
57
+ names.zip(versions).map do |n, v|
58
+ opts = %w{pkg uninstall}
59
+ opts += ["--keep-latest", new_resource.keep_latest ] if new_resource.keep_latest
60
+ opts += ["#{strip_version(n).chomp("/")}#{v}", new_resource.options]
61
+ opts += ["--exclude"] if new_resource.exclude
62
+ opts += ["--no-deps"] if new_resource.no_deps
63
+ hab(opts)
64
+ # action :remove
65
+ end
66
+ end
67
+
68
+ alias_method :purge_package, :remove_package
69
+
70
+ private
71
+
72
+ def validate_name!(name)
73
+ raise ArgumentError, "package name must be specified as 'origin/name', use the 'version' property to specify a version" unless name.squeeze("/").count("/") < 2
74
+ end
75
+
76
+ def strip_version(name)
77
+ validate_name!(name)
78
+ n = name.squeeze("/").chomp("/").sub(%r{^\/}, "")
79
+ n = n[0..(n.rindex("/") - 1)] while n.count("/") >= 2
80
+ n
81
+ end
82
+
83
+ def platform_target
84
+ if windows?
85
+ "target=x86_64-windows"
86
+ elsif node["kernel"]["release"].to_i < 3
87
+ "target=x86_64-linux-kernel2"
88
+ else
89
+ ""
90
+ end
91
+ end
92
+
93
+ def depot_package(name, version = nil)
94
+ @depot_package ||= {}
95
+ @depot_package[name] ||=
96
+ begin
97
+ origin, pkg_name = name.split("/")
98
+ name_version = [pkg_name, version].compact.join("/").squeeze("/").chomp("/").sub(%r{^\/}, "")
99
+ url = if new_resource.bldr_url.include?("/v1/")
100
+ "#{new_resource.bldr_url.chomp("/")}/depot/channels/#{origin}/#{new_resource.channel}/pkgs/#{name_version}"
101
+ else
102
+ "#{new_resource.bldr_url.chomp("/")}/v1/depot/channels/#{origin}/#{new_resource.channel}/pkgs/#{name_version}"
103
+ end
104
+ url << "/latest" unless name_version.count("/") >= 2
105
+ url << "?#{platform_target}" unless platform_target.empty?
106
+
107
+ headers = {}
108
+ headers["Authorization"] = "Bearer #{new_resource.auth_token}" if new_resource.auth_token
109
+
110
+ Chef::JSONCompat.parse(http.get(url, headers))
111
+ rescue Net::HTTPServerException
112
+ nil
113
+ end
114
+ end
115
+
116
+ def package_version(name, version = nil)
117
+ p = depot_package(name, version)
118
+ "#{p["ident"]["version"]}/#{p["ident"]["release"]}" unless p.nil?
119
+ end
120
+
121
+ def http
122
+ # FIXME: use SimpleJSON when the depot mime-type is fixed
123
+ @http ||= Chef::HTTP::Simple.new(new_resource.bldr_url.to_s)
124
+ end
125
+
126
+ def candidate_versions
127
+ package_name_array.zip(new_version_array).map do |n, v|
128
+ package_version(n, v)
129
+ end
130
+ end
131
+
132
+ def current_versions
133
+ package_name_array.map do |n|
134
+ installed_version(n)
135
+ end
136
+ end
137
+
138
+ def installed_version(ident)
139
+ hab("pkg", "path", ident).stdout.chomp.split(windows? ? "\\" : "/")[-2..-1].join("/")
140
+ rescue Mixlib::ShellOut::ShellCommandFailed
141
+ nil
142
+ end
143
+
144
+ # This is used by the superclass Chef::Provider::Package
145
+ def version_requirement_satisfied?(current_version, new_version)
146
+ return false if new_version.nil? || current_version.nil?
147
+
148
+ nv_parts = new_version.squeeze("/").split("/")
149
+
150
+ if nv_parts.count < 2
151
+ current_version.squeeze("/").split("/")[0] == new_version.squeeze("/")
152
+ else
153
+ current_version.squeeze("/") == new_resource.version.squeeze("/")
154
+ end
155
+ end
156
+
157
+ # This is used by the superclass Chef::Provider::Package
158
+ def version_compare(v1, v2)
159
+ require "mixlib/versioning" unless defined?(Mixlib::Versioning)
160
+ # Convert the package version (X.Y.Z/DATE) into a version that Mixlib::Versioning understands (X.Y.Z+DATE)
161
+ hab_v1 = Mixlib::Versioning.parse(v1.tr("/", "+"))
162
+ hab_v2 = Mixlib::Versioning.parse(v2.tr("/", "+"))
163
+ hab_v1 <=> hab_v2
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
@@ -124,6 +124,11 @@ class Chef
124
124
  command.push("-RequiredVersion #{version}") if version
125
125
  command.push("-Source #{new_resource.source}") if new_resource.source && cmdlet_name =~ Regexp.union(/Install-Package/, /Find-Package/)
126
126
  command.push("-SkipPublisherCheck") if new_resource.skip_publisher_check && cmdlet_name !~ /Find-Package/
127
+ if new_resource.options && cmdlet_name !~ Regexp.union(/Get-Package/, /Find-Package/)
128
+ new_resource.options.each do |arg|
129
+ command.push(arg) unless command.include?(arg)
130
+ end
131
+ end
127
132
  command.push(").Version")
128
133
  command.join(" ")
129
134
  end
@@ -74,6 +74,7 @@ require_relative "provider/package/cab"
74
74
  require_relative "provider/package/powershell"
75
75
  require_relative "provider/package/msu"
76
76
  require_relative "provider/package/snap"
77
+ require_relative "provider/package/habitat"
77
78
 
78
79
  require_relative "provider/service/arch"
79
80
  require_relative "provider/service/freebsd"
@@ -29,7 +29,7 @@ class Chef
29
29
  examples <<~DOC
30
30
  **Bare minimum #{ChefUtils::Dist::Infra::PRODUCT} client.rb**:
31
31
 
32
- The absolute minimum configuration necessary for a node to communicate with the Infra Server is the URL of the Infra Server. All other configuration options either have values at the server side (Policyfiles, Roles, Environments, etc) or have default values determined at client startup.
32
+ The absolute minimum configuration necessary for a node to communicate with the #{ChefUtils::Dist::Server::PRODUCT} is the URL of the #{ChefUtils::Dist::Server::PRODUCT}. All other configuration options either have values at the server side (Policyfiles, Roles, Environments, etc) or have default values determined at client startup.
33
33
 
34
34
  ```ruby
35
35
  chef_client_config 'Create client.rb' do
@@ -184,6 +184,10 @@ class Chef
184
184
  coerce: proc { |x| x.map { |v| string_to_symbol(v).capitalize } },
185
185
  default: []
186
186
 
187
+ property :policy_persist_run_list, [true, false],
188
+ description: "Override run lists defined in a Policyfile with the `run_list` defined on the #{ChefUtils::Dist::Server::PRODUCT}.",
189
+ introduced: "17.3"
190
+
187
191
  property :minimal_ohai, [true, false],
188
192
  description: "Run a minimal set of Ohai plugins providing data necessary for the execution of #{ChefUtils::Dist::Infra::PRODUCT}'s built-in resources. Setting this to true will skip many large and time consuming data sets such as `cloud` or `packages`. Setting this this to true may break cookbooks that assume all Ohai data will be present."
189
193
 
@@ -277,7 +281,8 @@ class Chef
277
281
  report_handlers: format_handler(new_resource.report_handlers),
278
282
  ssl_verify_mode: new_resource.ssl_verify_mode,
279
283
  start_handlers: format_handler(new_resource.start_handlers),
280
- additional_config: new_resource.additional_config
284
+ additional_config: new_resource.additional_config,
285
+ policy_persist_run_list: new_resource.policy_persist_run_list
281
286
  )
282
287
  mode "0640"
283
288
  action :create
@@ -106,7 +106,7 @@ class Chef
106
106
  description: "The e-mail address to e-mail any cron task failures to."
107
107
 
108
108
  property :accept_chef_license, [true, false],
109
- description: "Accept the Chef Online Master License and Services Agreement. See <https://www.chef.io/online-master-agreement/>",
109
+ description: "Accept the Chef Online Master License and Services Agreement. See <https://www.chef.io/online-master-agreement>",
110
110
  default: false
111
111
 
112
112
  property :config_directory, String,
@@ -65,7 +65,7 @@ class Chef
65
65
  description: "A random number of seconds between 0 and X to add to interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time."
66
66
 
67
67
  property :accept_chef_license, [true, false],
68
- description: "Accept the Chef Online Master License and Services Agreement. See <https://www.chef.io/online-master-agreement/>",
68
+ description: "Accept the Chef Online Master License and Services Agreement. See <https://www.chef.io/online-master-agreement>",
69
69
  default: false
70
70
 
71
71
  property :config_directory, String,
@@ -87,7 +87,7 @@ class Chef
87
87
  default_description: "30 if frequency is 'minute', 1 otherwise"
88
88
 
89
89
  property :accept_chef_license, [true, false],
90
- description: "Accept the Chef Online Master License and Services Agreement. See <https://www.chef.io/online-master-agreement/>",
90
+ description: "Accept the Chef Online Master License and Services Agreement. See <https://www.chef.io/online-master-agreement>",
91
91
  default: false
92
92
 
93
93
  property :start_date, String,
@@ -75,7 +75,7 @@ class Chef
75
75
  default: "5min"
76
76
 
77
77
  property :accept_chef_license, [true, false],
78
- description: "Accept the Chef Online Master License and Services Agreement. See <https://www.chef.io/online-master-agreement/>",
78
+ description: "Accept the Chef Online Master License and Services Agreement. See <https://www.chef.io/online-master-agreement>",
79
79
  default: false
80
80
 
81
81
  property :run_on_battery, [true, false],
@@ -64,7 +64,7 @@ class Chef
64
64
  property :certificate, String, required: [:add],
65
65
  description: "The text of the certificate file including the BEGIN/END comment lines."
66
66
 
67
- action :add do
67
+ action :add, description: "Add a trusted certificate to #{ChefUtils::Dist::Infra::PRODUCT}'s trusted certificate directory" do
68
68
  unless ::Dir.exist?(Chef::Config[:trusted_certs_dir])
69
69
  directory Chef::Config[:trusted_certs_dir] do
70
70
  mode "0640"
@@ -78,7 +78,7 @@ class Chef
78
78
  end
79
79
  end
80
80
 
81
- action :remove do
81
+ action :remove, description: "Remove a trusted certificate from #{ChefUtils::Dist::Infra::PRODUCT}'s trusted certificate directory" do
82
82
  file cert_path do
83
83
  action :delete
84
84
  end
@@ -33,7 +33,7 @@ class Chef
33
33
  ```ruby
34
34
  chef_vault_secret 'foo' do
35
35
  data_bag 'bar'
36
- raw_data({'auth' => 'baz'})
36
+ raw_data({ 'auth' => 'baz' })
37
37
  admins 'jtimberman'
38
38
  search '*:*'
39
39
  end
@@ -45,7 +45,7 @@ class Chef
45
45
  chef_vault_secret 'root-password' do
46
46
  admins 'jtimberman,paulmooring'
47
47
  data_bag 'secrets'
48
- raw_data({'auth' => 'DoNotUseThisPasswordForRoot'})
48
+ raw_data({ 'auth' => 'DoNotUseThisPasswordForRoot' })
49
49
  search '*:*'
50
50
  end
51
51
  ```
@@ -74,7 +74,7 @@ class Chef
74
74
 
75
75
  property :module_version, String,
76
76
  introduced: "12.21",
77
- description: "The version number of the module to use. PowerShell 5.0.10018.0 (or higher) supports having multiple versions of a module installed. This should be specified along with the module_name."
77
+ description: "The version number of the module to use. PowerShell 5.0.10018.0 (or higher) supports having multiple versions of a module installed. This should be specified along with the `module_name` property."
78
78
 
79
79
  def property(property_name, value = nil)
80
80
  unless property_name.is_a?(Symbol)
@@ -304,9 +304,9 @@ class Chef
304
304
  gives a recipe full control over the command issued in a much cleaner, more
305
305
  direct manner.
306
306
 
307
- **Use the search recipe DSL method to find users**:
307
+ **Use the search Infra Language helper to find users**:
308
308
 
309
- The following example shows how to use the `search` method in the Recipe DSL to
309
+ The following example shows how to use the `search` method in the Chef Infra Language to
310
310
  search for users:
311
311
 
312
312
  ```ruby
@@ -515,7 +515,7 @@ class Chef
515
515
 
516
516
  property :command, [ String, Array ],
517
517
  name_property: true,
518
- description: "An optional property to set the command to be executed if it differs from the resource block's name."
518
+ description: "An optional property to set the command to be executed if it differs from the resource block's name. Note: Use the **execute** resource to run a single command. Use multiple **execute** resource blocks to run multiple commands."
519
519
 
520
520
  property :umask, [ String, Integer ],
521
521
  description: "The file mode creation mask, or umask."
@@ -83,7 +83,8 @@ class Chef
83
83
 
84
84
  property :clear_sources, [ TrueClass, FalseClass, nil ],
85
85
  description: "Set to `true` to download a gem from the path specified by the `source` property (and not from RubyGems).",
86
- default: lazy { Chef::Config[:clear_gem_sources] }, desired_state: false
86
+ default: lazy { Chef::Config[:clear_gem_sources] },
87
+ default_description: "false unless `clear_gem_sources` set to true in the `client.rb` config.", desired_state: false
87
88
 
88
89
  property :gem_binary, String, desired_state: false,
89
90
  description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by #{ChefUtils::Dist::Infra::PRODUCT} will be used."
@@ -0,0 +1,28 @@
1
+ #
2
+ # Copyright:: Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # li
16
+
17
+ def hab(*command)
18
+ # Windows shell_out does not support arrays, so manually cleaning and joining
19
+ hab_cmd = if windows?
20
+ (["hab"] + command).flatten.compact.join(" ")
21
+ else
22
+ (["hab"] + command)
23
+ end
24
+ shell_out!(hab_cmd)
25
+ rescue Errno::ENOENT
26
+ Chef::Log.fatal("'hab' binary not found, use the 'habitat_install' resource to install it first")
27
+ raise
28
+ end
@@ -0,0 +1,129 @@
1
+ #
2
+ # Copyright:: Chef Software Inc.
3
+ #
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require_relative "../package"
20
+
21
+ class Chef
22
+ class Resource
23
+ class HabitatPackage < Chef::Resource::Package
24
+ unified_mode true
25
+
26
+ provides :habitat_package
27
+ use "habitat_shared"
28
+ description "Use the **habitat_package** to install or remove Chef Habitat packages from Habitat Builder."
29
+ introduced "17.3"
30
+ examples <<~DOC
31
+ **Install core/redis**
32
+
33
+ ```ruby
34
+ habitat_package 'core/redis'
35
+ ```
36
+
37
+ **Install specific version of a package from the unstable channel**
38
+
39
+ ```ruby
40
+ habitat_package 'core/redis' do
41
+ version '3.2.3'
42
+ channel 'unstable'
43
+ end
44
+ ```
45
+
46
+ **Install a package with specific version and revision**
47
+
48
+ ```ruby
49
+ habitat_package 'core/redis' do
50
+ version '3.2.3/20160920131015'
51
+ end
52
+ ```
53
+
54
+ **Install a package and force linking it's binary files to the system path**
55
+
56
+ ```ruby
57
+ habitat_package 'core/nginx' do
58
+ binlink :force
59
+ end
60
+ ```
61
+
62
+ **Install a package and link it's binary files to the system path**
63
+
64
+ ```ruby
65
+ habitat_package 'core/nginx' do
66
+ options '--binlink'
67
+ end
68
+ ```
69
+
70
+ **Remove package and all of it's versions**
71
+
72
+ ```ruby
73
+ habitat_package 'core/nginx'
74
+ action :remove
75
+ end
76
+ ```
77
+
78
+ **Remove specified version of a package**
79
+
80
+ ```ruby
81
+ habitat_package 'core/nginx/3.2.3'
82
+ action :remove
83
+ end
84
+ ```
85
+
86
+ **Remove package but retain some versions Note: Only available as of Habitat 1.5.86**
87
+
88
+ ```ruby
89
+ habitat_package 'core/nginx'
90
+ keep_latest '2'
91
+ action :remove
92
+ end
93
+ ```
94
+
95
+ ```ruby
96
+ **Remove package but keep dependencies**
97
+ habitat_package 'core/nginx'
98
+ no_deps false
99
+ action :remove
100
+ end
101
+ ```
102
+ DOC
103
+
104
+ property :bldr_url, String, default: "https://bldr.habitat.sh",
105
+ description: "The habitat builder url where packages will be downloaded from. **Defaults to public Habitat Builder**"
106
+
107
+ property :channel, String, default: "stable",
108
+ description: "The release channel to install your package from."
109
+
110
+ property :auth_token, String,
111
+ description: "Auth token for installing a package from a private organization on Habitat builder."
112
+
113
+ property :binlink, [true, false, :force], default: false,
114
+ description: "If habitat should attempt to binlink the package. Acceptable values: `true`, `false`, `:force`. Will fail on binlinking if set to `true` and binary or binlink exists."
115
+
116
+ property :options, String,
117
+ description: "Pass any additional parameters to the habitat package command."
118
+
119
+ property :keep_latest, String,
120
+ description: "Ability to uninstall while retaining a specified version **This feature only works in Habitat 1.5.86+.**"
121
+
122
+ property :exclude, String,
123
+ description: "Identifier of one or more packages that should not be uninstalled. (ex: core/redis, core/busybox-static/1.42.2/21120102031201)"
124
+
125
+ property :no_deps, [true, false], default: false,
126
+ description: "Remove package but retain dependencies."
127
+ end
128
+ end
129
+ end