chef 18.9.4 → 18.11.11
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.
- checksums.yaml +4 -4
- data/Gemfile +16 -12
- data/README.md +0 -1
- data/Rakefile +21 -5
- data/chef-universal-mingw-ucrt.gemspec +4 -2
- data/chef.gemspec +17 -14
- data/lib/chef/application/apply.rb +1 -1
- data/lib/chef/application/base.rb +4 -4
- data/lib/chef/application/exit_code.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +4 -4
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +2 -3
- data/lib/chef/client.rb +2 -3
- data/lib/chef/compliance/fetcher/chef_server.rb +1 -1
- data/lib/chef/compliance/reporter/cli.rb +2 -2
- data/lib/chef/compliance/runner.rb +19 -1
- data/lib/chef/dsl/chef_vault.rb +1 -1
- data/lib/chef/dsl/rest_resource.rb +223 -16
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -5
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_cache.rb +1 -5
- data/lib/chef/formatters/error_description.rb +8 -1
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +1 -1
- data/lib/chef/group.rb +1 -1
- data/lib/chef/handler/slow_report.rb +1 -1
- data/lib/chef/http/authenticator.rb +25 -12
- data/lib/chef/mixin/api_version_request_handling.rb +1 -1
- data/lib/chef/mixin/powershell_type_coercions.rb +2 -2
- data/lib/chef/mixin/securable.rb +2 -2
- data/lib/chef/mixin/template.rb +25 -3
- data/lib/chef/mixin/versioned_api.rb +1 -1
- data/lib/chef/monkey_patches/net-http.rb +8 -8
- data/lib/chef/monkey_patches/reline-windows.rb +116 -0
- data/lib/chef/property.rb +1 -1
- data/lib/chef/provider/cron.rb +1 -1
- data/lib/chef/provider/directory.rb +11 -0
- data/lib/chef/provider/dsc_resource.rb +2 -2
- data/lib/chef/provider/file/content.rb +3 -2
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/git.rb +1 -1
- data/lib/chef/provider/ifconfig/debian.rb +1 -1
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/mount/linux.rb +1 -1
- data/lib/chef/provider/mount/windows.rb +4 -4
- data/lib/chef/provider/package/chocolatey.rb +78 -19
- data/lib/chef/provider/package/dnf/dnf_helper.py +355 -65
- data/lib/chef/provider/package/dnf/python_helper.rb +7 -4
- data/lib/chef/provider/package/dnf.rb +25 -6
- data/lib/chef/provider/package/homebrew.rb +3 -3
- data/lib/chef/provider/package/rubygems.rb +25 -2
- data/lib/chef/provider/package/snap.rb +1 -1
- data/lib/chef/provider/package/windows/exe.rb +1 -1
- data/lib/chef/provider/package/windows/msi.rb +1 -1
- data/lib/chef/provider/package/yum/rpm_utils.rb +2 -2
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/powershell_script.rb +84 -84
- data/lib/chef/provider/service/debian.rb +2 -4
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/user/mac.rb +1 -1
- data/lib/chef/provider/windows_script.rb +1 -1
- data/lib/chef/resource/_rest_resource.rb +9 -7
- data/lib/chef/resource/alternatives.rb +41 -41
- data/lib/chef/resource/apt_package.rb +31 -31
- data/lib/chef/resource/apt_preference.rb +22 -22
- data/lib/chef/resource/apt_repository.rb +2 -2
- data/lib/chef/resource/archive_file.rb +52 -18
- data/lib/chef/resource/bash.rb +129 -129
- data/lib/chef/resource/bff_package.rb +15 -15
- data/lib/chef/resource/breakpoint.rb +44 -44
- data/lib/chef/resource/cab_package.rb +22 -22
- data/lib/chef/resource/chef_client_config.rb +251 -89
- data/lib/chef/resource/chef_client_cron.rb +18 -18
- data/lib/chef/resource/chef_client_launchd.rb +1 -1
- data/lib/chef/resource/chef_client_scheduled_task.rb +31 -31
- data/lib/chef/resource/chef_client_systemd_timer.rb +16 -16
- data/lib/chef/resource/chef_client_trusted_certificate.rb +28 -28
- data/lib/chef/resource/chef_handler.rb +107 -107
- data/lib/chef/resource/chef_vault_secret.rb +1 -1
- data/lib/chef/resource/chocolatey_config.rb +14 -14
- data/lib/chef/resource/chocolatey_feature.rb +1 -1
- data/lib/chef/resource/chocolatey_installer.rb +60 -42
- data/lib/chef/resource/chocolatey_package.rb +1 -1
- data/lib/chef/resource/chocolatey_source.rb +15 -15
- data/lib/chef/resource/cron/_cron_shared.rb +0 -2
- data/lib/chef/resource/cron/cron.rb +70 -70
- data/lib/chef/resource/csh.rb +5 -5
- data/lib/chef/resource/directory.rb +6 -6
- data/lib/chef/resource/dpkg_package.rb +3 -3
- data/lib/chef/resource/group.rb +28 -28
- data/lib/chef/resource/habitat/habitat_package.rb +80 -80
- data/lib/chef/resource/habitat/habitat_sup.rb +93 -95
- data/lib/chef/resource/habitat/habitat_sup_systemd.rb +10 -10
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +3 -3
- data/lib/chef/resource/habitat_config.rb +13 -13
- data/lib/chef/resource/habitat_install.rb +17 -17
- data/lib/chef/resource/habitat_service.rb +1 -1
- data/lib/chef/resource/habitat_user_toml.rb +12 -12
- data/lib/chef/resource/helpers/cron_validations.rb +2 -2
- data/lib/chef/resource/homebrew_cask.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +20 -20
- data/lib/chef/resource/homebrew_tap.rb +1 -1
- data/lib/chef/resource/hostname.rb +2 -2
- data/lib/chef/resource/http_request.rb +2 -2
- data/lib/chef/resource/ifconfig.rb +34 -34
- data/lib/chef/resource/inspec_input.rb +37 -37
- data/lib/chef/resource/inspec_waiver.rb +63 -63
- data/lib/chef/resource/inspec_waiver_file_entry.rb +25 -25
- data/lib/chef/resource/ksh.rb +5 -5
- data/lib/chef/resource/launchd.rb +2 -2
- data/lib/chef/resource/link.rb +8 -8
- data/lib/chef/resource/locale.rb +6 -6
- data/lib/chef/resource/log.rb +4 -4
- data/lib/chef/resource/mdadm.rb +36 -36
- data/lib/chef/resource/mount.rb +3 -3
- data/lib/chef/resource/msu_package.rb +1 -1
- data/lib/chef/resource/ohai.rb +32 -32
- data/lib/chef/resource/ohai_hint.rb +24 -24
- data/lib/chef/resource/openssl_ec_private_key.rb +2 -2
- data/lib/chef/resource/openssl_ec_public_key.rb +2 -2
- data/lib/chef/resource/openssl_rsa_private_key.rb +1 -1
- data/lib/chef/resource/openssl_rsa_public_key.rb +2 -2
- data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
- data/lib/chef/resource/openssl_x509_crl.rb +15 -15
- data/lib/chef/resource/openssl_x509_request.rb +2 -2
- data/lib/chef/resource/osx_profile.rb +54 -54
- data/lib/chef/resource/package.rb +6 -6
- data/lib/chef/resource/perl.rb +5 -5
- data/lib/chef/resource/plist.rb +4 -4
- data/lib/chef/resource/powershell_package_source.rb +12 -12
- data/lib/chef/resource/python.rb +4 -4
- data/lib/chef/resource/reboot.rb +5 -5
- data/lib/chef/resource/registry_key.rb +81 -81
- data/lib/chef/resource/remote_file.rb +72 -72
- data/lib/chef/resource/resource_notification.rb +4 -4
- data/lib/chef/resource/rhsm_errata_level.rb +1 -1
- data/lib/chef/resource/rhsm_register.rb +2 -2
- data/lib/chef/resource/scm/git.rb +79 -79
- data/lib/chef/resource/scm/subversion.rb +9 -9
- data/lib/chef/resource/script.rb +3 -3
- data/lib/chef/resource/selinux_boolean.rb +12 -12
- data/lib/chef/resource/selinux_fcontext.rb +21 -21
- data/lib/chef/resource/selinux_install.rb +18 -18
- data/lib/chef/resource/selinux_login.rb +11 -11
- data/lib/chef/resource/selinux_module.rb +16 -16
- data/lib/chef/resource/selinux_permissive.rb +9 -9
- data/lib/chef/resource/selinux_port.rb +16 -16
- data/lib/chef/resource/selinux_state.rb +28 -28
- data/lib/chef/resource/selinux_user.rb +14 -14
- data/lib/chef/resource/service.rb +5 -5
- data/lib/chef/resource/snap_package.rb +16 -16
- data/lib/chef/resource/ssh_known_hosts_entry.rb +10 -10
- data/lib/chef/resource/sudo.rb +68 -68
- data/lib/chef/resource/swap_file.rb +12 -12
- data/lib/chef/resource/sysctl.rb +42 -42
- data/lib/chef/resource/systemd_unit.rb +38 -38
- data/lib/chef/resource/timezone.rb +16 -16
- data/lib/chef/resource/user/mac_user.rb +3 -3
- data/lib/chef/resource/user.rb +6 -6
- data/lib/chef/resource/user_ulimit.rb +22 -22
- data/lib/chef/resource/windows_ad_join.rb +25 -25
- data/lib/chef/resource/windows_audit_policy.rb +34 -34
- data/lib/chef/resource/windows_auto_run.rb +8 -8
- data/lib/chef/resource/windows_certificate.rb +20 -20
- data/lib/chef/resource/windows_defender.rb +22 -22
- data/lib/chef/resource/windows_defender_exclusion.rb +17 -17
- data/lib/chef/resource/windows_env.rb +6 -6
- data/lib/chef/resource/windows_feature.rb +42 -42
- data/lib/chef/resource/windows_feature_dism.rb +8 -8
- data/lib/chef/resource/windows_feature_powershell.rb +20 -20
- data/lib/chef/resource/windows_firewall_profile.rb +28 -28
- data/lib/chef/resource/windows_firewall_rule.rb +47 -47
- data/lib/chef/resource/windows_font.rb +7 -7
- data/lib/chef/resource/windows_package.rb +59 -59
- data/lib/chef/resource/windows_pagefile.rb +29 -29
- data/lib/chef/resource/windows_path.rb +12 -12
- data/lib/chef/resource/windows_printer.rb +28 -28
- data/lib/chef/resource/windows_printer_port.rb +21 -21
- data/lib/chef/resource/windows_security_policy.rb +23 -23
- data/lib/chef/resource/windows_service.rb +108 -108
- data/lib/chef/resource/windows_share.rb +19 -19
- data/lib/chef/resource/windows_shortcut.rb +7 -7
- data/lib/chef/resource/windows_task.rb +105 -105
- data/lib/chef/resource/windows_uac.rb +14 -14
- data/lib/chef/resource/windows_update_settings.rb +27 -27
- data/lib/chef/resource/windows_user_privilege.rb +59 -59
- data/lib/chef/resource/windows_workgroup.rb +12 -12
- data/lib/chef/resource/yum_package.rb +1 -1
- data/lib/chef/resource/yum_repository.rb +36 -36
- data/lib/chef/resource.rb +1 -1
- data/lib/chef/resource_collection/resource_set.rb +2 -3
- data/lib/chef/resource_inspector.rb +1 -2
- data/lib/chef/run_context.rb +2 -2
- data/lib/chef/runner.rb +1 -1
- data/lib/chef/secret_fetcher/akeyless_vault.rb +0 -1
- data/lib/chef/secret_fetcher/hashi_vault.rb +0 -1
- data/lib/chef/shell/ext.rb +20 -20
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/shell.rb +7 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_constraint.rb +1 -1
- data/lib/chef/win32/file/version_info.rb +1 -1
- metadata +63 -38
|
@@ -28,95 +28,95 @@ class Chef
|
|
|
28
28
|
|
|
29
29
|
description "Use the **registry_key** resource to create and delete registry keys in Microsoft Windows. Note: 64-bit versions of Microsoft Windows have a 32-bit compatibility layer in the registry that reflects and redirects certain keys (and their values) into specific locations (or logical views) of the registry hive.\n\n#{ChefUtils::Dist::Infra::PRODUCT} can access any reflected or redirected registry key. The machine architecture of the system on which #{ChefUtils::Dist::Infra::PRODUCT} is running is used as the default (non-redirected) location. Access to the SysWow64 location is redirected must be specified. Typically, this is only necessary to ensure compatibility with 32-bit applications that are running on a 64-bit operating system.\n\nFor more information, see: [Registry Reflection](https://docs.microsoft.com/en-us/windows/win32/winprog64/registry-reflection)."
|
|
30
30
|
examples <<~'DOC'
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
**Create a registry key with binary data: "\x01\x02\x03"**:
|
|
45
|
-
|
|
46
|
-
```ruby
|
|
47
|
-
registry_key 'HKEY_CURRENT_USER\ChefTest' do
|
|
48
|
-
values [{
|
|
49
|
-
:name => "test",
|
|
50
|
-
:type => :binary,
|
|
51
|
-
:data => [0, 1, 2].map(&:chr).join
|
|
52
|
-
}]
|
|
31
|
+
**Create a registry key**
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
registry_key 'HKEY_LOCAL_MACHINE\\path-to-key\\Policies\\System' do
|
|
35
|
+
values [{
|
|
36
|
+
name: 'EnableLUA',
|
|
37
|
+
type: :dword,
|
|
38
|
+
data: 0
|
|
39
|
+
}]
|
|
40
|
+
action :create
|
|
41
|
+
end
|
|
42
|
+
```
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
end
|
|
56
|
-
```
|
|
44
|
+
**Create a registry key with binary data: "\x01\x02\x03"**:
|
|
57
45
|
|
|
58
|
-
|
|
46
|
+
```ruby
|
|
47
|
+
registry_key 'HKEY_CURRENT_USER\ChefTest' do
|
|
48
|
+
values [{
|
|
49
|
+
:name => "test",
|
|
50
|
+
:type => :binary,
|
|
51
|
+
:data => [0, 1, 2].map(&:chr).join
|
|
52
|
+
}]
|
|
59
53
|
|
|
60
|
-
|
|
54
|
+
action :create
|
|
55
|
+
end
|
|
56
|
+
```
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\Example' do
|
|
64
|
-
architecture :i386
|
|
65
|
-
recursive true
|
|
66
|
-
action :create
|
|
67
|
-
end
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
**Set proxy settings to be the same as those used by #{ChefUtils::Dist::Infra::PRODUCT}**
|
|
71
|
-
|
|
72
|
-
```ruby
|
|
73
|
-
proxy = URI.parse(Chef::Config[:http_proxy])
|
|
74
|
-
registry_key 'HKCU\Software\Microsoft\path\to\key\Internet Settings' do
|
|
75
|
-
values [{name: 'ProxyEnable', type: :reg_dword, data: 1},
|
|
76
|
-
{name: 'ProxyServer', data: "#{proxy.host}:#{proxy.port}"},
|
|
77
|
-
{name: 'ProxyOverride', type: :reg_string, data: <local>},
|
|
78
|
-
]
|
|
79
|
-
action :create
|
|
80
|
-
end
|
|
81
|
-
```
|
|
58
|
+
**Create 32-bit key in redirected wow6432 tree**
|
|
82
59
|
|
|
83
|
-
|
|
60
|
+
In 64-bit versions of Microsoft Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Example is a re-directed key. In the following examples, because HKEY_LOCAL_MACHINE\SOFTWARE\Example is a 32-bit key, the output will be “Found 32-bit key” if they are run on a version of Microsoft Windows that is 64-bit:
|
|
84
61
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
62
|
+
```ruby
|
|
63
|
+
registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\Example' do
|
|
64
|
+
architecture :i386
|
|
65
|
+
recursive true
|
|
66
|
+
action :create
|
|
67
|
+
end
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Set proxy settings to be the same as those used by #{ChefUtils::Dist::Infra::PRODUCT}**
|
|
71
|
+
|
|
72
|
+
```ruby
|
|
73
|
+
proxy = URI.parse(Chef::Config[:http_proxy])
|
|
74
|
+
registry_key 'HKCU\Software\Microsoft\path\to\key\Internet Settings' do
|
|
75
|
+
values [{name: 'ProxyEnable', type: :reg_dword, data: 1},
|
|
76
|
+
{name: 'ProxyServer', data: "#{proxy.host}:#{proxy.port}"},
|
|
77
|
+
{name: 'ProxyOverride', type: :reg_string, data: <local>},
|
|
78
|
+
]
|
|
79
|
+
action :create
|
|
80
|
+
end
|
|
81
|
+
```
|
|
94
82
|
|
|
95
|
-
|
|
83
|
+
**Set the name of a registry key to "(Default)"**
|
|
96
84
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
85
|
+
```ruby
|
|
86
|
+
registry_key 'Set (Default) value' do
|
|
87
|
+
key 'HKLM\Software\Test\Key\Path'
|
|
88
|
+
values [
|
|
89
|
+
{name: '', type: :string, data: 'test'},
|
|
90
|
+
]
|
|
91
|
+
action :create
|
|
92
|
+
end
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Delete a registry key value**
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
registry_key 'HKEY_LOCAL_MACHINE\SOFTWARE\path\to\key\AU' do
|
|
99
|
+
values [{
|
|
100
|
+
name: 'NoAutoRebootWithLoggedOnUsers',
|
|
101
|
+
type: :dword,
|
|
102
|
+
data: ''
|
|
103
|
+
}]
|
|
104
|
+
action :delete
|
|
105
|
+
end
|
|
106
|
+
```
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
Note: If data: is not specified, you get an error: Missing data key in RegistryKey values hash
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
**Delete a registry key and its subkeys, recursively**
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
```ruby
|
|
113
|
+
registry_key 'HKCU\SOFTWARE\Policies\path\to\key\Themes' do
|
|
114
|
+
recursive true
|
|
115
|
+
action :delete_key
|
|
116
|
+
end
|
|
117
|
+
```
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
Note: Be careful when using the :delete_key action with the recursive attribute. This will delete the registry key, all of its values and all of the names, types, and data associated with them. This cannot be undone by #{ChefUtils::Dist::Infra::PRODUCT}.
|
|
120
120
|
DOC
|
|
121
121
|
|
|
122
122
|
default_action :create
|
|
@@ -152,10 +152,10 @@ class Chef
|
|
|
152
152
|
property :recursive, [TrueClass, FalseClass], default: false
|
|
153
153
|
property :architecture, Symbol, default: :machine, equal_to: %i{machine x86_64 i386}
|
|
154
154
|
property :only_record_changes, [TrueClass, FalseClass],
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
default: true,
|
|
156
|
+
introduced: "18.7.3",
|
|
157
|
+
description: "(no-op) disabled functionality to only record registry value changes",
|
|
158
|
+
deprecated: true
|
|
159
159
|
|
|
160
160
|
# Some registry key data types may not be safely reported as json.
|
|
161
161
|
# Example (CHEF-5323):
|
|
@@ -34,75 +34,75 @@ class Chef
|
|
|
34
34
|
description "Use the **remote_file** resource to transfer a file from a remote location using file specificity. This resource is similar to the **file** resource. Note: Fetching files from the `files/` directory in a cookbook should be done with the **cookbook_file** resource."
|
|
35
35
|
|
|
36
36
|
examples <<~'DOC'
|
|
37
|
-
|
|
37
|
+
**Download a file without checking the checksum**:
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
```ruby
|
|
40
|
+
remote_file '/tmp/remote.txt' do
|
|
41
|
+
source 'https://example.org/remote.txt'
|
|
42
|
+
end
|
|
43
|
+
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
**Download a file with a checksum to validate**:
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
```ruby
|
|
48
|
+
remote_file '/tmp/test_file' do
|
|
49
|
+
source 'http://www.example.com/tempfiles/test_file'
|
|
50
|
+
mode '0755'
|
|
51
|
+
checksum '3a7dac00b1' # A SHA256 (or portion thereof) of the file.
|
|
52
|
+
end
|
|
53
|
+
```
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
**Download a file only if it's not already present**:
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
```ruby
|
|
58
|
+
remote_file '/tmp/remote.txt' do
|
|
59
|
+
source 'https://example.org/remote.txt'
|
|
60
|
+
checksum '3a7dac00b1' # A SHA256 (or portion thereof) of the file.
|
|
61
|
+
action :create_if_missing
|
|
62
|
+
end
|
|
63
|
+
```
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
**Using HTTP Basic Authentication in Headers**:
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
```ruby
|
|
68
|
+
remote_file '/tmp/remote.txt' do
|
|
69
|
+
source 'https://example.org/remote.txt'
|
|
70
|
+
headers('Authorization' => "Basic #{Base64.encode64("USERNAME_VALUE:PASSWORD_VALUE").delete("\n")}")
|
|
71
|
+
checksum '3a7dac00b1' # A SHA256 (or portion thereof) of the file.
|
|
72
|
+
action :create_if_missing
|
|
73
|
+
end
|
|
74
|
+
```
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
**Downloading a file to the Chef file cache dir for execution**:
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
```ruby
|
|
79
|
+
remote_file '#{Chef::Config['file_cache_path']}/install.sh' do
|
|
80
|
+
source 'https://example.org/install.sh'
|
|
81
|
+
action :create_if_missing
|
|
82
|
+
end
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
84
|
+
execute '#{Chef::Config['file_cache_path']}/install.sh'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Specify advanced HTTP connection options including Net::HTTP (nethttp) options:**
|
|
88
|
+
|
|
89
|
+
```ruby
|
|
90
|
+
remote_file '/tmp/remote.txt' do
|
|
91
|
+
source 'https://example.org/remote.txt'
|
|
92
|
+
http_options({
|
|
93
|
+
http_retry_delay: 0,
|
|
94
|
+
http_retry_count: 0,
|
|
95
|
+
keepalives: false,
|
|
96
|
+
nethttp: {
|
|
97
|
+
continue_timeout: 5,
|
|
98
|
+
max_retries: 5,
|
|
99
|
+
read_timeout: 5,
|
|
100
|
+
write_timeout: 5,
|
|
101
|
+
ssl_timeout: 5,
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
end
|
|
105
|
+
```
|
|
106
106
|
DOC
|
|
107
107
|
|
|
108
108
|
def initialize(name, run_context = nil)
|
|
@@ -135,7 +135,7 @@ class Chef
|
|
|
135
135
|
def parse_source_args(args)
|
|
136
136
|
if args.empty?
|
|
137
137
|
nil
|
|
138
|
-
elsif args[0].is_a?(Chef::DelayedEvaluator) && args.
|
|
138
|
+
elsif args[0].is_a?(Chef::DelayedEvaluator) && args.one?
|
|
139
139
|
args[0]
|
|
140
140
|
elsif args.any?(Chef::DelayedEvaluator) && args.count > 1
|
|
141
141
|
raise Exceptions::InvalidRemoteFileURI, "Only 1 source argument allowed when using a lazy evaluator"
|
|
@@ -168,23 +168,23 @@ class Chef
|
|
|
168
168
|
|
|
169
169
|
property :headers, Hash, default: {},
|
|
170
170
|
description: <<~'DOCS'
|
|
171
|
-
|
|
171
|
+
A Hash of custom headers. For example:
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
```ruby
|
|
174
|
+
headers({ "Cookie" => "user=some_user; pass=p@ssw0rd!" })
|
|
175
|
+
```
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
or:
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
```ruby
|
|
180
|
+
headers({ "Referer" => "#{header}" })
|
|
181
|
+
```
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
or:
|
|
184
184
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
```ruby
|
|
186
|
+
headers( "Authorization"=>"Basic #{ Base64.encode64("#{username}:#{password}").gsub("\n", "") }" )
|
|
187
|
+
```
|
|
188
188
|
DOCS
|
|
189
189
|
|
|
190
190
|
property :show_progress, [ TrueClass, FalseClass ],
|
|
@@ -41,7 +41,7 @@ class Chef
|
|
|
41
41
|
# @return [Boolean] does the resource match
|
|
42
42
|
def duplicates?(other_notification)
|
|
43
43
|
unless other_notification.respond_to?(:resource) && other_notification.respond_to?(:action)
|
|
44
|
-
msg = "only duck-types of Chef::Resource::Notification can be checked for duplication "\
|
|
44
|
+
msg = "only duck-types of Chef::Resource::Notification can be checked for duplication " \
|
|
45
45
|
"you gave #{other_notification.inspect}"
|
|
46
46
|
raise ArgumentError, msg
|
|
47
47
|
end
|
|
@@ -73,7 +73,7 @@ class Chef
|
|
|
73
73
|
def fix_resource_reference(resource_collection, always_raise = false)
|
|
74
74
|
matching_resource = resource_collection.find(resource)
|
|
75
75
|
if Array(matching_resource).size > 1
|
|
76
|
-
msg = "Notification #{self} from #{notifying_resource} was created with a reference to multiple resources, "\
|
|
76
|
+
msg = "Notification #{self} from #{notifying_resource} was created with a reference to multiple resources, " \
|
|
77
77
|
"but can only notify one resource. Notifying resource was defined on #{notifying_resource.source_line}"
|
|
78
78
|
raise Chef::Exceptions::InvalidResourceReference, msg
|
|
79
79
|
end
|
|
@@ -108,8 +108,8 @@ class Chef
|
|
|
108
108
|
def fix_notifier_reference(resource_collection)
|
|
109
109
|
matching_notifier = resource_collection.find(notifying_resource)
|
|
110
110
|
if Array(matching_notifier).size > 1
|
|
111
|
-
msg = "Notification #{self} from #{notifying_resource} was created with a reference to multiple notifying "\
|
|
112
|
-
"resources, but can only originate from one resource. Destination resource was defined "\
|
|
111
|
+
msg = "Notification #{self} from #{notifying_resource} was created with a reference to multiple notifying " \
|
|
112
|
+
"resources, but can only originate from one resource. Destination resource was defined " \
|
|
113
113
|
"on #{resource.source_line}"
|
|
114
114
|
raise Chef::Exceptions::InvalidResourceReference, msg
|
|
115
115
|
end
|
|
@@ -35,7 +35,7 @@ class Chef
|
|
|
35
35
|
DOC
|
|
36
36
|
|
|
37
37
|
property :errata_level, String,
|
|
38
|
-
coerce: proc
|
|
38
|
+
coerce: proc(&:downcase),
|
|
39
39
|
equal_to: %w{critical moderate important low},
|
|
40
40
|
description: "An optional property for specifying the errata level of packages to install if it differs from the resource block's name.",
|
|
41
41
|
name_property: true
|
|
@@ -53,7 +53,7 @@ class Chef
|
|
|
53
53
|
property :username, String,
|
|
54
54
|
description: "The username to use when registering. This property is not applicable if using an activation key. If specified, password and environment properties are also required."
|
|
55
55
|
|
|
56
|
-
property :password, String,
|
|
56
|
+
property :password, String, sensitive: true,
|
|
57
57
|
description: "The password to use when registering. This property is not applicable if using an activation key. If specified, username and environment are also required."
|
|
58
58
|
|
|
59
59
|
property :system_name, String,
|
|
@@ -80,7 +80,7 @@ class Chef
|
|
|
80
80
|
|
|
81
81
|
property :server_url, String,
|
|
82
82
|
description: "The hostname of the subscription service to use. The default is Customer Portal Subscription Management, subscription.rhn.redhat.com. If you do not use this option, the system registers with Customer Portal Subscription Management.",
|
|
83
|
-
|
|
83
|
+
introduced: "17.8"
|
|
84
84
|
|
|
85
85
|
property :base_url, String,
|
|
86
86
|
description: "The hostname of the content delivery server to use to receive updates. Both Customer Portal Subscription Management and Subscription Asset Manager use Red Hat's hosted content delivery services, with the URL https://cdn.redhat.com. Since Satellite 6 hosts its own content, the URL must be used for systems registered with Satellite 6.",
|
|
@@ -27,85 +27,85 @@ class Chef
|
|
|
27
27
|
|
|
28
28
|
description "Use the **git** resource to manage source control resources that exist in a git repository. git version 1.6.5 (or higher) is required to use all of the functionality in the git resource."
|
|
29
29
|
examples <<~DOC
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
30
|
+
**Use the git mirror**
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
git '/opt/my_sources/couch' do
|
|
34
|
+
repository 'git://git.apache.org/couchdb.git'
|
|
35
|
+
revision 'master'
|
|
36
|
+
action :sync
|
|
37
|
+
end
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Use different branches**
|
|
41
|
+
|
|
42
|
+
To use different branches, depending on the environment of the node:
|
|
43
|
+
|
|
44
|
+
```ruby
|
|
45
|
+
branch_name = if node.chef_environment == 'QA'
|
|
46
|
+
'staging'
|
|
47
|
+
else
|
|
48
|
+
'master'
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
git '/home/user/deployment' do
|
|
52
|
+
repository 'git@github.com:git_site/deployment.git'
|
|
53
|
+
revision branch_name
|
|
54
|
+
action :sync
|
|
55
|
+
user 'user'
|
|
56
|
+
group 'test'
|
|
57
|
+
end
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Where the `branch_name` variable is set to staging or master, depending on the environment of the node. Once this is determined, the `branch_name` variable is used to set the revision for the repository. If the git status command is used after running the example above, it will return the branch name as `deploy`, as this is the default value. Run Chef Infra Client in debug mode to verify that the correct branches are being checked out:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
sudo chef-client -l debug
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Install an application from git using bash**
|
|
67
|
+
|
|
68
|
+
The following example shows how Bash can be used to install a plug-in for rbenv named ruby-build, which is located in git version source control. First, the application is synchronized, and then Bash changes its working directory to the location in which ruby-build is located, and then runs a command.
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
git "#{Chef::Config[:file_cache_path]}/ruby-build" do
|
|
72
|
+
repository 'git://github.com/rbenv/ruby-build.git'
|
|
73
|
+
revision 'master'
|
|
74
|
+
action :sync
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
bash 'install_ruby_build' do
|
|
78
|
+
cwd "#{Chef::Config[:file_cache_path]}/ruby-build"
|
|
79
|
+
user 'rbenv'
|
|
80
|
+
group 'rbenv'
|
|
81
|
+
code <<-EOH
|
|
82
|
+
./install.sh
|
|
83
|
+
EOH
|
|
84
|
+
environment 'PREFIX' => '/usr/local'
|
|
85
|
+
end
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Notify a resource post-checkout**
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
git "#{Chef::Config[:file_cache_path]}/my_app" do
|
|
92
|
+
repository node['my_app']['git_repository']
|
|
93
|
+
revision node['my_app']['git_revision']
|
|
94
|
+
action :sync
|
|
95
|
+
notifies :run, 'bash[compile_my_app]', :immediately
|
|
96
|
+
end
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Pass in environment variables**
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
git '/opt/my_sources/couch' do
|
|
103
|
+
repository 'git://git.apache.org/couchdb.git'
|
|
104
|
+
revision 'master'
|
|
105
|
+
environment 'VAR' => 'whatever'
|
|
106
|
+
action :sync
|
|
107
|
+
end
|
|
108
|
+
```
|
|
109
109
|
DOC
|
|
110
110
|
|
|
111
111
|
property :additional_remotes, Hash,
|
|
@@ -28,16 +28,16 @@ class Chef
|
|
|
28
28
|
|
|
29
29
|
description "Use the **subversion** resource to manage source control resources that exist in a Subversion repository. Warning: The subversion resource has known bugs and may not work as expected. For more information see Chef GitHub issues, particularly [#4050](https://github.com/chef/chef/issues/4050) and [#4257](https://github.com/chef/chef/issues/4257)."
|
|
30
30
|
examples <<~DOC
|
|
31
|
-
|
|
31
|
+
**Get the latest version of an application**
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
```ruby
|
|
34
|
+
subversion 'CouchDB Edge' do
|
|
35
|
+
repository 'http://svn.apache.org/repos/asf/couchdb/trunk'
|
|
36
|
+
revision 'HEAD'
|
|
37
|
+
destination '/opt/my_sources/couch'
|
|
38
|
+
action :sync
|
|
39
|
+
end
|
|
40
|
+
```
|
|
41
41
|
DOC
|
|
42
42
|
|
|
43
43
|
allowed_actions :force_export
|
data/lib/chef/resource/script.rb
CHANGED
|
@@ -27,9 +27,9 @@ class Chef
|
|
|
27
27
|
|
|
28
28
|
identity_attr :name
|
|
29
29
|
|
|
30
|
-
description "Use the **script** resource to execute scripts using a specified interpreter, such as Bash, csh, Perl, Python, or Ruby."\
|
|
31
|
-
" This resource may also use any of the actions and properties that are available to the **execute** resource. Commands"\
|
|
32
|
-
" that are executed with this resource are (by their nature) not idempotent, as they are typically unique to the"\
|
|
30
|
+
description "Use the **script** resource to execute scripts using a specified interpreter, such as Bash, csh, Perl, Python, or Ruby." \
|
|
31
|
+
" This resource may also use any of the actions and properties that are available to the **execute** resource. Commands" \
|
|
32
|
+
" that are executed with this resource are (by their nature) not idempotent, as they are typically unique to the" \
|
|
33
33
|
" environment in which they are run. Use `not_if` and `only_if` to guard this resource for idempotence."
|
|
34
34
|
|
|
35
35
|
def initialize(name, run_context = nil)
|