chef 17.0.242-universal-mingw32 → 17.4.25-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -14
- data/Rakefile +2 -2
- data/chef.gemspec +10 -20
- data/lib/chef/action_collection.rb +6 -26
- data/lib/chef/application/base.rb +15 -0
- data/lib/chef/application.rb +4 -2
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/client.rb +7 -1
- data/lib/chef/compliance/default_attributes.rb +5 -3
- data/lib/chef/compliance/reporter/automate.rb +1 -1
- data/lib/chef/compliance/runner.rb +17 -3
- data/lib/chef/cookbook/cookbook_version_loader.rb +3 -3
- data/lib/chef/cookbook/gem_installer.rb +5 -1
- data/lib/chef/cookbook_version.rb +26 -4
- data/lib/chef/data_collector/run_end_message.rb +1 -1
- data/lib/chef/data_collector.rb +0 -1
- data/lib/chef/deprecated.rb +14 -4
- data/lib/chef/dsl/declare_resource.rb +5 -10
- data/lib/chef/dsl/render_helpers.rb +44 -0
- data/lib/chef/dsl/secret.rb +64 -0
- data/lib/chef/dsl/toml.rb +116 -0
- data/lib/chef/dsl/universal.rb +5 -0
- data/lib/chef/dsl.rb +1 -0
- data/lib/chef/event_dispatch/base.rb +2 -1
- data/lib/chef/exceptions.rb +23 -0
- data/lib/chef/formatters/doc.rb +2 -1
- data/lib/chef/formatters/error_mapper.rb +2 -2
- data/lib/chef/handler/slow_report.rb +66 -0
- data/lib/chef/handler.rb +46 -8
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/node.rb +21 -20
- data/lib/chef/policy_builder/policyfile.rb +88 -45
- data/lib/chef/provider/directory.rb +6 -6
- data/lib/chef/provider/execute.rb +1 -1
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/launchd.rb +6 -6
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/lwrp_base.rb +1 -1
- data/lib/chef/provider/package/dnf/dnf_helper.py +11 -10
- data/lib/chef/provider/package/dnf/python_helper.rb +9 -8
- data/lib/chef/provider/package/habitat.rb +168 -0
- data/lib/chef/provider/package/powershell.rb +5 -0
- data/lib/chef/provider/package/yum/python_helper.rb +15 -10
- data/lib/chef/provider/package/yum/yum_helper.py +46 -62
- data/lib/chef/provider/package/yum.rb +1 -4
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/subversion.rb +4 -4
- data/lib/chef/provider/support/yum_repo.erb +1 -1
- data/lib/chef/provider/support/zypper_repo.erb +4 -2
- data/lib/chef/provider/systemd_unit.rb +18 -17
- data/lib/chef/provider/template/content.rb +1 -1
- data/lib/chef/provider/user/mac.rb +3 -3
- data/lib/chef/provider/windows_script.rb +1 -1
- data/lib/chef/provider/yum_repository.rb +27 -43
- data/lib/chef/provider/zypper_repository.rb +30 -34
- data/lib/chef/provider.rb +26 -1
- data/lib/chef/provider_resolver.rb +8 -2
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource/alternatives.rb +5 -5
- data/lib/chef/resource/apt_preference.rb +2 -2
- data/lib/chef/resource/apt_repository.rb +2 -2
- data/lib/chef/resource/apt_update.rb +4 -4
- data/lib/chef/resource/build_essential.rb +1 -1
- data/lib/chef/resource/chef_client_config.rb +10 -5
- data/lib/chef/resource/chef_client_cron.rb +3 -3
- data/lib/chef/resource/chef_client_launchd.rb +3 -3
- data/lib/chef/resource/chef_client_scheduled_task.rb +15 -15
- data/lib/chef/resource/chef_client_systemd_timer.rb +3 -3
- data/lib/chef/resource/chef_client_trusted_certificate.rb +2 -2
- data/lib/chef/resource/chef_handler.rb +2 -2
- data/lib/chef/resource/chef_sleep.rb +1 -1
- data/lib/chef/resource/chef_vault_secret.rb +2 -2
- data/lib/chef/resource/chocolatey_feature.rb +2 -2
- data/lib/chef/resource/chocolatey_source.rb +1 -1
- data/lib/chef/resource/cron/cron_d.rb +4 -6
- data/lib/chef/resource/cron_access.rb +1 -1
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dsc_resource.rb +1 -1
- data/lib/chef/resource/execute.rb +5 -5
- data/lib/chef/resource/gem_package.rb +2 -1
- data/lib/chef/resource/group.rb +4 -4
- data/lib/chef/resource/habitat/_habitat_shared.rb +28 -0
- data/lib/chef/resource/habitat/habitat_package.rb +129 -0
- data/lib/chef/resource/habitat/habitat_sup.rb +329 -0
- data/lib/chef/resource/habitat/habitat_sup_systemd.rb +67 -0
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +90 -0
- data/lib/chef/resource/habitat_config.rb +107 -0
- data/lib/chef/resource/habitat_install.rb +247 -0
- data/lib/chef/resource/habitat_service.rb +451 -0
- data/lib/chef/resource/habitat_user_toml.rb +92 -0
- data/lib/chef/resource/homebrew_cask.rb +18 -7
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +4 -3
- data/lib/chef/resource/homebrew_update.rb +2 -2
- data/lib/chef/resource/hostname.rb +49 -7
- data/lib/chef/resource/inspec_waiver_file_entry.rb +156 -0
- data/lib/chef/resource/kernel_module.rb +6 -6
- data/lib/chef/resource/launchd.rb +3 -3
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/lwrp_base.rb +18 -3
- data/lib/chef/resource/macos_userdefaults.rb +2 -2
- data/lib/chef/resource/ohai_hint.rb +2 -6
- data/lib/chef/resource/openbsd_package.rb +17 -0
- data/lib/chef/resource/openssl_dhparam.rb +1 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +1 -3
- data/lib/chef/resource/openssl_ec_public_key.rb +1 -3
- data/lib/chef/resource/openssl_rsa_private_key.rb +1 -3
- data/lib/chef/resource/openssl_rsa_public_key.rb +1 -3
- data/lib/chef/resource/openssl_x509_certificate.rb +1 -4
- data/lib/chef/resource/openssl_x509_crl.rb +1 -3
- data/lib/chef/resource/openssl_x509_request.rb +1 -3
- data/lib/chef/resource/osx_profile.rb +3 -3
- data/lib/chef/resource/plist.rb +1 -1
- data/lib/chef/resource/powershell_package_source.rb +2 -4
- data/lib/chef/resource/reboot.rb +38 -9
- data/lib/chef/resource/remote_directory.rb +2 -2
- data/lib/chef/resource/remote_file.rb +3 -3
- data/lib/chef/resource/rhsm_errata.rb +0 -2
- data/lib/chef/resource/rhsm_errata_level.rb +1 -5
- data/lib/chef/resource/rhsm_repo.rb +15 -0
- data/lib/chef/resource/rhsm_subscription.rb +5 -5
- data/lib/chef/resource/ruby_block.rb +100 -0
- data/lib/chef/resource/scm/subversion.rb +1 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +4 -7
- data/lib/chef/resource/sudo.rb +2 -6
- data/lib/chef/resource/support/HabService.dll.config.erb +19 -0
- data/lib/chef/resource/support/client.erb +8 -1
- data/lib/chef/resource/support/sup.toml.erb +179 -0
- data/lib/chef/resource/swap_file.rb +2 -6
- data/lib/chef/resource/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +3 -3
- data/lib/chef/resource/timezone.rb +1 -1
- data/lib/chef/resource/user_ulimit.rb +2 -2
- data/lib/chef/resource/windows_ad_join.rb +2 -2
- data/lib/chef/resource/windows_audit_policy.rb +2 -2
- data/lib/chef/resource/windows_auto_run.rb +2 -2
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_defender.rb +163 -0
- data/lib/chef/resource/windows_defender_exclusion.rb +125 -0
- data/lib/chef/resource/windows_dfs_folder.rb +2 -2
- data/lib/chef/resource/windows_dfs_namespace.rb +2 -2
- data/lib/chef/resource/windows_dns_record.rb +2 -2
- data/lib/chef/resource/windows_dns_zone.rb +2 -2
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +3 -3
- data/lib/chef/resource/windows_feature_dism.rb +3 -5
- data/lib/chef/resource/windows_feature_powershell.rb +3 -3
- data/lib/chef/resource/windows_firewall_profile.rb +2 -2
- data/lib/chef/resource/windows_firewall_rule.rb +20 -6
- data/lib/chef/resource/windows_font.rb +2 -2
- data/lib/chef/resource/windows_pagefile.rb +104 -65
- data/lib/chef/resource/windows_path.rb +4 -4
- data/lib/chef/resource/windows_printer.rb +80 -61
- data/lib/chef/resource/windows_printer_port.rb +48 -65
- data/lib/chef/resource/windows_security_policy.rb +7 -4
- data/lib/chef/resource/windows_share.rb +2 -2
- data/lib/chef/resource/windows_shortcut.rb +1 -1
- data/lib/chef/resource/windows_task.rb +2 -2
- data/lib/chef/resource/windows_uac.rb +3 -5
- data/lib/chef/resource/windows_update_settings.rb +259 -0
- data/lib/chef/resource/windows_user_privilege.rb +2 -2
- data/lib/chef/resource/windows_workgroup.rb +2 -2
- data/lib/chef/resource/yum_package.rb +11 -15
- data/lib/chef/resource/zypper_package.rb +4 -4
- data/lib/chef/resource/zypper_repository.rb +28 -8
- data/lib/chef/resource.rb +20 -25
- data/lib/chef/resource_builder.rb +8 -2
- data/lib/chef/resource_inspector.rb +6 -2
- data/lib/chef/resource_reporter.rb +0 -1
- data/lib/chef/resources.rb +13 -1
- data/lib/chef/run_lock.rb +1 -1
- data/lib/chef/runner.rb +1 -1
- data/lib/chef/secret_fetcher/aws_secrets_manager.rb +65 -0
- data/lib/chef/secret_fetcher/azure_key_vault.rb +78 -0
- data/lib/chef/secret_fetcher/base.rb +76 -0
- data/lib/chef/secret_fetcher/example.rb +46 -0
- data/lib/chef/secret_fetcher.rb +55 -0
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +9 -2
- data/spec/data/knife-home/.chef/plugins/knife/example_home_subcommand.rb +0 -0
- data/spec/data/knife-site-subcommands/plugins/knife/example_subcommand.rb +0 -0
- data/spec/data/knife_subcommand/test_explicit_category.rb +7 -0
- data/spec/data/knife_subcommand/test_name_mapping.rb +4 -0
- data/spec/data/knife_subcommand/test_yourself.rb +21 -0
- data/spec/functional/mixin/from_file_spec.rb +1 -1
- data/spec/functional/resource/dnf_package_spec.rb +857 -537
- data/spec/functional/resource/group_spec.rb +1 -1
- data/spec/functional/resource/link_spec.rb +1 -1
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/windows_env_spec.rb +2 -2
- data/spec/functional/resource/windows_hostname_spec.rb +91 -0
- data/spec/functional/resource/windows_pagefile_spec.rb +98 -0
- data/spec/functional/resource/yum_package_spec.rb +495 -428
- data/spec/integration/client/client_spec.rb +0 -20
- data/spec/integration/compliance/compliance_spec.rb +1 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
- data/spec/integration/recipes/resource_action_spec.rb +6 -6
- data/spec/integration/recipes/unified_mode_spec.rb +70 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/knife.rb +37 -0
- data/spec/support/shared/integration/knife_support.rb +192 -0
- data/spec/support/shared/unit/knife_shared.rb +39 -0
- data/spec/support/shared/unit/provider/file.rb +3 -9
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +1 -1
- data/spec/unit/compliance/runner_spec.rb +46 -2
- data/spec/unit/cookbook_version_spec.rb +52 -0
- data/spec/unit/data_collector_spec.rb +47 -1
- data/spec/unit/dsl/render_helpers_spec.rb +102 -0
- data/spec/unit/dsl/secret_spec.rb +71 -0
- data/spec/unit/handler_spec.rb +8 -2
- data/spec/unit/policy_builder/dynamic_spec.rb +0 -5
- data/spec/unit/policy_builder/policyfile_spec.rb +144 -56
- data/spec/unit/provider/apt_update_spec.rb +3 -1
- data/spec/unit/provider/link_spec.rb +1 -1
- data/spec/unit/provider/mount/aix_spec.rb +1 -1
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -0
- data/spec/unit/provider/package/powershell_spec.rb +74 -12
- data/spec/unit/provider/package/yum/python_helper_spec.rb +1 -0
- data/spec/unit/provider/service/systemd_service_spec.rb +2 -2
- data/spec/unit/provider/systemd_unit_spec.rb +2 -2
- data/spec/unit/provider/zypper_repository_spec.rb +3 -10
- data/spec/unit/provider_spec.rb +23 -0
- data/spec/unit/resource/homebrew_cask_spec.rb +29 -11
- data/spec/unit/resource/inspec_waiver_file_entry_spec.rb +80 -0
- data/spec/unit/resource/rhsm_subscription_spec.rb +50 -3
- data/spec/unit/resource/systemd_unit_spec.rb +1 -1
- data/spec/unit/resource/windows_defender_exclusion_spec.rb +62 -0
- data/spec/unit/resource/windows_defender_spec.rb +71 -0
- data/spec/unit/resource/windows_firewall_rule_spec.rb +12 -7
- data/spec/unit/resource/windows_pagefile_spec.rb +4 -9
- data/spec/unit/resource/windows_update_settings_spec.rb +64 -0
- data/spec/unit/resource/zypper_repository_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +19 -8
- data/spec/unit/secret_fetcher/aws_secrets_manager_spec.rb +70 -0
- data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +70 -0
- data/spec/unit/secret_fetcher_spec.rb +82 -0
- data/tasks/rspec.rb +4 -9
- metadata +65 -161
- data/lib/chef/provider/package/yum/simplejson/LICENSE.txt +0 -79
- data/lib/chef/provider/package/yum/simplejson/__init__.py +0 -318
- data/lib/chef/provider/package/yum/simplejson/__init__.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/decoder.py +0 -354
- data/lib/chef/provider/package/yum/simplejson/decoder.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/encoder.py +0 -440
- data/lib/chef/provider/package/yum/simplejson/encoder.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/scanner.py +0 -65
- data/lib/chef/provider/package/yum/simplejson/scanner.pyc +0 -0
- data/lib/chef/provider/package/yum/simplejson/tool.py +0 -37
@@ -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
|
@@ -0,0 +1,329 @@
|
|
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
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require_relative "../../resource"
|
19
|
+
|
20
|
+
class Chef
|
21
|
+
class Resource
|
22
|
+
class HabitatSup < Chef::Resource
|
23
|
+
unified_mode true
|
24
|
+
|
25
|
+
provides :habitat_sup do |_node|
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
description "Use the **habitat_sup** resource to runs a Chef Habitat supervisor for one or more Chef Habitat services. The resource is commonly used in conjunction with `habitat_service` which will manage the services loaded and started within the supervisor."
|
30
|
+
introduced "17.3"
|
31
|
+
examples <<~DOC
|
32
|
+
**Set up with just the defaults**
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
habitat_sup 'default'
|
36
|
+
```
|
37
|
+
|
38
|
+
**Update listen ports and use Supervisor toml config**
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
habitat_sup 'test-options' do
|
42
|
+
listen_http '0.0.0.0:9999'
|
43
|
+
listen_gossip '0.0.0.0:9998'
|
44
|
+
toml_config true
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
**Use with an on-prem Habitat Builder. Note: Access to public builder may not be available due to your company policies**
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
habitat_sup 'default' do
|
52
|
+
bldr_url 'https://bldr.private.net'
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
**Using update_condition**
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
habitat_sup 'default' do
|
60
|
+
bldr_url 'https://bldr.private.net'
|
61
|
+
habitat_channel 'dev'
|
62
|
+
update_condition 'track-channel'
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
**Provide event_stream_* information**
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
habitat_sup 'default' do
|
70
|
+
license 'accept'
|
71
|
+
event_stream_application 'myapp'
|
72
|
+
event_stream_environment 'production'
|
73
|
+
event_stream_site 'MySite'
|
74
|
+
event_stream_url 'automate.private.net:4222'
|
75
|
+
event_stream_token 'myawesomea2clitoken='
|
76
|
+
event_stream_cert '/hab/cache/ssl/mycert.crt'
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
**Provide specific versions**
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
habitat_sup 'default' do
|
84
|
+
bldr_url 'https://bldr.private.net'
|
85
|
+
sup_version '1.5.50'
|
86
|
+
launcher_version '13458'
|
87
|
+
service_version '0.6.0' # WINDOWS ONLY
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
**Set latest version of packages to retain**
|
92
|
+
|
93
|
+
habitat_sup 'default' do
|
94
|
+
bldr_url 'https://bldr.private.net'
|
95
|
+
sup_version '1.5.86'
|
96
|
+
launcher_version '13458'
|
97
|
+
service_version '0.6.0' # WINDOWS ONLY
|
98
|
+
keep_latest '2'
|
99
|
+
end
|
100
|
+
```
|
101
|
+
DOC
|
102
|
+
|
103
|
+
property :bldr_url, String,
|
104
|
+
description: "The Habitat Builder URL for the `habitat_package` resource, if needed."
|
105
|
+
|
106
|
+
property :permanent_peer, [true, false], default: false,
|
107
|
+
description: "Only valid for `:run` action, passes `--permanent-peer` to the hab command."
|
108
|
+
|
109
|
+
property :listen_ctl, String,
|
110
|
+
description: "Only valid for `:run` action, passes `--listen-ctl` with the specified address and port, e.g., `0.0.0.0:9632`, to the hab command."
|
111
|
+
|
112
|
+
property :listen_gossip, String,
|
113
|
+
description: "Only valid for `:run` action, passes `--listen-gossip` with the specified address and port, e.g., `0.0.0.0:9638`, to the hab command."
|
114
|
+
|
115
|
+
property :listen_http, String,
|
116
|
+
description: "Only valid for `:run` action, passes `--listen-http` with the specified address and port, e.g., `0.0.0.0:9631`, to the hab command."
|
117
|
+
|
118
|
+
property :org, String, default: "default",
|
119
|
+
description: "Only valid for `:run` action, passes `--org` with the specified org name to the hab command."
|
120
|
+
|
121
|
+
property :peer, [String, Array], coerce: proc { |b| b.is_a?(String) ? [b] : b },
|
122
|
+
description: "Only valid for `:run` action, passes `--peer` with the specified initial peer to the hab command."
|
123
|
+
|
124
|
+
property :ring, String,
|
125
|
+
description: "Only valid for `:run` action, passes `--ring` with the specified ring key name to the hab command."
|
126
|
+
|
127
|
+
property :hab_channel, String,
|
128
|
+
description: "The channel to install Habitat from. Defaults to stable"
|
129
|
+
|
130
|
+
property :auto_update, [true, false], default: false,
|
131
|
+
description: "Passes `--auto-update`. This will set the Habitat supervisor to automatically update itself any time a stable version has been released."
|
132
|
+
|
133
|
+
property :auth_token, String,
|
134
|
+
description: "Auth token for accessing a private organization on bldr. This value is templated into the appropriate service file."
|
135
|
+
|
136
|
+
property :gateway_auth_token, String,
|
137
|
+
description: "Auth token for accessing the supervisor's HTTP gateway. This value is templated into the appropriate service file."
|
138
|
+
|
139
|
+
property :update_condition, String,
|
140
|
+
description: "Passes `--update-condition` dictating when this service should updated. Defaults to `latest`. Options are `latest` or `track-channel` **_Note: This requires a minimum habitat version of 1.5.71_**
|
141
|
+
- `latest`: Runs the latest package that can be found in the configured channel and local packages.
|
142
|
+
- `track-channel`: Always run what is at the head of a given channel. This enables service rollback where demoting a package from a channel will cause the package to rollback to an older version of the package. A ramification of enabling this condition is packages newer than the package at the head of the channel will be automatically uninstalled during a service rollback."
|
143
|
+
|
144
|
+
property :limit_no_files, String,
|
145
|
+
description: "allows you to set LimitNOFILE in the systemd service when used Note: Linux Only."
|
146
|
+
|
147
|
+
property :license, String, equal_to: ["accept"],
|
148
|
+
description: "Specifies acceptance of habitat license when set to `accept`."
|
149
|
+
|
150
|
+
property :health_check_interval, [String, Integer], coerce: proc { |h| h.is_a?(String) ? h : h.to_s },
|
151
|
+
description: "The interval (seconds) on which to run health checks."
|
152
|
+
|
153
|
+
property :event_stream_application, String,
|
154
|
+
description: "The name of your application that will be displayed in the Chef Automate Applications Dashboard."
|
155
|
+
|
156
|
+
property :event_stream_environment, String,
|
157
|
+
description: "The application environment for the supervisor, this is for grouping in the Applications Dashboard."
|
158
|
+
|
159
|
+
property :event_stream_site, String,
|
160
|
+
description: "Application Dashboard label for the 'site' of the application - can be filtered in the dashboard."
|
161
|
+
|
162
|
+
property :event_stream_url, String,
|
163
|
+
description: "`AUTOMATE_HOSTNAME:4222` - the Chef Automate URL with port 4222 specified Note: The port can be changed if needed."
|
164
|
+
|
165
|
+
property :event_stream_token, String,
|
166
|
+
description: "Chef Automate token for sending application event stream data."
|
167
|
+
|
168
|
+
property :event_stream_cert, String,
|
169
|
+
description: "With `Intermediary Certificates` or, Automate 2 being set to use TLS with a valid cert, you will need to provide `Habitat` with your certificate for communication with Automate to work. [Follow these steps!](https://automate.chef.io/docs/applications-setup/#share-the-tls-certificate-with-chef-habitat)."
|
170
|
+
|
171
|
+
property :sup_version, String,
|
172
|
+
description: "Allows you to choose which version of supervisor you would like to install. Note: If a version is provided, it will also install that version of habitat if not previously installed."
|
173
|
+
|
174
|
+
property :launcher_version, String,
|
175
|
+
description: "Allows you to choose which version of launcher to install."
|
176
|
+
|
177
|
+
property :service_version, String, # Windows only
|
178
|
+
description: "Allows you to choose which version of the **_Windows Service_** to install."
|
179
|
+
|
180
|
+
property :keep_latest, String,
|
181
|
+
description: "Automatically cleans up old packages. If this flag is enabled, service startup will initiate an uninstall of all previous versions of the associated package. This also applies when a service is restarted due to an update. If a number is passed to this argument, that number of latest versions will be kept. The same logic applies to the Supervisor package `env:HAB_KEEP_LATEST_PACKAGES=1` Note: This requires Habitat version `1.5.86+`"
|
182
|
+
|
183
|
+
property :toml_config, [true, false], default: false,
|
184
|
+
description: "Supports using the Supervisor toml configuration instead of passing exec parameters to the service, [reference](https://www.habitat.sh/docs/reference/#supervisor-config)."
|
185
|
+
|
186
|
+
action :run, description: "The `run` action handles installing Habitat using the `habitat_install` resource, ensures that the appropriate versions of the `core/hab-sup` and `core/hab-launcher` packages are installed using `habitat_package`, and then drops off the appropriate init system definitions and manages the service." do
|
187
|
+
habitat_install new_resource.name do
|
188
|
+
license new_resource.license
|
189
|
+
hab_version new_resource.sup_version if new_resource.sup_version
|
190
|
+
not_if { ::File.exist?("/bin/hab") }
|
191
|
+
not_if { ::File.exist?("/usr/bin/hab") }
|
192
|
+
not_if { ::File.exist?("c:/habitat/hab.exe") }
|
193
|
+
not_if { ::File.exist?("c:/ProgramData/Habitat/hab.exe") }
|
194
|
+
end
|
195
|
+
|
196
|
+
habitat_package "core/hab-sup" do
|
197
|
+
bldr_url new_resource.bldr_url if new_resource.bldr_url
|
198
|
+
version new_resource.sup_version if new_resource.sup_version
|
199
|
+
end
|
200
|
+
|
201
|
+
habitat_package "core/hab-launcher" do
|
202
|
+
bldr_url new_resource.bldr_url if new_resource.bldr_url
|
203
|
+
version new_resource.launcher_version if new_resource.launcher_version
|
204
|
+
end
|
205
|
+
|
206
|
+
if windows?
|
207
|
+
directory "C:/hab/sup/default/config" do
|
208
|
+
recursive true
|
209
|
+
only_if { ::Dir.exist?("C:/hab") }
|
210
|
+
only_if { use_toml_config }
|
211
|
+
action :create
|
212
|
+
end
|
213
|
+
|
214
|
+
template "C:/hab/sup/default/config/sup.toml" do
|
215
|
+
source ::File.expand_path("../support/sup.toml.erb", __dir__)
|
216
|
+
local true
|
217
|
+
sensitive true
|
218
|
+
variables(
|
219
|
+
bldr_url: new_resource.bldr_url,
|
220
|
+
permanent_peer: new_resource.permanent_peer,
|
221
|
+
listen_ctl: new_resource.listen_ctl,
|
222
|
+
listen_gossip: new_resource.listen_gossip,
|
223
|
+
listen_http: new_resource.listen_http,
|
224
|
+
organization: new_resource.org,
|
225
|
+
peer: peer_list_with_port,
|
226
|
+
ring: new_resource.ring,
|
227
|
+
auto_update: new_resource.auto_update,
|
228
|
+
update_condition: new_resource.update_condition,
|
229
|
+
health_check_interval: new_resource.health_check_interval,
|
230
|
+
event_stream_application: new_resource.event_stream_application,
|
231
|
+
event_stream_environment: new_resource.event_stream_environment,
|
232
|
+
event_stream_site: new_resource.event_stream_site,
|
233
|
+
event_stream_url: new_resource.event_stream_url,
|
234
|
+
event_stream_token: new_resource.event_stream_token,
|
235
|
+
event_stream_server_certificate: new_resource.event_stream_cert,
|
236
|
+
keep_latest_packages: new_resource.keep_latest
|
237
|
+
)
|
238
|
+
only_if { use_toml_config }
|
239
|
+
only_if { ::Dir.exist?("C:/hab/sup/default/config") }
|
240
|
+
end
|
241
|
+
else
|
242
|
+
directory "/hab/sup/default/config" do
|
243
|
+
mode "0755"
|
244
|
+
recursive true
|
245
|
+
only_if { use_toml_config }
|
246
|
+
only_if { ::Dir.exist?("/hab") }
|
247
|
+
action :create
|
248
|
+
end
|
249
|
+
|
250
|
+
template "/hab/sup/default/config/sup.toml" do
|
251
|
+
source ::File.expand_path("../support/sup.toml.erb", __dir__)
|
252
|
+
local true
|
253
|
+
sensitive true
|
254
|
+
variables(
|
255
|
+
bldr_url: new_resource.bldr_url,
|
256
|
+
permanent_peer: new_resource.permanent_peer,
|
257
|
+
listen_ctl: new_resource.listen_ctl,
|
258
|
+
listen_gossip: new_resource.listen_gossip,
|
259
|
+
listen_http: new_resource.listen_http,
|
260
|
+
organization: new_resource.org,
|
261
|
+
peer: peer_list_with_port,
|
262
|
+
ring: new_resource.ring,
|
263
|
+
auto_update: new_resource.auto_update,
|
264
|
+
update_condition: new_resource.update_condition,
|
265
|
+
health_check_interval: new_resource.health_check_interval,
|
266
|
+
event_stream_application: new_resource.event_stream_application,
|
267
|
+
event_stream_environment: new_resource.event_stream_environment,
|
268
|
+
event_stream_site: new_resource.event_stream_site,
|
269
|
+
event_stream_url: new_resource.event_stream_url,
|
270
|
+
event_stream_token: new_resource.event_stream_token,
|
271
|
+
event_stream_server_certificate: new_resource.event_stream_cert,
|
272
|
+
keep_latest_packages: new_resource.keep_latest
|
273
|
+
)
|
274
|
+
only_if { use_toml_config }
|
275
|
+
only_if { ::Dir.exist?("/hab/sup/default/config") }
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
action_class do
|
281
|
+
use "habitat_shared"
|
282
|
+
# validate that peers have been passed with a port # for toml file
|
283
|
+
def peer_list_with_port
|
284
|
+
if new_resource.peer
|
285
|
+
peer_list = []
|
286
|
+
new_resource.peer.each do |p|
|
287
|
+
peer_list << if p !~ /.*:.*/
|
288
|
+
p + ":9632"
|
289
|
+
else
|
290
|
+
p
|
291
|
+
end
|
292
|
+
end
|
293
|
+
peer_list
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
# Specify whether toml configuration should be used in place of service arguments.
|
298
|
+
def use_toml_config
|
299
|
+
new_resource.toml_config
|
300
|
+
end
|
301
|
+
|
302
|
+
def exec_start_options
|
303
|
+
# Populate exec_start_options which will pass to 'hab sup run' for platforms if use_toml_config is not 'true'
|
304
|
+
unless use_toml_config
|
305
|
+
opts = []
|
306
|
+
opts << "--permanent-peer" if new_resource.permanent_peer
|
307
|
+
opts << "--listen-ctl #{new_resource.listen_ctl}" if new_resource.listen_ctl
|
308
|
+
opts << "--listen-gossip #{new_resource.listen_gossip}" if new_resource.listen_gossip
|
309
|
+
opts << "--listen-http #{new_resource.listen_http}" if new_resource.listen_http
|
310
|
+
opts << "--org #{new_resource.org}" unless new_resource.org == "default"
|
311
|
+
opts.push(*new_resource.peer.map { |b| "--peer #{b}" }) if new_resource.peer
|
312
|
+
opts << "--ring #{new_resource.ring}" if new_resource.ring
|
313
|
+
opts << "--auto-update" if new_resource.auto_update
|
314
|
+
opts << "--update-condition #{new_resource.update_condition}" if new_resource.update_condition
|
315
|
+
opts << "--health-check-interval #{new_resource.health_check_interval}" if new_resource.health_check_interval
|
316
|
+
opts << "--event-stream-application #{new_resource.event_stream_application}" if new_resource.event_stream_application
|
317
|
+
opts << "--event-stream-environment #{new_resource.event_stream_environment}" if new_resource.event_stream_environment
|
318
|
+
opts << "--event-stream-site #{new_resource.event_stream_site}" if new_resource.event_stream_site
|
319
|
+
opts << "--event-stream-url #{new_resource.event_stream_url}" if new_resource.event_stream_url
|
320
|
+
opts << "--event-stream-token #{new_resource.event_stream_token}" if new_resource.event_stream_token
|
321
|
+
opts << "--event-stream-server-certificate #{new_resource.event_stream_cert}" if new_resource.event_stream_cert
|
322
|
+
opts << "--keep-latest-packages #{new_resource.keep_latest}" if new_resource.keep_latest
|
323
|
+
opts.join(" ")
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|