chef 12.13.37-universal-mingw32 → 12.14.60-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +48 -95
- data/Gemfile +6 -1
- data/README.md +9 -11
- data/VERSION +1 -1
- data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +0 -1
- data/acceptance/Gemfile +4 -7
- data/acceptance/Gemfile.lock +59 -92
- data/acceptance/basics/test/integration/helpers/serverspec/Gemfile +8 -0
- data/acceptance/data-collector/test/integration/helpers/serverspec/Gemfile +8 -0
- data/acceptance/fips/test/integration/fips-integration/serverspec/Gemfile +6 -0
- data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +4 -0
- data/chef.gemspec +3 -2
- data/lib/chef/application/client.rb +4 -4
- data/lib/chef/application/solo.rb +2 -2
- data/lib/chef/chef_fs/command_line.rb +36 -34
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -2
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +139 -137
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +2 -6
- data/lib/chef/cookbook/cookbook_version_loader.rb +27 -22
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +3 -3
- data/lib/chef/cookbook_site_streaming_uploader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +6 -6
- data/lib/chef/dsl/powershell.rb +1 -1
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_cache.rb +1 -1
- data/lib/chef/formatters/base.rb +2 -2
- data/lib/chef/formatters/doc.rb +2 -2
- data/lib/chef/http.rb +48 -18
- data/lib/chef/http/auth_credentials.rb +1 -1
- data/lib/chef/http/basic_client.rb +11 -2
- data/lib/chef/http/socketless_chef_zero_client.rb +2 -2
- data/lib/chef/key.rb +55 -56
- data/lib/chef/knife.rb +70 -61
- data/lib/chef/knife/client_delete.rb +2 -2
- data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
- data/lib/chef/knife/cookbook_show.rb +1 -1
- data/lib/chef/knife/core/gem_glob_loader.rb +3 -3
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +19 -21
- data/lib/chef/knife/status.rb +2 -2
- data/lib/chef/mixin/command/unix.rb +2 -2
- data/lib/chef/mixin/powershell_type_coercions.rb +1 -1
- data/lib/chef/mixin/properties.rb +3 -0
- data/lib/chef/mixin/securable.rb +2 -2
- data/lib/chef/mixin/shell_out.rb +30 -0
- data/lib/chef/mixin/uris.rb +2 -1
- data/lib/chef/mixin/windows_architecture_helper.rb +3 -4
- data/lib/chef/monkey_patches/webrick-utils.rb +2 -2
- data/lib/chef/monologger.rb +1 -1
- data/lib/chef/node.rb +2 -2
- data/lib/chef/node/attribute.rb +3 -3
- data/lib/chef/platform/provider_mapping.rb +5 -2
- data/lib/chef/property.rb +14 -3
- data/lib/chef/provider/apt_repository.rb +3 -7
- data/lib/chef/provider/apt_update.rb +4 -6
- data/lib/chef/provider/cron.rb +1 -2
- data/lib/chef/provider/dsc_script.rb +4 -4
- data/lib/chef/provider/group/usermod.rb +1 -1
- data/lib/chef/provider/link.rb +10 -3
- data/lib/chef/provider/osx_profile.rb +10 -10
- data/lib/chef/provider/package.rb +2 -12
- data/lib/chef/provider/package/rubygems.rb +17 -16
- data/lib/chef/provider/package/windows.rb +2 -0
- data/lib/chef/provider/package/windows/exe.rb +1 -1
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +0 -2
- data/lib/chef/provider/package/yum/rpm_utils.rb +8 -8
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/remote_file/ftp.rb +2 -2
- data/lib/chef/provider/remote_file/sftp.rb +2 -2
- data/lib/chef/provider/service/debian.rb +2 -2
- data/lib/chef/provider/service/simple.rb +4 -3
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +2 -2
- data/lib/chef/provider/service/upstart.rb +8 -5
- data/lib/chef/provider/support/yum_repo.erb +125 -0
- data/lib/chef/provider/systemd_unit.rb +11 -2
- data/lib/chef/provider/template_finder.rb +1 -1
- data/lib/chef/provider/user.rb +20 -16
- data/lib/chef/provider/user/aix.rb +5 -2
- data/lib/chef/provider/user/dscl.rb +1 -0
- data/lib/chef/provider/user/linux.rb +128 -0
- data/lib/chef/provider/user/pw.rb +2 -1
- data/lib/chef/provider/user/solaris.rb +3 -2
- data/lib/chef/provider/user/useradd.rb +5 -4
- data/lib/chef/provider/user/windows.rb +1 -1
- data/lib/chef/provider/windows_script.rb +5 -2
- data/lib/chef/provider/yum_repository.rb +121 -0
- data/lib/chef/providers.rb +4 -2
- data/lib/chef/resource.rb +7 -9
- data/lib/chef/resource/conditional.rb +9 -1
- data/lib/chef/resource/launchd.rb +1 -1
- data/lib/chef/resource/user.rb +3 -3
- data/lib/chef/resource/user/aix_user.rb +31 -0
- data/lib/chef/resource/user/dscl_user.rb +31 -0
- data/lib/chef/resource/user/linux_user.rb +51 -0
- data/lib/chef/resource/user/pw_user.rb +31 -0
- data/lib/chef/resource/user/solaris_user.rb +31 -0
- data/lib/chef/resource/user/windows_user.rb +31 -0
- data/lib/chef/resource/yum_package.rb +13 -12
- data/lib/chef/resource/yum_repository.rb +76 -0
- data/lib/chef/resource_builder.rb +1 -1
- data/lib/chef/resource_collection/stepable_iterator.rb +1 -3
- data/lib/chef/resource_reporter.rb +5 -5
- data/lib/chef/resources.rb +7 -0
- data/lib/chef/run_context.rb +5 -3
- data/lib/chef/run_context/cookbook_compiler.rb +3 -2
- data/lib/chef/run_list.rb +2 -2
- data/lib/chef/search/query.rb +11 -8
- data/lib/chef/shell/ext.rb +2 -2
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/util/powershell/cmdlet.rb +5 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +2 -2
- data/lib/chef/version_constraint.rb +2 -2
- data/lib/chef/win32/api/error.rb +2 -2
- data/lib/chef/win32/api/net.rb +1 -1
- data/lib/chef/win32/eventlog.rb +1 -1
- data/lib/chef/win32/net.rb +1 -1
- data/lib/chef/win32/security/sid.rb +1 -1
- data/spec/functional/assets/testchefsubsys +2 -3
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +11 -8
- data/spec/functional/file_content_management/deploy_strategies_spec.rb +1 -1
- data/spec/functional/http/simple_spec.rb +2 -2
- data/spec/functional/knife/cookbook_delete_spec.rb +5 -5
- data/spec/functional/knife/exec_spec.rb +6 -6
- data/spec/functional/knife/ssh_spec.rb +4 -4
- data/spec/functional/notifications_spec.rb +2 -2
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +5 -5
- data/spec/functional/resource/bash_spec.rb +2 -2
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dpkg_package_spec.rb +2 -2
- data/spec/functional/resource/dsc_resource_spec.rb +5 -5
- data/spec/functional/resource/dsc_script_spec.rb +27 -22
- data/spec/functional/resource/env_spec.rb +4 -4
- data/spec/functional/resource/execute_spec.rb +4 -4
- data/spec/functional/resource/group_spec.rb +20 -8
- data/spec/functional/resource/link_spec.rb +34 -0
- data/spec/functional/resource/ohai_spec.rb +6 -6
- data/spec/functional/resource/reboot_spec.rb +2 -2
- data/spec/functional/resource/remote_file_spec.rb +16 -7
- data/spec/functional/resource/user/dscl_spec.rb +3 -3
- data/spec/functional/resource/user/useradd_spec.rb +32 -26
- data/spec/functional/resource/windows_service_spec.rb +15 -15
- data/spec/functional/rest_spec.rb +2 -2
- data/spec/functional/run_lock_spec.rb +9 -9
- data/spec/functional/tiny_server_spec.rb +9 -8
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +8 -8
- data/spec/integration/client/client_spec.rb +6 -4
- data/spec/integration/knife/chef_repo_path_spec.rb +70 -1
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +6 -6
- data/spec/integration/recipes/noop_resource_spec.rb +4 -4
- data/spec/integration/recipes/provider_choice.rb +3 -3
- data/spec/integration/recipes/recipe_dsl_spec.rb +318 -317
- data/spec/integration/recipes/resource_action_spec.rb +50 -54
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +34 -34
- data/spec/integration/recipes/resource_load_spec.rb +24 -24
- data/spec/integration/solo/solo_spec.rb +21 -30
- data/spec/scripts/ssl-serve.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/stress/win32/security_spec.rb +4 -4
- data/spec/support/chef_helpers.rb +22 -0
- data/spec/support/platform_helpers.rb +5 -1
- data/spec/support/shared/context/client.rb +3 -2
- data/spec/support/shared/functional/file_resource.rb +5 -4
- data/spec/support/shared/functional/http.rb +16 -16
- data/spec/support/shared/functional/securable_resource.rb +5 -5
- data/spec/support/shared/functional/win32_service.rb +5 -7
- data/spec/support/shared/integration/app_server_support.rb +1 -3
- data/spec/support/shared/integration/knife_support.rb +0 -2
- data/spec/support/shared/shared_examples.rb +2 -2
- data/spec/support/shared/unit/api_versioning.rb +2 -2
- data/spec/support/shared/unit/application_dot_d.rb +9 -6
- data/spec/support/shared/unit/provider/file.rb +2 -2
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +49 -80
- data/spec/support/shared/unit/resource/static_provider_resolution.rb +2 -2
- data/spec/support/shared/unit/script_resource.rb +4 -4
- data/spec/support/shared/unit/user_and_client_shared.rb +4 -4
- data/spec/tiny_server.rb +51 -66
- data/spec/unit/api_client_v1_spec.rb +2 -2
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/audit/audit_event_proxy_spec.rb +34 -27
- data/spec/unit/audit/audit_reporter_spec.rb +32 -23
- data/spec/unit/audit/control_group_data_spec.rb +19 -14
- data/spec/unit/chef_class_spec.rb +1 -1
- data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +1 -1
- data/spec/unit/chef_fs/diff_spec.rb +4 -4
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +4 -4
- data/spec/unit/chef_fs/file_system_spec.rb +2 -2
- data/spec/unit/chef_fs/parallelizer.rb +5 -7
- data/spec/unit/cookbook/metadata_spec.rb +98 -98
- data/spec/unit/cookbook/synchronizer_spec.rb +7 -0
- data/spec/unit/cookbook_loader_spec.rb +24 -24
- data/spec/unit/cookbook_version_file_specificity_spec.rb +8 -8
- data/spec/unit/daemon_spec.rb +1 -1
- data/spec/unit/data_bag_item_spec.rb +18 -18
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector/messages/helpers_spec.rb +9 -9
- data/spec/unit/data_collector/messages_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +19 -19
- data/spec/unit/dsl/audit_spec.rb +3 -3
- data/spec/unit/dsl/data_query_spec.rb +3 -2
- data/spec/unit/dsl/declare_resource_spec.rb +10 -10
- data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +3 -2
- data/spec/unit/encrypted_data_bag_item_spec.rb +3 -2
- data/spec/unit/environment_spec.rb +6 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +2 -2
- data/spec/unit/file_access_control_spec.rb +3 -3
- data/spec/unit/file_content_management/tempfile_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +2 -2
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +2 -2
- data/spec/unit/http/basic_client_spec.rb +20 -0
- data/spec/unit/http/validate_content_length_spec.rb +8 -8
- data/spec/unit/http_spec.rb +14 -0
- data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +2 -2
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +2 -2
- data/spec/unit/knife/bootstrap_spec.rb +8 -6
- data/spec/unit/knife/client_bulk_delete_spec.rb +8 -8
- data/spec/unit/knife/client_edit_spec.rb +2 -2
- data/spec/unit/knife/configure_client_spec.rb +2 -2
- data/spec/unit/knife/cookbook_metadata_spec.rb +4 -4
- data/spec/unit/knife/cookbook_site_install_spec.rb +6 -5
- data/spec/unit/knife/cookbook_site_share_spec.rb +2 -2
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +5 -4
- data/spec/unit/knife/core/node_editor_spec.rb +3 -3
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +4 -3
- data/spec/unit/knife/data_bag_show_spec.rb +3 -2
- data/spec/unit/knife/key_create_spec.rb +14 -14
- data/spec/unit/knife/key_delete_spec.rb +2 -2
- data/spec/unit/knife/key_edit_spec.rb +16 -16
- data/spec/unit/knife/key_list_spec.rb +6 -6
- data/spec/unit/knife/key_show_spec.rb +4 -4
- data/spec/unit/knife/status_spec.rb +3 -2
- data/spec/unit/knife/user_create_spec.rb +4 -4
- data/spec/unit/knife_spec.rb +7 -6
- data/spec/unit/lwrp_spec.rb +6 -6
- data/spec/unit/mixin/api_version_request_handling_spec.rb +2 -2
- data/spec/unit/mixin/command_spec.rb +17 -14
- data/spec/unit/mixin/deprecation_spec.rb +1 -1
- data/spec/unit/mixin/homebrew_user_spec.rb +2 -2
- data/spec/unit/mixin/params_validate_spec.rb +53 -52
- data/spec/unit/mixin/powershell_out_spec.rb +2 -2
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +2 -2
- data/spec/unit/mixin/shell_out_spec.rb +1 -1
- data/spec/unit/mixin/xml_escape_spec.rb +3 -3
- data/spec/unit/node_spec.rb +2 -2
- data/spec/unit/platform/query_helpers_spec.rb +3 -3
- data/spec/unit/property_spec.rb +4 -4
- data/spec/unit/provider/cookbook_file_spec.rb +4 -4
- data/spec/unit/provider/cron/unix_spec.rb +4 -4
- data/spec/unit/provider/cron_spec.rb +2 -2
- data/spec/unit/provider/deploy_spec.rb +8 -8
- data/spec/unit/provider/dsc_resource_spec.rb +11 -10
- data/spec/unit/provider/dsc_script_spec.rb +9 -9
- data/spec/unit/provider/env/windows_spec.rb +8 -8
- data/spec/unit/provider/file/content_spec.rb +6 -6
- data/spec/unit/provider/file_spec.rb +4 -4
- data/spec/unit/provider/launchd_spec.rb +2 -1
- data/spec/unit/provider/link_spec.rb +155 -0
- data/spec/unit/provider/mount/mount_spec.rb +5 -5
- data/spec/unit/provider/mount/solaris_spec.rb +48 -48
- data/spec/unit/provider/osx_profile_spec.rb +6 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +4 -4
- data/spec/unit/provider/package/freebsd/port_spec.rb +4 -4
- data/spec/unit/provider/package/rubygems_spec.rb +50 -44
- data/spec/unit/provider/package/windows/exe_spec.rb +9 -0
- data/spec/unit/provider/package/yum_spec.rb +61 -60
- data/spec/unit/provider/package_spec.rb +2 -2
- data/spec/unit/provider/powershell_script_spec.rb +4 -4
- data/spec/unit/provider/remote_directory_spec.rb +1 -1
- data/spec/unit/provider/remote_file/ftp_spec.rb +4 -4
- data/spec/unit/provider/remote_file/local_file_spec.rb +4 -2
- data/spec/unit/provider/remote_file/sftp_spec.rb +4 -4
- data/spec/unit/provider/remote_file_spec.rb +4 -4
- data/spec/unit/provider/script_spec.rb +4 -4
- data/spec/unit/provider/service/debian_service_spec.rb +4 -4
- data/spec/unit/provider/service/freebsd_service_spec.rb +12 -8
- data/spec/unit/provider/service/openbsd_service_spec.rb +12 -8
- data/spec/unit/provider/service/systemd_service_spec.rb +4 -4
- data/spec/unit/provider/service/upstart_service_spec.rb +27 -12
- data/spec/unit/provider/service/windows_spec.rb +10 -10
- data/spec/unit/provider/systemd_unit_spec.rb +2 -2
- data/spec/unit/provider/template/content_spec.rb +8 -8
- data/spec/unit/provider/template_spec.rb +8 -8
- data/spec/unit/provider/user/dscl_spec.rb +51 -51
- data/spec/unit/provider/user/linux_spec.rb +76 -0
- data/spec/unit/provider/user/pw_spec.rb +3 -6
- data/spec/unit/provider/user/solaris_spec.rb +5 -5
- data/spec/unit/provider/user/windows_spec.rb +3 -3
- data/spec/unit/provider/user_spec.rb +2 -2
- data/spec/unit/provider/yum_repository_spec.rb +35 -0
- data/spec/unit/provider_resolver_spec.rb +306 -264
- data/spec/unit/recipe_spec.rb +8 -7
- data/spec/unit/resource/apt_repository_spec.rb +4 -4
- data/spec/unit/resource/apt_update_spec.rb +4 -4
- data/spec/unit/resource/conditional_spec.rb +46 -0
- data/spec/unit/resource/dsc_resource_spec.rb +8 -8
- data/spec/unit/resource/dsc_script_spec.rb +4 -4
- data/spec/unit/resource/freebsd_package_spec.rb +6 -6
- data/spec/unit/resource/launchd_spec.rb +3 -2
- data/spec/unit/resource/osx_profile_spec.rb +3 -2
- data/spec/unit/resource/remote_file_spec.rb +6 -6
- data/spec/unit/resource/service_spec.rb +14 -14
- data/spec/unit/resource/user_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +49 -0
- data/spec/unit/resource_collection_spec.rb +4 -4
- data/spec/unit/resource_definition_spec.rb +11 -11
- data/spec/unit/resource_reporter_spec.rb +4 -4
- data/spec/unit/resource_resolver_spec.rb +6 -6
- data/spec/unit/resource_spec.rb +36 -16
- data/spec/unit/run_context/child_run_context_spec.rb +4 -4
- data/spec/unit/run_context/cookbook_compiler_spec.rb +43 -1
- data/spec/unit/run_context_spec.rb +8 -8
- data/spec/unit/run_list/run_list_expansion_spec.rb +2 -2
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/search/query_spec.rb +15 -14
- data/spec/unit/user_v1_spec.rb +8 -8
- data/spec/unit/util/dsc/configuration_generator_spec.rb +12 -12
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +12 -9
- data/spec/unit/util/dsc/resource_store.rb +8 -6
- data/spec/unit/util/editor_spec.rb +6 -6
- data/spec/unit/util/powershell/cmdlet_spec.rb +10 -10
- data/tasks/bin/bundle-platform +1 -0
- data/tasks/bin/bundler_patch.rb +27 -0
- data/tasks/cbgb.rb +2 -2
- data/tasks/maintainers.rb +2 -2
- metadata +37 -8
- data/spec/unit/provider/user/useradd_spec.rb +0 -51
@@ -14,11 +14,14 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
+
require "chef/provider/user/useradd"
|
18
|
+
|
17
19
|
class Chef
|
18
20
|
class Provider
|
19
21
|
class User
|
20
22
|
class Aix < Chef::Provider::User::Useradd
|
21
|
-
provides :user,
|
23
|
+
provides :user, os: "aix"
|
24
|
+
provides :aix_user
|
22
25
|
|
23
26
|
UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]]
|
24
27
|
|
@@ -66,7 +69,7 @@ class Chef
|
|
66
69
|
shell_out!("chuser account_locked=false #{new_resource.username}")
|
67
70
|
end
|
68
71
|
|
69
|
-
|
72
|
+
private
|
70
73
|
|
71
74
|
def add_password
|
72
75
|
if @current_resource.password != @new_resource.password && @new_resource.password
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2016, 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
|
+
require "chef/provider/user"
|
18
|
+
|
19
|
+
class Chef
|
20
|
+
class Provider
|
21
|
+
class User
|
22
|
+
class Linux < Chef::Provider::User
|
23
|
+
provides :linux_user
|
24
|
+
provides :user, os: "linux"
|
25
|
+
|
26
|
+
def create_user
|
27
|
+
shell_out!(*clean_array("useradd", universal_options, useradd_options, new_resource.username))
|
28
|
+
end
|
29
|
+
|
30
|
+
def manage_user
|
31
|
+
shell_out!(*clean_array("usermod", universal_options, usermod_options, new_resource.username))
|
32
|
+
end
|
33
|
+
|
34
|
+
def remove_user
|
35
|
+
shell_out!(*clean_array("userdel", userdel_options, new_resource.username))
|
36
|
+
end
|
37
|
+
|
38
|
+
def lock_user
|
39
|
+
shell_out!(*clean_array("usermod", "-L", new_resource.username))
|
40
|
+
end
|
41
|
+
|
42
|
+
def unlock_user
|
43
|
+
shell_out!(*clean_array("usermod", "-U", new_resource.username))
|
44
|
+
end
|
45
|
+
|
46
|
+
# common to usermod and useradd
|
47
|
+
def universal_options
|
48
|
+
opts = []
|
49
|
+
opts << "-c" << new_resource.comment if should_set?(:comment)
|
50
|
+
opts << "-g" << new_resource.gid if should_set?(:gid)
|
51
|
+
opts << "-p" << new_resource.password if should_set?(:password)
|
52
|
+
opts << "-s" << new_resource.shell if should_set?(:shell)
|
53
|
+
opts << "-u" << new_resource.uid if should_set?(:uid)
|
54
|
+
opts << "-d" << new_resource.home if updating_home?
|
55
|
+
opts << "-o" if new_resource.non_unique
|
56
|
+
opts
|
57
|
+
end
|
58
|
+
|
59
|
+
def usermod_options
|
60
|
+
opts = []
|
61
|
+
if updating_home?
|
62
|
+
if new_resource.manage_home
|
63
|
+
opts << "-m"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
opts
|
67
|
+
end
|
68
|
+
|
69
|
+
def useradd_options
|
70
|
+
opts = []
|
71
|
+
opts << "-r" if new_resource.system
|
72
|
+
if new_resource.manage_home
|
73
|
+
opts << "-m"
|
74
|
+
else
|
75
|
+
opts << "-M"
|
76
|
+
end
|
77
|
+
opts
|
78
|
+
end
|
79
|
+
|
80
|
+
def userdel_options
|
81
|
+
opts = []
|
82
|
+
opts << "-r" if new_resource.manage_home
|
83
|
+
opts << "-f" if new_resource.force
|
84
|
+
opts
|
85
|
+
end
|
86
|
+
|
87
|
+
def should_set?(sym)
|
88
|
+
current_resource.send(sym).to_s != new_resource.send(sym).to_s && new_resource.send(sym)
|
89
|
+
end
|
90
|
+
|
91
|
+
def updating_home?
|
92
|
+
return false unless new_resource.home
|
93
|
+
return true unless current_resource.home
|
94
|
+
new_resource.home && Pathname.new(current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath
|
95
|
+
end
|
96
|
+
|
97
|
+
def check_lock
|
98
|
+
# there's an old bug in rhel (https://bugzilla.redhat.com/show_bug.cgi?id=578534)
|
99
|
+
# which means that both 0 and 1 can be success.
|
100
|
+
passwd_s = shell_out("passwd", "-S", new_resource.username, returns: [ 0, 1 ])
|
101
|
+
|
102
|
+
# checking "does not exist" has to come before exit code handling since centos and ubuntu differ in exit codes
|
103
|
+
if passwd_s.stderr =~ /does not exist/
|
104
|
+
if whyrun_mode?
|
105
|
+
return false
|
106
|
+
else
|
107
|
+
raise Chef::Exceptions::User, "User #{new_resource.username} does not exist when checking lock status for #{new_resource}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# now raise if we didn't get a 0 or 1 (see above)
|
112
|
+
passwd_s.error!
|
113
|
+
|
114
|
+
# now the actual output parsing
|
115
|
+
@locked = nil
|
116
|
+
status_line = passwd_s.stdout.split(" ")
|
117
|
+
@locked = false if status_line[1] =~ /^[PN]/
|
118
|
+
@locked = true if status_line[1] =~ /^L/
|
119
|
+
|
120
|
+
raise Chef::Exceptions::User, "Cannot determine if user #{new_resource.username} is locked for #{new_resource}" if @locked.nil?
|
121
|
+
|
122
|
+
# FIXME: should probably go on the current_resource
|
123
|
+
@locked
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -24,7 +24,8 @@ class Chef
|
|
24
24
|
class Provider
|
25
25
|
class User
|
26
26
|
class Solaris < Chef::Provider::User::Useradd
|
27
|
-
provides :
|
27
|
+
provides :solaris_user
|
28
|
+
provides :user, os: %w{omnios solaris2}
|
28
29
|
UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]]
|
29
30
|
|
30
31
|
attr_writer :password_file
|
@@ -70,7 +71,7 @@ class Chef
|
|
70
71
|
shell_out!("passwd", "-u", new_resource.username)
|
71
72
|
end
|
72
73
|
|
73
|
-
|
74
|
+
private
|
74
75
|
|
75
76
|
def manage_password
|
76
77
|
if @current_resource.password != @new_resource.password && @new_resource.password
|
@@ -23,7 +23,7 @@ class Chef
|
|
23
23
|
class Provider
|
24
24
|
class User
|
25
25
|
class Useradd < Chef::Provider::User
|
26
|
-
|
26
|
+
# MAJOR XXX: this should become the base class of all Useradd providers instead of the linux implementation
|
27
27
|
|
28
28
|
UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:password, "-p"], [:shell, "-s"], [:uid, "-u"]]
|
29
29
|
|
@@ -116,15 +116,15 @@ class Chef
|
|
116
116
|
update_options(field, option, opts)
|
117
117
|
end
|
118
118
|
if updating_home?
|
119
|
+
opts << "-d" << new_resource.home
|
119
120
|
if managing_home_dir?
|
120
121
|
Chef::Log.debug("#{new_resource} managing the users home directory")
|
121
|
-
opts << "-
|
122
|
+
opts << "-m"
|
122
123
|
else
|
123
124
|
Chef::Log.debug("#{new_resource} setting home to #{new_resource.home}")
|
124
|
-
opts << "-d" << new_resource.home
|
125
125
|
end
|
126
126
|
end
|
127
|
-
opts << "-o" if new_resource.non_unique
|
127
|
+
opts << "-o" if new_resource.non_unique
|
128
128
|
opts
|
129
129
|
end
|
130
130
|
end
|
@@ -141,6 +141,7 @@ class Chef
|
|
141
141
|
def useradd_options
|
142
142
|
opts = []
|
143
143
|
opts << "-r" if new_resource.system
|
144
|
+
opts << "-M" unless managing_home_dir?
|
144
145
|
opts
|
145
146
|
end
|
146
147
|
|
@@ -33,8 +33,11 @@ class Chef
|
|
33
33
|
super( new_resource, run_context )
|
34
34
|
@script_extension = script_extension
|
35
35
|
|
36
|
-
target_architecture = new_resource.architecture.nil?
|
37
|
-
|
36
|
+
target_architecture = if new_resource.architecture.nil?
|
37
|
+
node_windows_architecture(run_context.node)
|
38
|
+
else
|
39
|
+
new_resource.architecture
|
40
|
+
end
|
38
41
|
|
39
42
|
@is_wow64 = wow64_architecture_override_required?(run_context.node, target_architecture)
|
40
43
|
|
@@ -0,0 +1,121 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Thom May (<thom@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2016 Chef Software, Inc.
|
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 "chef/resource"
|
20
|
+
require "chef/dsl/declare_resource"
|
21
|
+
require "chef/mixin/shell_out"
|
22
|
+
require "chef/mixin/which"
|
23
|
+
require "chef/http/simple"
|
24
|
+
require "chef/provider/noop"
|
25
|
+
|
26
|
+
class Chef
|
27
|
+
class Provider
|
28
|
+
class YumRepository < Chef::Provider
|
29
|
+
use_inline_resources
|
30
|
+
|
31
|
+
extend Chef::Mixin::Which
|
32
|
+
|
33
|
+
provides :yum_repository do
|
34
|
+
which "yum"
|
35
|
+
end
|
36
|
+
|
37
|
+
def whyrun_supported?; true; end
|
38
|
+
|
39
|
+
def load_current_resource; end
|
40
|
+
|
41
|
+
action :create do
|
42
|
+
declare_resource(:template, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
|
43
|
+
if template_available?(new_resource.source)
|
44
|
+
source new_resource.source
|
45
|
+
else
|
46
|
+
source ::File.expand_path("../support/yum_repo.erb", __FILE__)
|
47
|
+
local true
|
48
|
+
end
|
49
|
+
sensitive new_resource.sensitive
|
50
|
+
variables(config: new_resource)
|
51
|
+
mode new_resource.mode
|
52
|
+
if new_resource.make_cache
|
53
|
+
notifies :run, "execute[yum clean metadata #{new_resource.repositoryid}]", :immediately if new_resource.clean_metadata || new_resource.clean_headers
|
54
|
+
notifies :run, "execute[yum-makecache-#{new_resource.repositoryid}]", :immediately
|
55
|
+
notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
declare_resource(:execute, "yum clean metadata #{new_resource.repositoryid}") do
|
60
|
+
command "yum clean metadata --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
|
61
|
+
action :nothing
|
62
|
+
end
|
63
|
+
|
64
|
+
# get the metadata for this repo only
|
65
|
+
declare_resource(:execute, "yum-makecache-#{new_resource.repositoryid}") do
|
66
|
+
command "yum -q -y makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
|
67
|
+
action :nothing
|
68
|
+
only_if { new_resource.enabled }
|
69
|
+
end
|
70
|
+
|
71
|
+
# reload internal Chef yum cache
|
72
|
+
declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
|
73
|
+
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
74
|
+
action :nothing
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
action :delete do
|
79
|
+
declare_resource(:file, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
|
80
|
+
action :delete
|
81
|
+
notifies :run, "execute[yum clean all #{new_resource.repositoryid}]", :immediately
|
82
|
+
notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
|
83
|
+
end
|
84
|
+
|
85
|
+
declare_resource(:execute, "yum clean all #{new_resource.repositoryid}") do
|
86
|
+
command "yum clean all --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
|
87
|
+
only_if "yum repolist | grep -P '^#{new_resource.repositoryid}([ \t]|$)'"
|
88
|
+
action :nothing
|
89
|
+
end
|
90
|
+
|
91
|
+
declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
|
92
|
+
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
93
|
+
action :nothing
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
action :makecache do
|
98
|
+
declare_resource(:execute, "yum-makecache-#{new_resource.repositoryid}") do
|
99
|
+
command "yum -q -y makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
|
100
|
+
action :run
|
101
|
+
only_if { new_resource.enabled }
|
102
|
+
end
|
103
|
+
|
104
|
+
declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
|
105
|
+
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
106
|
+
action :run
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
alias_method :action_add, :action_create
|
111
|
+
alias_method :action_remove, :action_delete
|
112
|
+
|
113
|
+
def template_available?(path)
|
114
|
+
!path.nil? && run_context.has_template_in_cookbook?(new_resource.cookbook_name, path)
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
Chef::Provider::Noop.provides :yum_repository
|
data/lib/chef/providers.rb
CHANGED
@@ -58,6 +58,7 @@ require "chef/provider/systemd_unit"
|
|
58
58
|
require "chef/provider/template"
|
59
59
|
require "chef/provider/user"
|
60
60
|
require "chef/provider/whyrun_safe_ruby_block"
|
61
|
+
require "chef/provider/yum_repository"
|
61
62
|
|
62
63
|
require "chef/provider/env/windows"
|
63
64
|
|
@@ -101,12 +102,13 @@ require "chef/provider/service/macosx"
|
|
101
102
|
require "chef/provider/service/aixinit"
|
102
103
|
require "chef/provider/service/aix"
|
103
104
|
|
105
|
+
require "chef/provider/user/aix"
|
104
106
|
require "chef/provider/user/dscl"
|
107
|
+
require "chef/provider/user/linux"
|
105
108
|
require "chef/provider/user/pw"
|
109
|
+
require "chef/provider/user/solaris"
|
106
110
|
require "chef/provider/user/useradd"
|
107
111
|
require "chef/provider/user/windows"
|
108
|
-
require "chef/provider/user/solaris"
|
109
|
-
require "chef/provider/user/aix"
|
110
112
|
|
111
113
|
require "chef/provider/group/aix"
|
112
114
|
require "chef/provider/group/dscl"
|
data/lib/chef/resource.rb
CHANGED
@@ -497,7 +497,7 @@ class Chef
|
|
497
497
|
state_properties = self.class.state_properties
|
498
498
|
state_properties.each do |property|
|
499
499
|
if property.identity? || property.is_set?(self)
|
500
|
-
state[property.name] = send(property.name)
|
500
|
+
state[property.name] = property.sensitive? ? "*sensitive value suppressed*" : send(property.name)
|
501
501
|
end
|
502
502
|
end
|
503
503
|
state
|
@@ -1276,15 +1276,15 @@ class Chef
|
|
1276
1276
|
# resolve_resource_reference on each in turn, causing them to
|
1277
1277
|
# resolve lazy/forward references.
|
1278
1278
|
def resolve_notification_references
|
1279
|
-
run_context.before_notifications(self).each
|
1279
|
+
run_context.before_notifications(self).each do |n|
|
1280
1280
|
n.resolve_resource_reference(run_context.resource_collection)
|
1281
|
-
|
1282
|
-
run_context.immediate_notifications(self).each
|
1281
|
+
end
|
1282
|
+
run_context.immediate_notifications(self).each do |n|
|
1283
1283
|
n.resolve_resource_reference(run_context.resource_collection)
|
1284
|
-
|
1285
|
-
run_context.delayed_notifications(self).each
|
1284
|
+
end
|
1285
|
+
run_context.delayed_notifications(self).each do |n|
|
1286
1286
|
n.resolve_resource_reference(run_context.resource_collection)
|
1287
|
-
|
1287
|
+
end
|
1288
1288
|
end
|
1289
1289
|
|
1290
1290
|
# Helper for #notifies
|
@@ -1575,8 +1575,6 @@ class Chef
|
|
1575
1575
|
end
|
1576
1576
|
end
|
1577
1577
|
|
1578
|
-
private
|
1579
|
-
|
1580
1578
|
def self.remove_canonical_dsl
|
1581
1579
|
if @resource_name
|
1582
1580
|
remaining = Chef.resource_handler_map.delete_canonical(@resource_name, self)
|
@@ -103,7 +103,15 @@ class Chef
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def evaluate_block
|
106
|
-
@block.call
|
106
|
+
@block.call.tap do |rv|
|
107
|
+
if rv.is_a?(String) && !rv.empty?
|
108
|
+
# This is probably a mistake:
|
109
|
+
# not_if { "command" }
|
110
|
+
sanitized_rv = @parent_resource.sensitive ? "a string" : rv.inspect
|
111
|
+
Chef::Log.warn("#{@positivity} block for #{@parent_resource} returned #{sanitized_rv}, did you mean to run a command?" +
|
112
|
+
(@parent_resource.sensitive ? "" : " If so use '#{@positivity} #{sanitized_rv}' in your code."))
|
113
|
+
end
|
114
|
+
end
|
107
115
|
end
|
108
116
|
|
109
117
|
def short_description
|