chef 14.1.12-universal-mingw32 → 14.2.0-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 +1 -6
- data/VERSION +1 -1
- data/chef.gemspec +2 -3
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +8 -4
- data/lib/chef/cookbook/manifest_v0.rb +2 -2
- data/lib/chef/cookbook_manifest.rb +3 -2
- data/lib/chef/cookbook_version.rb +3 -2
- data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -2
- data/lib/chef/http/auth_credentials.rb +5 -3
- data/lib/chef/http/authenticator.rb +6 -3
- data/lib/chef/knife.rb +3 -6
- data/lib/chef/knife/configure.rb +12 -8
- data/lib/chef/knife/raw.rb +6 -1
- data/lib/chef/mixin/shell_out.rb +16 -14
- data/lib/chef/provider/execute.rb +4 -3
- data/lib/chef/provider/git.rb +1 -1
- data/lib/chef/provider/package/dnf.rb +5 -5
- data/lib/chef/provider/package/windows.rb +7 -0
- data/lib/chef/provider/package/yum.rb +7 -7
- data/lib/chef/provider/service/freebsd.rb +3 -3
- data/lib/chef/provider/service/init.rb +5 -5
- data/lib/chef/provider/service/macosx.rb +5 -4
- data/lib/chef/provider/service/simple.rb +4 -4
- data/lib/chef/provider/service/systemd.rb +13 -13
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/service/windows.rb +2 -0
- data/lib/chef/provider/systemd_unit.rb +4 -4
- data/lib/chef/provider/user.rb +18 -1
- data/lib/chef/provider/user/aix.rb +40 -8
- data/lib/chef/provider/user/dscl.rb +7 -14
- data/lib/chef/provider/user/linux.rb +1 -11
- data/lib/chef/provider/user/solaris.rb +57 -26
- data/lib/chef/provider/user/useradd.rb +4 -1
- data/lib/chef/provider/windows_task.rb +1 -0
- data/lib/chef/providers.rb +1 -2
- data/lib/chef/resource/execute.rb +4 -1
- data/lib/chef/resource/gem_package.rb +1 -1
- data/lib/chef/resource/hostname.rb +1 -1
- data/lib/chef/resource/sysctl.rb +3 -1
- data/lib/chef/resource/windows_ad_join.rb +16 -3
- data/lib/chef/resource_inspector.rb +13 -0
- data/lib/chef/run_context/cookbook_compiler.rb +1 -1
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/version.rb +1 -1
- data/spec/functional/mixin/shell_out_spec.rb +27 -1
- data/spec/functional/resource/execute_spec.rb +2 -2
- data/spec/functional/resource/windows_task_spec.rb +1 -1
- data/spec/support/shared/functional/securable_resource.rb +1 -1
- data/spec/support/shared/unit/execute_resource.rb +1 -1
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +3 -3
- data/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb +65 -0
- data/spec/unit/cookbook/manifest_v0_spec.rb +1 -1
- data/spec/unit/cookbook_manifest_spec.rb +2 -0
- data/spec/unit/dsl/recipe_spec.rb +1 -5
- data/spec/unit/http/authenticator_spec.rb +33 -8
- data/spec/unit/mixin/shell_out_spec.rb +61 -1
- data/spec/unit/provider/apt_update_spec.rb +7 -7
- data/spec/unit/provider/execute_spec.rb +16 -15
- data/spec/unit/provider/git_spec.rb +3 -3
- data/spec/unit/provider/package/windows_spec.rb +12 -0
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/arch_service_spec.rb +9 -9
- data/spec/unit/provider/service/freebsd_service_spec.rb +6 -6
- data/spec/unit/provider/service/init_service_spec.rb +11 -11
- data/spec/unit/provider/service/invokercd_service_spec.rb +9 -9
- data/spec/unit/provider/service/macosx_spec.rb +11 -11
- data/spec/unit/provider/service/openbsd_service_spec.rb +6 -6
- data/spec/unit/provider/service/simple_service_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_service_spec.rb +16 -16
- data/spec/unit/provider/service/upstart_service_spec.rb +12 -12
- data/spec/unit/provider/service/windows_spec.rb +5 -0
- data/spec/unit/provider/systemd_unit_spec.rb +163 -118
- data/spec/unit/provider/user/dscl_spec.rb +2 -9
- data/spec/unit/provider/user/solaris_spec.rb +2 -2
- data/spec/unit/provider/zypper_repository_spec.rb +3 -3
- data/spec/unit/provider_spec.rb +1 -5
- data/spec/unit/resource/apt_package_spec.rb +14 -0
- data/spec/unit/resource/apt_preference_spec.rb +14 -1
- data/spec/unit/resource/apt_repository_spec.rb +12 -3
- data/spec/unit/resource/apt_update_spec.rb +9 -0
- data/spec/unit/resource/bash_spec.rb +8 -0
- data/spec/unit/resource/bff_package_spec.rb +51 -0
- data/spec/unit/resource/breakpoint_spec.rb +4 -4
- data/spec/unit/resource/build_essential_spec.rb +5 -1
- data/spec/unit/resource/cab_package_spec.rb +10 -0
- data/spec/unit/resource/chef_gem_spec.rb +14 -0
- data/spec/unit/resource/chef_handler_spec.rb +9 -4
- data/spec/unit/resource/chocolatey_package_spec.rb +15 -1
- data/spec/unit/resource/conditional_spec.rb +3 -3
- data/spec/unit/resource/cookbook_file_spec.rb +13 -2
- data/spec/unit/resource/cron_spec.rb +2 -7
- data/spec/unit/resource/csh_spec.rb +8 -0
- data/spec/unit/resource/directory_spec.rb +4 -9
- data/spec/unit/resource/dmg_package_spec.rb +8 -4
- data/spec/unit/resource/dnf_package_spec.rb +16 -1
- data/spec/unit/resource/dpkg_package_spec.rb +18 -0
- data/spec/unit/resource/dsc_resource_spec.rb +6 -6
- data/spec/unit/resource/dsc_script_spec.rb +39 -39
- data/spec/unit/resource/execute_spec.rb +20 -12
- data/spec/unit/resource/file_spec.rb +10 -10
- data/spec/unit/resource/freebsd_package_spec.rb +16 -0
- data/spec/unit/resource/gem_package_spec.rb +27 -0
- data/spec/unit/resource/git_spec.rb +17 -2
- data/spec/unit/resource/group_spec.rb +18 -17
- data/spec/unit/resource/homebrew_cask_spec.rb +9 -4
- data/spec/unit/resource/homebrew_package_spec.rb +14 -0
- data/spec/unit/resource/homebrew_tap_spec.rb +8 -3
- data/spec/unit/resource/hostname_spec.rb +10 -6
- data/spec/unit/resource/http_request_spec.rb +14 -0
- data/spec/unit/resource/ips_package_spec.rb +15 -3
- data/spec/unit/resource/ksh_spec.rb +8 -0
- data/spec/unit/resource/launchd_spec.rb +11 -5
- data/spec/unit/resource/link_spec.rb +6 -11
- data/spec/unit/resource/log_spec.rb +8 -8
- data/spec/unit/resource/macos_user_defaults_spec.rb +5 -1
- data/spec/unit/resource/macports_package_spec.rb +19 -0
- data/spec/unit/resource/mdadm_spec.rb +7 -3
- data/spec/unit/resource/mount_spec.rb +15 -18
- data/spec/unit/resource/msu_package_spec.rb +10 -0
- data/spec/unit/resource/ohai_hint_spec.rb +9 -8
- data/spec/unit/resource/ohai_spec.rb +11 -3
- data/spec/unit/resource/openbsd_package_spec.rb +14 -0
- data/spec/unit/resource/openssl_dhparam.rb +10 -5
- data/spec/unit/resource/openssl_rsa_private_key_spec.rb +10 -5
- data/spec/unit/resource/openssl_rsa_public_key_spec.rb +9 -5
- data/spec/unit/resource/osx_profile_spec.rb +7 -4
- data/spec/unit/resource/package_spec.rb +14 -0
- data/spec/unit/resource/pacman_package_spec.rb +17 -3
- data/spec/unit/resource/paludis_package_spec.rb +36 -0
- data/spec/unit/resource/perl_spec.rb +8 -0
- data/spec/unit/resource/portage_package_spec.rb +14 -0
- data/spec/unit/resource/powershell_package_spec.rb +14 -0
- data/spec/unit/resource/python_spec.rb +8 -0
- data/spec/unit/resource/reboot_spec.rb +5 -3
- data/spec/unit/resource/registry_key_spec.rb +12 -1
- data/spec/unit/resource/remote_directory_spec.rb +11 -1
- data/spec/unit/resource/remote_file_spec.rb +19 -0
- data/spec/unit/resource/rhsm_errata_level_spec.rb +7 -3
- data/spec/unit/resource/rhsm_errata_spec.rb +8 -4
- data/spec/unit/resource/rhsm_register_spec.rb +6 -1
- data/spec/unit/resource/rhsm_repo_spec.rb +9 -4
- data/spec/unit/resource/rhsm_subscription_spec.rb +9 -4
- data/spec/unit/resource/route_spec.rb +4 -9
- data/spec/unit/resource/rpm_package_spec.rb +14 -0
- data/spec/unit/resource/ruby_block_spec.rb +12 -8
- data/spec/unit/resource/ruby_spec.rb +8 -0
- data/spec/unit/resource/scm_spec.rb +16 -8
- data/spec/unit/resource/script_spec.rb +8 -0
- data/spec/unit/resource/service_spec.rb +15 -0
- data/spec/unit/resource/smartos_package_spec.rb +18 -4
- data/spec/unit/resource/solaris_package_spec.rb +14 -0
- data/spec/unit/resource/subversion_spec.rb +14 -8
- data/spec/unit/resource/sudo_spec.rb +11 -4
- data/spec/unit/resource/swap_file_spec.rb +4 -5
- data/spec/unit/resource/sysctl_spec.rb +8 -10
- data/spec/unit/resource/systemd_unit_spec.rb +14 -12
- data/spec/unit/resource/template_spec.rb +19 -0
- data/spec/unit/resource/{windows_ad_join.rb → windows_ad_join_spec.rb} +12 -6
- data/spec/unit/resource/windows_auto_run_spec.rb +9 -9
- data/spec/unit/resource/windows_env_spec.rb +8 -16
- data/spec/unit/resource/windows_feature.rb +27 -8
- data/spec/unit/resource/windows_feature_dism.rb +30 -9
- data/spec/unit/resource/windows_feature_powershell.rb +7 -7
- data/spec/unit/resource/windows_font_spec.rb +3 -4
- data/spec/unit/resource/windows_package_spec.rb +12 -2
- data/spec/unit/resource/windows_pagefile_spec.rb +12 -8
- data/spec/unit/resource/windows_path_spec.rb +4 -5
- data/spec/unit/resource/windows_printer_port_spec.rb +20 -3
- data/spec/unit/resource/windows_printer_spec.rb +12 -5
- data/spec/unit/resource/windows_service_spec.rb +24 -1
- data/spec/unit/resource/windows_shortcut_spec.rb +4 -5
- data/spec/unit/resource/yum_repository_spec.rb +48 -2
- data/spec/unit/resource/zypper_package_spec.rb +51 -0
- data/spec/unit/resource/zypper_repository_spec.rb +56 -11
- data/spec/unit/resource_spec.rb +1 -5
- metadata +21 -12
- data/spec/functional/resource/user/useradd_spec.rb +0 -709
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright 2016-
|
2
|
+
# Copyright:: Copyright 2016-2018, Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -85,16 +85,6 @@ class Chef
|
|
85
85
|
opts
|
86
86
|
end
|
87
87
|
|
88
|
-
def should_set?(sym)
|
89
|
-
current_resource.send(sym).to_s != new_resource.send(sym).to_s && new_resource.send(sym)
|
90
|
-
end
|
91
|
-
|
92
|
-
def updating_home?
|
93
|
-
return false unless new_resource.home
|
94
|
-
return true unless current_resource.home
|
95
|
-
new_resource.home && Pathname.new(current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath
|
96
|
-
end
|
97
|
-
|
98
88
|
def check_lock
|
99
89
|
# there's an old bug in rhel (https://bugzilla.redhat.com/show_bug.cgi?id=578534)
|
100
90
|
# which means that both 0 and 1 can be success.
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Stephen Nelson-Smith (<sns@chef.io>)
|
3
3
|
# Author:: Jon Ramsey (<jonathon.ramsey@gmail.com>)
|
4
4
|
# Author:: Dave Eddy (<dave@daveeddy.com>)
|
5
|
-
# Copyright:: Copyright 2012-
|
5
|
+
# Copyright:: Copyright 2012-2018, Chef Software Inc.
|
6
6
|
# Copyright:: Copyright 2015-2016, Dave Eddy
|
7
7
|
# License:: Apache License, Version 2.0
|
8
8
|
#
|
@@ -18,35 +18,34 @@
|
|
18
18
|
# See the License for the specific language governing permissions and
|
19
19
|
# limitations under the License.
|
20
20
|
|
21
|
-
require "chef/provider/user
|
21
|
+
require "chef/provider/user"
|
22
22
|
|
23
23
|
class Chef
|
24
24
|
class Provider
|
25
25
|
class User
|
26
|
-
class Solaris < Chef::Provider::User
|
26
|
+
class Solaris < Chef::Provider::User
|
27
27
|
provides :solaris_user
|
28
|
-
provides :user, os: %w{omnios solaris2}
|
29
|
-
UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]].freeze
|
28
|
+
provides :user, os: %w{openindiana opensolaris illumos omnios solaris2 smartos}
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
def initialize(new_resource, run_context)
|
34
|
-
@password_file = "/etc/shadow"
|
35
|
-
super
|
36
|
-
end
|
30
|
+
PASSWORD_FILE = "/etc/shadow"
|
37
31
|
|
38
32
|
def create_user
|
39
|
-
|
33
|
+
shell_out_compact!("useradd", universal_options, useradd_options, new_resource.username)
|
40
34
|
manage_password
|
41
35
|
end
|
42
36
|
|
43
37
|
def manage_user
|
44
38
|
manage_password
|
45
|
-
|
39
|
+
return if universal_options.empty? && usermod_options.empty?
|
40
|
+
shell_out_compact!("usermod", universal_options, usermod_options, new_resource.username)
|
41
|
+
end
|
42
|
+
|
43
|
+
def remove_user
|
44
|
+
shell_out_compact!("userdel", userdel_options, new_resource.username)
|
46
45
|
end
|
47
46
|
|
48
47
|
def check_lock
|
49
|
-
user = IO.read(
|
48
|
+
user = IO.read(PASSWORD_FILE).match(/^#{Regexp.escape(new_resource.username)}:([^:]*):/)
|
50
49
|
|
51
50
|
# If we're in whyrun mode, and the user is not created, we assume it will be
|
52
51
|
return false if whyrun_mode? && user.nil?
|
@@ -66,15 +65,45 @@ class Chef
|
|
66
65
|
|
67
66
|
private
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
68
|
+
def universal_options
|
69
|
+
opts = []
|
70
|
+
opts << "-c" << new_resource.comment if should_set?(:comment)
|
71
|
+
opts << "-g" << new_resource.gid if should_set?(:gid)
|
72
|
+
opts << "-s" << new_resource.shell if should_set?(:shell)
|
73
|
+
opts << "-u" << new_resource.uid if should_set?(:uid)
|
74
|
+
opts << "-d" << new_resource.home if updating_home?
|
75
|
+
opts << "-o" if new_resource.non_unique
|
76
|
+
if updating_home?
|
77
|
+
if new_resource.manage_home
|
78
|
+
logger.trace("#{new_resource} managing the users home directory")
|
79
|
+
opts << "-m"
|
80
|
+
else
|
81
|
+
logger.trace("#{new_resource} setting home to #{new_resource.home}")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
opts
|
85
|
+
end
|
86
|
+
|
87
|
+
def usermod_options
|
88
|
+
opts = []
|
89
|
+
opts += [ "-u", new_resource.uid ] if new_resource.non_unique
|
90
|
+
if updating_home?
|
91
|
+
if new_resource.manage_home
|
92
|
+
opts << "-m"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
opts
|
96
|
+
end
|
97
|
+
|
98
|
+
def userdel_options
|
99
|
+
opts = []
|
100
|
+
opts << "-r" if new_resource.manage_home
|
101
|
+
opts << "-f" if new_resource.force
|
102
|
+
opts
|
103
|
+
end
|
104
|
+
|
105
|
+
# Solaris does not support system users and has no '-r' option, solaris also
|
106
|
+
# lacks '-M' and defaults to no-manage-home.
|
78
107
|
def useradd_options
|
79
108
|
opts = []
|
80
109
|
opts << "-m" if new_resource.manage_home
|
@@ -87,9 +116,11 @@ class Chef
|
|
87
116
|
write_shadow_file
|
88
117
|
end
|
89
118
|
|
119
|
+
# XXX: this was straight copypasta'd back in 2013 and I don't think we've ever evaluted using
|
120
|
+
# a pipe to passwd(1) or evaluating modern ruby-shadow. See https://github.com/chef/chef/pull/721
|
90
121
|
def write_shadow_file
|
91
122
|
buffer = Tempfile.new("shadow", "/etc")
|
92
|
-
::File.open(
|
123
|
+
::File.open(PASSWORD_FILE) do |shadow_file|
|
93
124
|
shadow_file.each do |entry|
|
94
125
|
user = entry.split(":").first
|
95
126
|
if user == new_resource.username
|
@@ -102,7 +133,7 @@ class Chef
|
|
102
133
|
buffer.close
|
103
134
|
|
104
135
|
# FIXME: mostly duplicates code with file provider deploying a file
|
105
|
-
s = ::File.stat(
|
136
|
+
s = ::File.stat(PASSWORD_FILE)
|
106
137
|
mode = s.mode & 0o7777
|
107
138
|
uid = s.uid
|
108
139
|
gid = s.gid
|
@@ -110,7 +141,7 @@ class Chef
|
|
110
141
|
FileUtils.chown uid, gid, buffer.path
|
111
142
|
FileUtils.chmod mode, buffer.path
|
112
143
|
|
113
|
-
FileUtils.mv buffer.path,
|
144
|
+
FileUtils.mv buffer.path, PASSWORD_FILE
|
114
145
|
end
|
115
146
|
|
116
147
|
def updated_password(entry)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -23,6 +23,9 @@ class Chef
|
|
23
23
|
class Provider
|
24
24
|
class User
|
25
25
|
class Useradd < Chef::Provider::User
|
26
|
+
|
27
|
+
Chef::Log.warn("the Chef::Provider::User::Useradd provider is deprecated, please subclass Chef::Provider::User directly")
|
28
|
+
|
26
29
|
# the linux version of this has been forked off, this is the base class now of solaris and AIX and should be abandoned
|
27
30
|
# and those provider should be rewritten like the linux version.
|
28
31
|
|
@@ -231,6 +231,7 @@ class Chef
|
|
231
231
|
|
232
232
|
# seprated command arguments from :command property
|
233
233
|
def set_command_and_arguments
|
234
|
+
new_resource.command = new_resource.command.gsub(/\\/, '\&\&')
|
234
235
|
cmd, *args = Shellwords.split(new_resource.command)
|
235
236
|
new_resource.command = cmd
|
236
237
|
new_resource.command_arguments = args.join(" ")
|
data/lib/chef/providers.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
3
|
-
# Copyright:: Copyright 2010-
|
3
|
+
# Copyright:: Copyright 2010-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -109,7 +109,6 @@ require "chef/provider/user/dscl"
|
|
109
109
|
require "chef/provider/user/linux"
|
110
110
|
require "chef/provider/user/pw"
|
111
111
|
require "chef/provider/user/solaris"
|
112
|
-
require "chef/provider/user/useradd"
|
113
112
|
require "chef/provider/user/windows"
|
114
113
|
|
115
114
|
require "chef/provider/group/aix"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
3
|
# Author:: Tyler Cloke (<tyler@chef.io>)
|
4
|
-
# Copyright:: Copyright 2008-
|
4
|
+
# Copyright:: Copyright 2008-2018, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -64,6 +64,9 @@ class Chef
|
|
64
64
|
|
65
65
|
property :group, [ String, Integer ]
|
66
66
|
property :live_stream, [ TrueClass, FalseClass ], default: false
|
67
|
+
# default_env defaults to `false` so that the command execution more exactly matches what the user gets on the command line without magic
|
68
|
+
property :default_env, [ TrueClass, FalseClass ], desired_state: false, default: false,
|
69
|
+
description: "When true this enables ENV magic to add path_sanity to the PATH and force the locale to English+UTF-8 for parsing output"
|
67
70
|
property :returns, [ Integer, Array ], default: 0
|
68
71
|
property :timeout, [ Integer, Float ]
|
69
72
|
property :user, [ String, Integer ]
|
@@ -40,7 +40,7 @@ class Chef
|
|
40
40
|
# FIXME? the array form of installing paths most likely does not work?
|
41
41
|
#
|
42
42
|
property :source, [ String, Array ]
|
43
|
-
property :clear_sources, [ TrueClass, FalseClass ], default:
|
43
|
+
property :clear_sources, [ TrueClass, FalseClass ], default: lazy { Chef::Config[:clear_gem_sources] }, desired_state: false
|
44
44
|
# Sets a custom gem_binary to run for gem commands.
|
45
45
|
property :gem_binary, String, desired_state: false
|
46
46
|
|
@@ -116,7 +116,7 @@ class Chef
|
|
116
116
|
# this must come before other methods like /etc/hostname and /etc/sysconfig/network
|
117
117
|
declare_resource(:execute, "hostnamectl set-hostname #{new_resource.hostname}") do
|
118
118
|
notifies :reload, "ohai[reload hostname]"
|
119
|
-
not_if { shell_out!("hostnamectl status", { :returns => [0, 1] }).stdout =~ /Static hostname:\s
|
119
|
+
not_if { shell_out!("hostnamectl status", { :returns => [0, 1] }).stdout =~ /Static hostname:\s*#{new_resource.hostname}\s*$/ }
|
120
120
|
end
|
121
121
|
when ::File.exist?("/etc/hostname")
|
122
122
|
# debian family uses /etc/hostname
|
data/lib/chef/resource/sysctl.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Copyright:: 2018, Webb Agile Solutions Ltd.
|
3
|
-
# Copyright:: 2018, Chef Software Inc.
|
3
|
+
# Copyright:: 2018-2018, Chef Software Inc.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -84,6 +84,7 @@ class Chef
|
|
84
84
|
|
85
85
|
execute "Load sysctl values" do
|
86
86
|
command "sysctl #{'-e ' if new_resource.ignore_error}-p"
|
87
|
+
default_env true
|
87
88
|
action :run
|
88
89
|
end
|
89
90
|
end
|
@@ -98,6 +99,7 @@ class Chef
|
|
98
99
|
end
|
99
100
|
|
100
101
|
execute "Load sysctl values" do
|
102
|
+
default_env true
|
101
103
|
command "sysctl -p"
|
102
104
|
action :run
|
103
105
|
end
|
@@ -47,7 +47,7 @@ class Chef
|
|
47
47
|
description: "The path to the OU where you would like to place the host."
|
48
48
|
|
49
49
|
property :reboot, Symbol,
|
50
|
-
equal_to: [:immediate, :delayed, :never],
|
50
|
+
equal_to: [:immediate, :delayed, :never, :request_reboot, :reboot_now],
|
51
51
|
validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the Chef run completes), and :never (Don't reboot)",
|
52
52
|
description: "Controls the system reboot behavior post domain joining. Reboot immediately, after the Chef run completes, or never. Note that a reboot is necessary for changes to take effect.",
|
53
53
|
default: :immediate
|
@@ -71,8 +71,8 @@ class Chef
|
|
71
71
|
raise "Failed to join the domain #{new_resource.domain_name}: #{ps_run.stderr}}" if ps_run.error?
|
72
72
|
|
73
73
|
unless new_resource.reboot == :never
|
74
|
-
|
75
|
-
action new_resource.reboot
|
74
|
+
reboot "Reboot to join domain #{new_resource.domain_name}" do
|
75
|
+
action clarify_reboot(new_resource.reboot)
|
76
76
|
reason "Reboot to join domain #{new_resource.domain_name}"
|
77
77
|
end
|
78
78
|
end
|
@@ -86,6 +86,19 @@ class Chef
|
|
86
86
|
raise "Failed to check if the system is joined to the domain #{new_resource.domain_name}: #{node_domain.stderr}}" if node_domain.error?
|
87
87
|
node_domain.stdout.downcase.strip == new_resource.domain_name.downcase
|
88
88
|
end
|
89
|
+
|
90
|
+
# This resource historically took `:immediate` and `:delayed` as arguments to the reboot property but then
|
91
|
+
# tried to shove that straight to the `reboot` resource which objected strenuously
|
92
|
+
def clarify_reboot(reboot_action)
|
93
|
+
case reboot_action
|
94
|
+
when :immediate
|
95
|
+
:reboot_now
|
96
|
+
when :delayed
|
97
|
+
:request_reboot
|
98
|
+
else
|
99
|
+
reboot_action
|
100
|
+
end
|
101
|
+
end
|
89
102
|
end
|
90
103
|
end
|
91
104
|
end
|
@@ -24,10 +24,22 @@ require "chef/resources"
|
|
24
24
|
require "chef/json_compat"
|
25
25
|
|
26
26
|
module ResourceInspector
|
27
|
+
def self.get_default(default)
|
28
|
+
if default.kind_of?(Chef::DelayedEvaluator)
|
29
|
+
# ideally we'd get the block we pass to `lazy`, but the best we can do
|
30
|
+
# is to get the source location, which then results in reparsing the source
|
31
|
+
# code for the resource ourselves and just no
|
32
|
+
"lazy default"
|
33
|
+
else
|
34
|
+
default
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
27
38
|
def self.extract_resource(resource, complete = false)
|
28
39
|
data = {}
|
29
40
|
data[:description] = resource.description
|
30
41
|
# data[:deprecated] = resource.deprecated || false
|
42
|
+
data[:default_action] = resource.default_action
|
31
43
|
data[:actions] = resource.allowed_actions
|
32
44
|
data[:examples] = resource.examples
|
33
45
|
data[:introduced] = resource.introduced
|
@@ -43,6 +55,7 @@ module ResourceInspector
|
|
43
55
|
acc << { name: n, description: opts[:description],
|
44
56
|
introduced: opts[:introduced], is: opts[:is],
|
45
57
|
deprecated: opts[:deprecated] || false,
|
58
|
+
default: get_default(opts[:default]),
|
46
59
|
name_property: opts[:name_property] || false }
|
47
60
|
end
|
48
61
|
data
|
@@ -191,7 +191,7 @@ class Chef
|
|
191
191
|
|
192
192
|
def load_attributes_from_cookbook(cookbook_name)
|
193
193
|
list_of_attr_files = files_in_cookbook_by_segment(cookbook_name, :attributes).dup
|
194
|
-
root_alias = cookbook_collection[cookbook_name].files_for(:root_files).find { |record| record[:name] == "attributes.rb" }
|
194
|
+
root_alias = cookbook_collection[cookbook_name].files_for(:root_files).find { |record| record[:name] == "root_files/attributes.rb" }
|
195
195
|
default_file = list_of_attr_files.find { |path| File.basename(path) == "default.rb" }
|
196
196
|
if root_alias
|
197
197
|
if default_file
|
data/lib/chef/server_api.rb
CHANGED
@@ -30,9 +30,11 @@ class Chef
|
|
30
30
|
class ServerAPI < Chef::HTTP
|
31
31
|
|
32
32
|
def initialize(url = Chef::Config[:chef_server_url], options = {})
|
33
|
+
# # If making a change here, also update Chef::Knife::Raw::RawInputServerAPI.
|
33
34
|
options[:client_name] ||= Chef::Config[:node_name]
|
34
35
|
options[:raw_key] ||= Chef::Config[:client_key_contents]
|
35
36
|
options[:signing_key_filename] ||= Chef::Config[:client_key] unless options[:raw_key]
|
37
|
+
options[:ssh_agent_signing] ||= Chef::Config[:ssh_agent_signing]
|
36
38
|
options[:signing_key_filename] = nil if chef_zero_uri?(url)
|
37
39
|
options[:inflate_json_class] = false
|
38
40
|
super(url, options)
|
data/lib/chef/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright 2014-
|
2
|
+
# Copyright:: Copyright 2014-2018, Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -45,4 +45,30 @@ describe Chef::Mixin::ShellOut do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
describe "shell_out default_env: false" do
|
50
|
+
describe "when environment['LC_ALL'] is not set" do
|
51
|
+
it "should use the default shell_out setting" do
|
52
|
+
cmd = if windows?
|
53
|
+
shell_out("echo %LC_ALL%", default_env: false)
|
54
|
+
else
|
55
|
+
shell_out("echo $LC_ALL", default_env: false)
|
56
|
+
end
|
57
|
+
|
58
|
+
expect(cmd.stdout.chomp).to match_environment_variable("LC_ALL")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "when environment['LC_ALL'] is set" do
|
63
|
+
it "should use the option's setting" do
|
64
|
+
cmd = if windows?
|
65
|
+
shell_out("echo %LC_ALL%", :environment => { "LC_ALL" => "POSIX" }, default_env: false)
|
66
|
+
else
|
67
|
+
shell_out("echo $LC_ALL", :environment => { "LC_ALL" => "POSIX" }, default_env: false)
|
68
|
+
end
|
69
|
+
|
70
|
+
expect(cmd.stdout.chomp).to eq "POSIX"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
48
74
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Serdar Sutay (<serdar@chef.io>)
|
3
|
-
# Copyright:: Copyright 2014-
|
3
|
+
# Copyright:: Copyright 2014-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -51,7 +51,7 @@ describe Chef::Resource::Execute do
|
|
51
51
|
|
52
52
|
# why_run mode doesn't disable the updated_by_last_action logic, so we really have to look at the provider action
|
53
53
|
# to see if why_run correctly disabled the resource. It should shell_out! for the guard but not the resource.
|
54
|
-
expect_any_instance_of(Chef::Provider::Execute).to receive(:
|
54
|
+
expect_any_instance_of(Chef::Provider::Execute).to receive(:shell_out!).once
|
55
55
|
|
56
56
|
resource.only_if guard
|
57
57
|
resource.run_action(:run)
|
@@ -68,7 +68,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
|
|
68
68
|
current_resource = call_for_load_current_resource
|
69
69
|
expect(current_resource.exists).to eq(true)
|
70
70
|
expect(current_resource.task.application_name).to eq("chef-client")
|
71
|
-
expect(current_resource.task.parameters).to eq("-W -L C
|
71
|
+
expect(current_resource.task.parameters).to eq("-W -L C:\\\\chef\\\\chef-ad-join.log")
|
72
72
|
end
|
73
73
|
|
74
74
|
it "does not converge the resource if it is already converged" do
|
@@ -313,7 +313,7 @@ shared_examples_for "a securable resource without existing target" do
|
|
313
313
|
end
|
314
314
|
|
315
315
|
it "sets owner when owner is specified with a \\" do
|
316
|
-
resource.owner "#{ENV['
|
316
|
+
resource.owner "#{ENV['COMPUTERNAME']}\\Guest"
|
317
317
|
resource.run_action(:create)
|
318
318
|
expect(descriptor.owner).to eq(SID.Guest)
|
319
319
|
end
|