chef 12.10.24-universal-mingw32 → 12.11.18-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 +3 -38
- data/Gemfile +6 -11
- data/LICENSE +201 -201
- data/README.md +11 -1
- data/VERSION +1 -1
- data/acceptance/.bundle/config +2 -0
- data/acceptance/Gemfile.lock +27 -26
- data/acceptance/basics/.kitchen/logs/chef-current-install-ubuntu-1404.log +2 -0
- data/acceptance/basics/.kitchen/logs/kitchen.log +3 -0
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/.gitignore +2 -0
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/metadata.rb +3 -0
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/recipes/destroy.rb +2 -0
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/recipes/provision.rb +2 -0
- data/acceptance/data-collector/.acceptance/acceptance-cookbook/recipes/verify.rb +2 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/.gitignore +16 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/Berksfile +3 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb +85 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/apigemfile +3 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-both-mode.rb +4 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-client-mode.rb +4 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-no-endpoint.rb +2 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-solo-mode.rb +4 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/files/default/config.ru +2 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/metadata.rb +7 -0
- data/acceptance/data-collector/.acceptance/data-collector-test/recipes/default.rb +38 -0
- data/acceptance/data-collector/.kitchen.yml +9 -0
- data/acceptance/data-collector/Berksfile +3 -0
- data/acceptance/data-collector/Berksfile.lock +6 -0
- data/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb +251 -0
- data/acceptance/fips/.kitchen/logs/fips-integration-centos-6.log +3 -0
- data/acceptance/fips/.kitchen/logs/fips-integration-windows-2012r2.log +3 -0
- data/acceptance/fips/.kitchen/logs/fips-unit-functional-centos-6.log +3 -0
- data/acceptance/fips/.kitchen/logs/fips-unit-functional-windows-2012r2.log +3 -0
- data/acceptance/fips/.kitchen/logs/kitchen.log +6 -0
- data/acceptance/fips/test/integration/fips-integration/serverspec/fips-integration_spec.rb +2 -1
- data/acceptance/top-cookbooks/.kitchen.docker.yml +1 -4
- data/acceptance/trivial/.kitchen/logs/chef-current-install-windows-2012r2.log +2 -0
- data/acceptance/trivial/.kitchen/logs/kitchen.log +3 -0
- data/acceptance/windows-service/.kitchen/logs/chef-windows-service-windows-2012r2.log +2 -0
- data/acceptance/windows-service/.kitchen/logs/kitchen.log +3 -0
- data/bin/chef-apply +0 -0
- data/bin/chef-client +0 -0
- data/bin/chef-service-manager +0 -0
- data/bin/chef-shell +0 -0
- data/bin/chef-solo +0 -0
- data/bin/chef-windows-service +0 -0
- data/bin/knife +0 -0
- data/chef.gemspec +1 -0
- data/distro/common/html/_sources/ctl_chef_client.txt +35 -35
- data/distro/common/html/_sources/ctl_chef_server.txt +341 -341
- data/distro/common/html/_sources/ctl_chef_shell.txt +15 -15
- data/distro/common/html/_sources/ctl_chef_solo.txt +25 -25
- data/distro/common/html/_sources/index.txt +135 -135
- data/distro/common/html/_sources/knife.txt +74 -74
- data/distro/common/html/_sources/knife_bootstrap.txt +56 -56
- data/distro/common/html/_sources/knife_client.txt +150 -150
- data/distro/common/html/_sources/knife_common_options.txt +6 -6
- data/distro/common/html/_sources/knife_configure.txt +29 -29
- data/distro/common/html/_sources/knife_cookbook.txt +236 -236
- data/distro/common/html/_sources/knife_cookbook_site.txt +157 -157
- data/distro/common/html/_sources/knife_data_bag.txt +159 -159
- data/distro/common/html/_sources/knife_delete.txt +26 -26
- data/distro/common/html/_sources/knife_deps.txt +61 -61
- data/distro/common/html/_sources/knife_diff.txt +34 -34
- data/distro/common/html/_sources/knife_download.txt +44 -44
- data/distro/common/html/_sources/knife_edit.txt +26 -26
- data/distro/common/html/_sources/knife_environment.txt +158 -158
- data/distro/common/html/_sources/knife_exec.txt +47 -47
- data/distro/common/html/_sources/knife_index_rebuild.txt +20 -20
- data/distro/common/html/_sources/knife_list.txt +33 -33
- data/distro/common/html/_sources/knife_node.txt +250 -250
- data/distro/common/html/_sources/knife_raw.txt +35 -35
- data/distro/common/html/_sources/knife_recipe_list.txt +23 -23
- data/distro/common/html/_sources/knife_role.txt +157 -157
- data/distro/common/html/_sources/knife_search.txt +53 -53
- data/distro/common/html/_sources/knife_serve.txt +18 -18
- data/distro/common/html/_sources/knife_show.txt +26 -26
- data/distro/common/html/_sources/knife_ssh.txt +43 -43
- data/distro/common/html/_sources/knife_ssl_check.txt +41 -41
- data/distro/common/html/_sources/knife_ssl_fetch.txt +41 -41
- data/distro/common/html/_sources/knife_status.txt +37 -37
- data/distro/common/html/_sources/knife_tag.txt +69 -69
- data/distro/common/html/_sources/knife_upload.txt +49 -49
- data/distro/common/html/_sources/knife_user.txt +127 -127
- data/distro/common/html/_sources/knife_using.txt +43 -43
- data/distro/common/html/_sources/knife_xargs.txt +30 -30
- data/distro/common/html/_static/guide.css +504 -504
- data/distro/common/html/_static/pygments.css +61 -61
- data/distro/common/html/_static/underscore.js +31 -31
- data/distro/common/html/ctl_chef_client.html +269 -269
- data/distro/common/html/ctl_chef_server.html +727 -727
- data/distro/common/html/ctl_chef_shell.html +162 -162
- data/distro/common/html/ctl_chef_solo.html +193 -193
- data/distro/common/html/index.html +201 -201
- data/distro/common/html/knife.html +169 -169
- data/distro/common/html/knife_bootstrap.html +284 -284
- data/distro/common/html/knife_client.html +284 -284
- data/distro/common/html/knife_common_options.html +95 -95
- data/distro/common/html/knife_configure.html +104 -104
- data/distro/common/html/knife_cookbook.html +486 -486
- data/distro/common/html/knife_data_bag.html +373 -373
- data/distro/common/html/knife_delete.html +92 -92
- data/distro/common/html/knife_deps.html +142 -142
- data/distro/common/html/knife_diff.html +122 -122
- data/distro/common/html/knife_download.html +144 -144
- data/distro/common/html/knife_edit.html +88 -88
- data/distro/common/html/knife_environment.html +325 -325
- data/distro/common/html/knife_exec.html +219 -219
- data/distro/common/html/knife_index_rebuild.html +82 -82
- data/distro/common/html/knife_list.html +113 -113
- data/distro/common/html/knife_node.html +457 -457
- data/distro/common/html/knife_raw.html +109 -109
- data/distro/common/html/knife_recipe_list.html +90 -90
- data/distro/common/html/knife_role.html +294 -294
- data/distro/common/html/knife_search.html +202 -202
- data/distro/common/html/knife_serve.html +78 -78
- data/distro/common/html/knife_show.html +103 -103
- data/distro/common/html/knife_ssh.html +176 -176
- data/distro/common/html/knife_ssl_check.html +150 -150
- data/distro/common/html/knife_ssl_fetch.html +150 -150
- data/distro/common/html/knife_status.html +143 -143
- data/distro/common/html/knife_tag.html +137 -137
- data/distro/common/html/knife_upload.html +152 -152
- data/distro/common/html/knife_user.html +241 -241
- data/distro/common/html/knife_using.html +209 -209
- data/distro/common/html/knife_xargs.html +121 -121
- data/distro/common/html/search.html +81 -81
- data/distro/common/man/man1/README.md +58 -58
- data/distro/common/man/man1/chef-shell.1 +194 -194
- data/distro/common/man/man1/knife-bootstrap.1 +215 -215
- data/distro/common/man/man1/knife-client.1 +443 -443
- data/distro/common/man/man1/knife-configure.1 +161 -161
- data/distro/common/man/man1/knife-cookbook.1 +770 -770
- data/distro/common/man/man1/knife-data-bag.1 +617 -617
- data/distro/common/man/man1/knife-delete.1 +127 -127
- data/distro/common/man/man1/knife-deps.1 +246 -246
- data/distro/common/man/man1/knife-diff.1 +226 -226
- data/distro/common/man/man1/knife-download.1 +258 -258
- data/distro/common/man/man1/knife-edit.1 +121 -121
- data/distro/common/man/man1/knife-environment.1 +508 -508
- data/distro/common/man/man1/knife-exec.1 +362 -362
- data/distro/common/man/man1/knife-index-rebuild.1 +63 -63
- data/distro/common/man/man1/knife-list.1 +174 -174
- data/distro/common/man/man1/knife-node.1 +716 -716
- data/distro/common/man/man1/knife-raw.1 +172 -172
- data/distro/common/man/man1/knife-recipe-list.1 +85 -85
- data/distro/common/man/man1/knife-role.1 +426 -426
- data/distro/common/man/man1/knife-search.1 +359 -359
- data/distro/common/man/man1/knife-serve.1 +109 -109
- data/distro/common/man/man1/knife-show.1 +160 -160
- data/distro/common/man/man1/knife-ssh.1 +284 -284
- data/distro/common/man/man1/knife-ssl-check.1 +207 -207
- data/distro/common/man/man1/knife-ssl-fetch.1 +207 -207
- data/distro/common/man/man1/knife-status.1 +234 -234
- data/distro/common/man/man1/knife-tag.1 +189 -189
- data/distro/common/man/man1/knife-upload.1 +280 -280
- data/distro/common/man/man1/knife-user.1 +356 -356
- data/distro/common/man/man1/knife-xargs.1 +189 -189
- data/distro/common/man/man1/knife.1 +332 -332
- data/distro/common/man/man8/chef-apply.8 +86 -86
- data/distro/common/man/man8/chef-client.8 +398 -398
- data/distro/common/man/man8/chef-solo.8 +260 -260
- data/distro/common/markdown/README +3 -3
- data/lib/chef/application.rb +14 -9
- data/lib/chef/application/apply.rb +5 -5
- data/lib/chef/application/client.rb +3 -3
- data/lib/chef/application/exit_code.rb +226 -0
- data/lib/chef/application/solo.rb +37 -7
- data/lib/chef/application/windows_service.rb +3 -3
- data/lib/chef/chef_fs/command_line.rb +7 -0
- data/lib/chef/chef_fs/config.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +11 -10
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +15 -13
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +4 -0
- data/lib/chef/chef_fs/file_system/chef_server/acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +9 -0
- data/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb +6 -0
- data/lib/chef/chef_fs/file_system/chef_server/data_bag_entry.rb +19 -0
- data/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/org_entry.rb +4 -0
- data/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb +4 -0
- data/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb +4 -0
- data/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb +4 -0
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +15 -4
- data/lib/chef/chef_fs/file_system/exceptions.rb +7 -0
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/nonexistent_fs_object.rb +0 -4
- data/lib/chef/chef_fs/file_system/repository/acl.rb +7 -0
- data/lib/chef/chef_fs/file_system/repository/acls_sub_dir.rb +0 -4
- data/lib/chef/chef_fs/file_system/repository/base_file.rb +36 -4
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -0
- data/lib/chef/chef_fs/file_system/repository/client_keys_sub_dir.rb +0 -4
- data/lib/chef/chef_fs/file_system/repository/clients_dir.rb +0 -3
- data/lib/chef/chef_fs/file_system/repository/containers_dir.rb +0 -4
- data/lib/chef/chef_fs/file_system/repository/directory.rb +4 -0
- data/lib/chef/chef_fs/file_system/repository/environments_dir.rb +0 -4
- data/lib/chef/chef_fs/file_system/repository/groups_dir.rb +0 -4
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +0 -4
- data/lib/chef/chef_fs/file_system/repository/policy_groups_dir.rb +0 -4
- data/lib/chef/chef_fs/file_system/repository/roles_dir.rb +0 -4
- data/lib/chef/chef_fs/file_system/repository/users_dir.rb +0 -4
- data/lib/chef/client.rb +11 -3
- data/lib/chef/config_fetcher.rb +4 -4
- data/lib/chef/cookbook/gem_installer.rb +1 -0
- data/lib/chef/cookbook/synchronizer.rb +1 -1
- data/lib/chef/data_bag.rb +2 -2
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/data_collector.rb +345 -0
- data/lib/chef/data_collector/messages.rb +125 -0
- data/lib/chef/data_collector/messages/helpers.rb +161 -0
- data/lib/chef/data_collector/resource_report.rb +84 -0
- data/lib/chef/decorator.rb +81 -0
- data/lib/chef/decorator/lazy.rb +60 -0
- data/lib/chef/decorator/lazy_array.rb +59 -0
- data/lib/chef/deprecation/provider/remote_file.rb +1 -1
- data/lib/chef/dsl/core.rb +19 -11
- data/lib/chef/dsl/platform_introspection.rb +16 -0
- data/lib/chef/dsl/recipe.rb +15 -9
- data/lib/chef/dsl/universal.rb +50 -0
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/exceptions.rb +19 -4
- data/lib/chef/handler.rb +33 -0
- data/lib/chef/knife/cookbook_show.rb +6 -10
- data/lib/chef/knife/cookbook_site_install.rb +7 -2
- data/lib/chef/knife/help_topics.rb +4 -4
- data/lib/chef/knife/list.rb +1 -2
- data/lib/chef/knife/ssl_check.rb +2 -1
- data/lib/chef/monkey_patches/win32/registry.rb +11 -0
- data/lib/chef/nil_argument.rb +3 -3
- data/lib/chef/node.rb +2 -2
- data/lib/chef/platform/rebooter.rb +13 -2
- data/lib/chef/policy_builder/dynamic.rb +1 -1
- data/lib/chef/policy_builder/expand_node_object.rb +3 -3
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/provider/git.rb +43 -41
- data/lib/chef/provider/lwrp_base.rb +0 -1
- data/lib/chef/provider/osx_profile.rb +2 -3
- data/lib/chef/provider/package.rb +51 -13
- data/lib/chef/provider/package/apt.rb +97 -103
- data/lib/chef/provider/package/chocolatey.rb +9 -10
- data/lib/chef/provider/package/dpkg.rb +2 -2
- data/lib/chef/provider/package/portage.rb +1 -1
- data/lib/chef/provider/package/rubygems.rb +8 -12
- data/lib/chef/provider/package/yum.rb +4 -959
- data/lib/chef/provider/package/yum/rpm_utils.rb +642 -0
- data/lib/chef/provider/package/{yum-dump.py → yum/yum-dump.py} +0 -0
- data/lib/chef/provider/package/yum/yum_cache.rb +376 -0
- data/lib/chef/provider/resource_update.rb +52 -52
- data/lib/chef/provider/systemd_unit.rb +238 -0
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/reserved_names.rb +9 -9
- data/lib/chef/resource.rb +2 -7
- data/lib/chef/resource/file.rb +6 -1
- data/lib/chef/resource/systemd_unit.rb +63 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/sandbox.rb +20 -20
- data/lib/chef/shell/shell_session.rb +3 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/system.rb +0 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/changelog +5 -5
- data/spec/data/apt/chef-integration-test-1.0/debian/compat +1 -1
- data/spec/data/apt/chef-integration-test-1.0/debian/control +13 -13
- data/spec/data/apt/chef-integration-test-1.0/debian/files +1 -1
- data/spec/data/apt/chef-integration-test-1.0/debian/rules +13 -13
- data/spec/data/apt/chef-integration-test-1.0/debian/source/format +1 -1
- data/spec/data/apt/chef-integration-test-1.1/debian/changelog +11 -11
- data/spec/data/apt/chef-integration-test-1.1/debian/compat +1 -1
- data/spec/data/apt/chef-integration-test-1.1/debian/control +13 -13
- data/spec/data/apt/chef-integration-test-1.1/debian/files +1 -1
- data/spec/data/apt/chef-integration-test-1.1/debian/rules +13 -13
- data/spec/data/apt/chef-integration-test-1.1/debian/source/format +1 -1
- data/spec/data/apt/chef-integration-test2-1.0/debian/rules +0 -0
- data/spec/data/apt/chef-integration-test_1.0-1_amd64.changes +22 -22
- data/spec/data/apt/chef-integration-test_1.1-1_amd64.changes +22 -22
- data/spec/data/apt/var/www/apt/conf/distributions +7 -7
- data/spec/data/apt/var/www/apt/conf/incoming +4 -4
- data/spec/data/apt/var/www/apt/conf/pulls +3 -3
- data/spec/data/apt/var/www/apt/db/version +4 -4
- data/spec/data/apt/var/www/apt/dists/sid/Release +19 -19
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages +16 -16
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Release +5 -5
- data/spec/data/bootstrap/encrypted_data_bag_secret +1 -1
- data/spec/data/bootstrap/no_proxy.erb +2 -2
- data/spec/data/bootstrap/secret.erb +9 -9
- data/spec/data/bootstrap/test-hints.erb +12 -12
- data/spec/data/bootstrap/test.erb +1 -1
- data/spec/data/cb_version_cookbooks/tatft/README.rdoc +2 -2
- data/spec/data/cb_version_cookbooks/tatft/attributes/default.rb +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-600hhz-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ahd2gq-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-api8ux-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-b0r1m1-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-bfygsi-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-el14l6-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ivrl3y-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-kkbs85-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ory1ux-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-pgsq76-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ra8uim-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-t7k1g-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-t8g0sv-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-ufy6g3-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-x2d6j9-0 +1 -1
- data/spec/data/checksum_cache/chef-file--tmp-chef-rendered-template20100929-10863-xi0l6h-0 +1 -1
- data/spec/data/config.rb +6 -6
- data/spec/data/cookbooks/angrybash/metadata.rb +2 -2
- data/spec/data/cookbooks/angrybash/recipes/default.rb +8 -8
- data/spec/data/cookbooks/apache2/files/default/apache2_module_conf_generate.pl +2 -2
- data/spec/data/cookbooks/apache2/metadata.rb +2 -2
- data/spec/data/cookbooks/apache2/recipes/default.rb +2 -2
- data/spec/data/cookbooks/borken/metadata.rb +2 -2
- data/spec/data/cookbooks/borken/recipes/default.rb +1 -1
- data/spec/data/cookbooks/borken/templates/default/borken.erb +1 -1
- data/spec/data/cookbooks/chefignore +8 -8
- data/spec/data/cookbooks/ignorken/files/default/not_me.rb +2 -2
- data/spec/data/cookbooks/ignorken/metadata.rb +2 -2
- data/spec/data/cookbooks/ignorken/recipes/ignoreme.rb +1 -1
- data/spec/data/cookbooks/ignorken/templates/ubuntu-12.10/not_me.rb +2 -2
- data/spec/data/cookbooks/java/files/default/java.response +1 -1
- data/spec/data/cookbooks/java/metadata.rb +2 -2
- data/spec/data/cookbooks/name-mismatch-versionnumber/README.md +4 -4
- data/spec/data/cookbooks/name-mismatch-versionnumber/metadata.rb +8 -8
- data/spec/data/cookbooks/openldap/attributes/default.rb +16 -16
- data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
- data/spec/data/cookbooks/openldap/definitions/client.rb +5 -5
- data/spec/data/cookbooks/openldap/definitions/server.rb +5 -5
- data/spec/data/cookbooks/openldap/files/default/.dotfile +1 -1
- data/spec/data/cookbooks/openldap/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir +1 -1
- data/spec/data/cookbooks/openldap/files/default/remotedir/not_a_template.erb +2 -2
- data/spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file1.txt +2 -2
- data/spec/data/cookbooks/openldap/files/default/remotedir/remote_dir_file2.txt +2 -2
- data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/.a_dotfile +1 -1
- data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file1.txt +2 -2
- data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/remote_subdir_file2.txt +2 -2
- data/spec/data/cookbooks/openldap/files/default/remotedir/subdir_with_no_file_just_a_subsubdir/the_subsubdir/some_file.txt +3 -3
- data/spec/data/cookbooks/openldap/libraries/openldap.rb +4 -4
- data/spec/data/cookbooks/openldap/libraries/openldap/version.rb +3 -3
- data/spec/data/cookbooks/openldap/metadata.rb +8 -8
- data/spec/data/cookbooks/openldap/recipes/default.rb +4 -4
- data/spec/data/cookbooks/openldap/recipes/gigantor.rb +3 -3
- data/spec/data/cookbooks/openldap/recipes/one.rb +15 -15
- data/spec/data/cookbooks/openldap/recipes/return.rb +2 -2
- data/spec/data/cookbooks/openldap/templates/default/helper_test.erb +1 -1
- data/spec/data/cookbooks/openldap/templates/default/helpers_via_partial_test.erb +1 -1
- data/spec/data/cookbooks/openldap/templates/default/no_windows_line_endings.erb +4 -4
- data/spec/data/cookbooks/openldap/templates/default/openldap_variable_stuff.conf.erb +1 -1
- data/spec/data/cookbooks/openldap/templates/default/test.erb +1 -1
- data/spec/data/cookbooks/preseed/files/default/preseed-file.seed +1 -1
- data/spec/data/cookbooks/preseed/files/default/preseed-template.seed +4 -4
- data/spec/data/cookbooks/preseed/metadata.rb +2 -2
- data/spec/data/cookbooks/preseed/templates/default/preseed-template-variables.seed +1 -1
- data/spec/data/cookbooks/preseed/templates/default/preseed-template.seed +1 -1
- data/spec/data/definitions/test.rb +4 -4
- data/spec/data/environment-config.rb +4 -4
- data/spec/data/file-providers-method-snapshot-chef-11-4.json +127 -127
- data/spec/data/fileedit/hosts +4 -4
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/README.md +4 -4
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/metadata.rb +13 -13
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/README.md +4 -4
- data/spec/data/kitchen/chefignore +6 -6
- data/spec/data/kitchen/openldap/attributes/default.rb +3 -3
- data/spec/data/kitchen/openldap/attributes/robinson.rb +2 -2
- data/spec/data/kitchen/openldap/definitions/client.rb +3 -3
- data/spec/data/kitchen/openldap/definitions/drewbarrymore.rb +2 -2
- data/spec/data/kitchen/openldap/recipes/gigantor.rb +2 -2
- data/spec/data/kitchen/openldap/recipes/ignoreme.rb +2 -2
- data/spec/data/kitchen/openldap/recipes/woot.rb +3 -3
- data/spec/data/knife_subcommand/test_explicit_category.rb +6 -6
- data/spec/data/knife_subcommand/test_name_mapping.rb +4 -4
- data/spec/data/knife_subcommand/test_yourself.rb +21 -21
- data/spec/data/lwrp/providers/inline_compiler.rb +26 -26
- data/spec/data/lwrp/providers/monkey_name_printer.rb +5 -5
- data/spec/data/lwrp/providers/paint_drying_watcher.rb +7 -7
- data/spec/data/lwrp/providers/thumb_twiddler.rb +7 -7
- data/spec/data/lwrp/resources/foo.rb +4 -4
- data/spec/data/lwrp/resources_with_default_attributes/nodeattr.rb +1 -1
- data/spec/data/lwrp_override/providers/buck_passer.rb +5 -5
- data/spec/data/mac_users/10.7-8.plist.xml +559 -559
- data/spec/data/mac_users/10.7-8.shadow.xml +11 -11
- data/spec/data/mac_users/10.7.plist.xml +559 -559
- data/spec/data/mac_users/10.7.shadow.xml +11 -11
- data/spec/data/mac_users/10.8.plist.xml +559 -559
- data/spec/data/mac_users/10.8.shadow.xml +21 -21
- data/spec/data/mac_users/10.9.plist.xml +560 -560
- data/spec/data/mac_users/10.9.shadow.xml +21 -21
- data/spec/data/metadata/quick_start/metadata.rb +19 -19
- data/spec/data/nodes/default.rb +15 -15
- data/spec/data/nodes/test.example.com.rb +17 -17
- data/spec/data/nodes/test.rb +15 -15
- data/spec/data/null_config.rb +1 -1
- data/spec/data/object_loader/environments/test.json +7 -7
- data/spec/data/object_loader/environments/test.rb +2 -2
- data/spec/data/object_loader/environments/test_json_class.json +8 -8
- data/spec/data/object_loader/nodes/test.json +7 -7
- data/spec/data/object_loader/nodes/test.rb +2 -2
- data/spec/data/object_loader/nodes/test_json_class.json +8 -8
- data/spec/data/object_loader/roles/test.json +7 -7
- data/spec/data/object_loader/roles/test.rb +2 -2
- data/spec/data/object_loader/roles/test_json_class.json +8 -8
- data/spec/data/partial_one.erb +1 -1
- data/spec/data/recipes/test.rb +7 -7
- data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -4
- data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -1
- data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -2
- data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -2
- data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -1
- data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -1
- data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -3
- data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -1
- data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -2
- data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -2
- data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -1
- data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -1
- data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -2
- data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -2
- data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -3
- data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -1
- data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -2
- data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -1
- data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -1
- data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -3
- data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -1
- data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -2
- data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -1
- data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -1
- data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -3
- data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -1
- data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -1
- data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -1
- data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -3
- data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -1
- data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -2
- data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -2
- data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -1
- data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -1
- data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -3
- data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -1
- data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -1
- data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -3
- data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -1
- data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -1
- data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
- data/spec/data/run_context/cookbooks/test/definitions/new_animals.rb +9 -9
- data/spec/data/run_context/cookbooks/test/definitions/new_cat.rb +5 -5
- data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -1
- data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -1
- data/spec/data/run_context/cookbooks/test/recipes/default.rb +5 -5
- data/spec/data/run_context/cookbooks/test/recipes/one.rb +7 -7
- data/spec/data/run_context/cookbooks/test/recipes/two.rb +7 -7
- data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -1
- data/spec/data/run_context/nodes/run_context.rb +5 -5
- data/spec/data/search_queries_to_transform.txt +98 -98
- data/spec/data/shef-config.rb +10 -10
- data/spec/data/ssl/5e707473.0 +18 -18
- data/spec/data/ssl/chef-rspec.cert +27 -27
- data/spec/data/ssl/chef-rspec.key +27 -27
- data/spec/data/ssl/key.pem +15 -15
- data/spec/data/ssl/private_key.pem +27 -27
- data/spec/data/ssl/private_key_with_whitespace.pem +32 -32
- data/spec/data/standalone_cookbook/chefignore +9 -9
- data/spec/data/standalone_cookbook/recipes/default.rb +2 -2
- data/spec/data/trusted_certs/example.crt +22 -22
- data/spec/data/trusted_certs/intermediate.pem +27 -27
- data/spec/data/trusted_certs/root.pem +22 -22
- data/spec/functional/assets/chefinittest +34 -34
- data/spec/functional/assets/testchefsubsys +10 -10
- data/spec/functional/provider/remote_file/cache_control_data_spec.rb +0 -0
- data/spec/functional/resource/aix_service_spec.rb +0 -0
- data/spec/functional/resource/aixinit_service_spec.rb +0 -0
- data/spec/functional/resource/chocolatey_package_spec.rb +0 -5
- data/spec/functional/resource/env_spec.rb +0 -0
- data/spec/functional/win32/registry_spec.rb +1 -0
- data/spec/integration/client/exit_code_spec.rb +245 -0
- data/spec/integration/knife/deps_spec.rb +7 -7
- data/spec/integration/knife/download_spec.rb +19 -0
- data/spec/integration/knife/list_spec.rb +0 -8
- data/spec/integration/knife/upload_spec.rb +21 -2
- data/spec/integration/solo/solo_spec.rb +1 -1
- data/spec/rcov.opts +2 -2
- data/spec/unit/application/apply_spec.rb +6 -4
- data/spec/unit/application/exit_code_spec.rb +231 -0
- data/spec/unit/application/solo_spec.rb +143 -88
- data/spec/unit/chef_fs/config_spec.rb +129 -0
- data/spec/unit/chef_fs/file_system/repository/base_file_spec.rb +8 -10
- data/spec/unit/client_spec.rb +1 -1
- data/spec/unit/config_fetcher_spec.rb +2 -2
- data/spec/unit/cookbook/synchronizer_spec.rb +1 -1
- data/spec/unit/data_bag_item_spec.rb +2 -2
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector/messages/helpers_spec.rb +190 -0
- data/spec/unit/data_collector/messages_spec.rb +207 -0
- data/spec/unit/data_collector_spec.rb +525 -0
- data/spec/unit/decorator/lazy_array_spec.rb +58 -0
- data/spec/unit/decorator/lazy_spec.rb +39 -0
- data/spec/unit/decorator_spec.rb +142 -0
- data/spec/unit/environment_spec.rb +4 -4
- data/spec/unit/handler_spec.rb +87 -0
- data/spec/unit/knife/cookbook_show_spec.rb +89 -90
- data/spec/unit/knife/ssl_check_spec.rb +16 -0
- data/spec/unit/policy_builder/dynamic_spec.rb +1 -1
- data/spec/unit/policy_builder/policyfile_spec.rb +1 -1
- data/spec/unit/provider/git_spec.rb +77 -18
- data/spec/unit/provider/package/apt_spec.rb +97 -34
- data/spec/unit/provider/package/chocolatey_spec.rb +3 -15
- data/spec/unit/provider/package/portage_spec.rb +6 -0
- data/spec/unit/provider/package/rubygems_spec.rb +38 -4
- data/spec/unit/provider/package/yum/yum_cache_spec.rb +27 -0
- data/spec/unit/provider/package_spec.rb +20 -7
- data/spec/unit/provider/systemd_unit_spec.rb +885 -0
- data/spec/unit/resource/systemd_unit_spec.rb +133 -0
- data/spec/unit/resource_builder_spec.rb +1 -1
- data/tasks/bin/bundle-platform +6 -2
- data/tasks/bin/bundle-platform.bat +0 -0
- data/tasks/bin/create-override-gemfile +0 -0
- data/tasks/bin/run_external_test +0 -0
- data/tasks/bundle_util.rb +18 -2
- data/tasks/changelog.rb +1 -0
- data/tasks/dependencies.rb +47 -57
- metadata +847 -7
- data/tasks/bin/run_chef_tests +0 -17
@@ -36,6 +36,7 @@ describe Chef::Provider::Package::Chocolatey do
|
|
36
36
|
# installed packages (ConEmu is upgradable)
|
37
37
|
let(:local_list_stdout) do
|
38
38
|
<<-EOF
|
39
|
+
Chocolatey v0.9.9.11
|
39
40
|
chocolatey|0.9.9.11
|
40
41
|
ConEmu|15.10.25.0
|
41
42
|
EOF
|
@@ -50,6 +51,7 @@ ConEmu|15.10.25.0
|
|
50
51
|
|
51
52
|
def allow_remote_list(package_names, args = nil)
|
52
53
|
remote_list_stdout = <<-EOF
|
54
|
+
Chocolatey v0.9.9.11
|
53
55
|
chocolatey|0.9.9.11
|
54
56
|
ConEmu|15.10.25.1
|
55
57
|
Git|2.6.1
|
@@ -57,7 +59,7 @@ Git|2.6.2
|
|
57
59
|
munin-node|1.6.1.20130823
|
58
60
|
EOF
|
59
61
|
remote_list_obj = double(stdout: remote_list_stdout)
|
60
|
-
allow(provider).to receive(:shell_out!).with("#{choco_exe} list -
|
62
|
+
allow(provider).to receive(:shell_out!).with("#{choco_exe} list -r #{package_names.join ' '}#{args}", { timeout: timeout }).and_return(remote_list_obj)
|
61
63
|
end
|
62
64
|
|
63
65
|
describe "#initialize" do
|
@@ -82,12 +84,6 @@ munin-node|1.6.1.20130823
|
|
82
84
|
expect(provider.candidate_version).to eql(["2.6.1"])
|
83
85
|
end
|
84
86
|
|
85
|
-
it "should set the candidate_version to nill if pinning to bogus version" do
|
86
|
-
allow_remote_list(["git"])
|
87
|
-
new_resource.version("2.5.0")
|
88
|
-
expect(provider.candidate_version).to eql([nil])
|
89
|
-
end
|
90
|
-
|
91
87
|
it "should set the candidate_version to nil if there is no candidate" do
|
92
88
|
allow_remote_list(["vim"])
|
93
89
|
new_resource.package_name("vim")
|
@@ -299,14 +295,6 @@ munin-node|1.6.1.20130823
|
|
299
295
|
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
|
300
296
|
end
|
301
297
|
|
302
|
-
it "installing a package version that does not exist throws an error" do
|
303
|
-
allow_remote_list(["git"])
|
304
|
-
new_resource.package_name("git")
|
305
|
-
new_resource.version("2.7.0")
|
306
|
-
provider.load_current_resource
|
307
|
-
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
|
308
|
-
end
|
309
|
-
|
310
298
|
it "installing multiple packages with a package that does not exist throws an error" do
|
311
299
|
allow_remote_list(["git", "package-does-not-exist"])
|
312
300
|
new_resource.package_name(["git", "package-does-not-exist"])
|
@@ -56,6 +56,12 @@ describe Chef::Provider::Package::Portage, "load_current_resource" do
|
|
56
56
|
expect(@provider.current_resource.version).to eq("1.0.0-r1")
|
57
57
|
end
|
58
58
|
|
59
|
+
it "should return a current resource with the correct version if the package is found with version with character" do
|
60
|
+
allow(::Dir).to receive(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/git-1.0.0d"])
|
61
|
+
@provider.load_current_resource
|
62
|
+
expect(@provider.current_resource.version).to eq("1.0.0d")
|
63
|
+
end
|
64
|
+
|
59
65
|
it "should return a current resource with a nil version if the package is not found" do
|
60
66
|
allow(::Dir).to receive(:[]).with("/var/db/pkg/dev-util/git-*").and_return(["/var/db/pkg/dev-util/notgit-1.0.0"])
|
61
67
|
@provider.load_current_resource
|
@@ -496,12 +496,36 @@ describe Chef::Provider::Package::Rubygems do
|
|
496
496
|
provider.load_current_resource
|
497
497
|
end
|
498
498
|
|
499
|
-
|
500
|
-
|
499
|
+
context "when the current version is the target version" do
|
500
|
+
it "does not query for available versions" do
|
501
|
+
# NOTE: odd use case -- we've equality pinned a version, but are calling :upgrade
|
502
|
+
expect(provider.gem_env).not_to receive(:candidate_version_from_remote)
|
503
|
+
expect(provider.gem_env).not_to receive(:install)
|
504
|
+
provider.run_action(:upgrade)
|
505
|
+
expect(new_resource).not_to be_updated_by_last_action
|
506
|
+
end
|
501
507
|
end
|
502
508
|
|
503
|
-
context "when the current version
|
504
|
-
let(:target_version) { "
|
509
|
+
context "when the current version satisfies the target version requirement" do
|
510
|
+
let(:target_version) { ">= 0" }
|
511
|
+
|
512
|
+
it "does not query for available versions on install" do
|
513
|
+
expect(provider.gem_env).not_to receive(:candidate_version_from_remote)
|
514
|
+
expect(provider.gem_env).not_to receive(:install)
|
515
|
+
provider.run_action(:install)
|
516
|
+
expect(new_resource).not_to be_updated_by_last_action
|
517
|
+
end
|
518
|
+
|
519
|
+
it "queries for available versions on upgrade" do
|
520
|
+
expect(provider.gem_env).to receive(:candidate_version_from_remote).
|
521
|
+
and_return(Gem::Version.new("9000.0.2"))
|
522
|
+
expect(provider.gem_env).to receive(:install)
|
523
|
+
provider.run_action(:upgrade)
|
524
|
+
expect(new_resource).to be_updated_by_last_action
|
525
|
+
end
|
526
|
+
end
|
527
|
+
|
528
|
+
context "when the requested source is a remote server" do
|
505
529
|
let(:source) { "http://mygems.example.com" }
|
506
530
|
|
507
531
|
it "determines the candidate version by querying the remote gem servers" do
|
@@ -669,6 +693,11 @@ describe Chef::Provider::Package::Rubygems do
|
|
669
693
|
expect(provider.gem_env).not_to receive(:install)
|
670
694
|
provider.run_action(:install)
|
671
695
|
end
|
696
|
+
|
697
|
+
it "performs the upgrade" do
|
698
|
+
expect(provider.gem_env).to receive(:install)
|
699
|
+
provider.run_action(:upgrade)
|
700
|
+
end
|
672
701
|
end
|
673
702
|
|
674
703
|
context "if the fuzzy operator is used" do
|
@@ -679,6 +708,11 @@ describe Chef::Provider::Package::Rubygems do
|
|
679
708
|
expect(provider.gem_env).not_to receive(:install)
|
680
709
|
provider.run_action(:install)
|
681
710
|
end
|
711
|
+
|
712
|
+
it "it upgrades an existing gem" do
|
713
|
+
expect(provider.gem_env).to receive(:install)
|
714
|
+
provider.run_action(:upgrade)
|
715
|
+
end
|
682
716
|
end
|
683
717
|
end
|
684
718
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
+
# Copyright:: Copyright 2008-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 "spec_helper"
|
20
|
+
|
21
|
+
describe Chef::Provider::Package::Yum::YumCache do
|
22
|
+
|
23
|
+
it "can find yum-dump.py" do
|
24
|
+
expect(File.exist?(Chef::Provider::Package::Yum::YumCache.instance.yum_dump_path)).to be true
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -458,8 +458,18 @@ describe "Subclass with use_multipackage_api" do
|
|
458
458
|
expect(provider.use_multipackage_api?).to be true
|
459
459
|
end
|
460
460
|
|
461
|
-
|
462
|
-
|
461
|
+
context "#a_to_s utility for subclasses" do
|
462
|
+
it "converts varargs of strings to a single string" do
|
463
|
+
expect(provider.send(:a_to_s, "a", nil, "b", "", "c", " ", "d e", "f-g")).to eq("a b c d e f-g")
|
464
|
+
end
|
465
|
+
|
466
|
+
it "converts an array of strings to a single string" do
|
467
|
+
expect(provider.send(:a_to_s, ["a", nil, "b", "", "c", " ", "d e", "f-g"])).to eq("a b c d e f-g")
|
468
|
+
end
|
469
|
+
|
470
|
+
it "converts a mishmash of array args to a single string" do
|
471
|
+
expect(provider.send(:a_to_s, "a", [ nil, "b", "", [ "c" ] ], " ", [ "d e", "f-g" ])).to eq("a b c d e f-g")
|
472
|
+
end
|
463
473
|
end
|
464
474
|
|
465
475
|
it "when user passes string to package_name, passes arrays to install_package" do
|
@@ -566,8 +576,11 @@ describe "Chef::Provider::Package - Multi" do
|
|
566
576
|
let(:new_resource) { Chef::Resource::Package.new(%w{emacs vi}) }
|
567
577
|
let(:current_resource) { Chef::Resource::Package.new(%w{emacs vi}) }
|
568
578
|
let(:candidate_version) { [ "1.0", "6.2" ] }
|
579
|
+
class MyPackageProvider < Chef::Provider::Package
|
580
|
+
use_multipackage_api
|
581
|
+
end
|
569
582
|
let(:provider) do
|
570
|
-
provider =
|
583
|
+
provider = MyPackageProvider.new(new_resource, run_context)
|
571
584
|
provider.current_resource = current_resource
|
572
585
|
provider.candidate_version = candidate_version
|
573
586
|
provider
|
@@ -731,7 +744,7 @@ describe "Chef::Provider::Package - Multi" do
|
|
731
744
|
|
732
745
|
it "should remove the packages if all are installed" do
|
733
746
|
expect(provider).to be_removing_package
|
734
|
-
expect(provider).to receive(:remove_package).with(%w{emacs vi}, nil)
|
747
|
+
expect(provider).to receive(:remove_package).with(%w{emacs vi}, [nil])
|
735
748
|
provider.run_action(:remove)
|
736
749
|
expect(new_resource).to be_updated
|
737
750
|
expect(new_resource).to be_updated_by_last_action
|
@@ -740,7 +753,7 @@ describe "Chef::Provider::Package - Multi" do
|
|
740
753
|
it "should remove the packages if some are installed" do
|
741
754
|
current_resource.version ["1.0", nil]
|
742
755
|
expect(provider).to be_removing_package
|
743
|
-
expect(provider).to receive(:remove_package).with(%w{emacs vi}, nil)
|
756
|
+
expect(provider).to receive(:remove_package).with(%w{emacs vi}, [nil])
|
744
757
|
provider.run_action(:remove)
|
745
758
|
expect(new_resource).to be_updated
|
746
759
|
expect(new_resource).to be_updated_by_last_action
|
@@ -787,7 +800,7 @@ describe "Chef::Provider::Package - Multi" do
|
|
787
800
|
|
788
801
|
it "should purge the packages if all are installed" do
|
789
802
|
expect(provider).to be_removing_package
|
790
|
-
expect(provider).to receive(:purge_package).with(%w{emacs vi}, nil)
|
803
|
+
expect(provider).to receive(:purge_package).with(%w{emacs vi}, [nil])
|
791
804
|
provider.run_action(:purge)
|
792
805
|
expect(new_resource).to be_updated
|
793
806
|
expect(new_resource).to be_updated_by_last_action
|
@@ -796,7 +809,7 @@ describe "Chef::Provider::Package - Multi" do
|
|
796
809
|
it "should purge the packages if some are installed" do
|
797
810
|
current_resource.version ["1.0", nil]
|
798
811
|
expect(provider).to be_removing_package
|
799
|
-
expect(provider).to receive(:purge_package).with(%w{emacs vi}, nil)
|
812
|
+
expect(provider).to receive(:purge_package).with(%w{emacs vi}, [nil])
|
800
813
|
provider.run_action(:purge)
|
801
814
|
expect(new_resource).to be_updated
|
802
815
|
expect(new_resource).to be_updated_by_last_action
|
@@ -0,0 +1,885 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Nathan Williams (<nath.e.will@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c), Nathan Williams
|
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 "spec_helper"
|
20
|
+
|
21
|
+
describe Chef::Provider::SystemdUnit do
|
22
|
+
let(:node) do
|
23
|
+
Chef::Node.new.tap do |n|
|
24
|
+
n.default["etc"] = {}
|
25
|
+
n.default["etc"]["passwd"] = {
|
26
|
+
"joe" => {
|
27
|
+
"uid" => 1_000,
|
28
|
+
},
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
34
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
35
|
+
let(:unit_name) { "sysstat-collect.timer" }
|
36
|
+
let(:user_name) { "joe" }
|
37
|
+
let(:current_resource) { Chef::Resource::SystemdUnit.new(unit_name) }
|
38
|
+
let(:new_resource) { Chef::Resource::SystemdUnit.new(unit_name) }
|
39
|
+
let(:provider) { Chef::Provider::SystemdUnit.new(new_resource, run_context) }
|
40
|
+
let(:unit_path_system) { "/etc/systemd/system/sysstat-collect.timer" }
|
41
|
+
let(:unit_path_user) { "/etc/systemd/user/sysstat-collect.timer" }
|
42
|
+
let(:unit_content_string) { "[Unit]\nDescription = Run system activity accounting tool every 10 minutes\n\n[Timer]\nOnCalendar = *:00/10\n\n[Install]\nWantedBy = sysstat.service\n" }
|
43
|
+
let(:malformed_content_string) { "derp" }
|
44
|
+
|
45
|
+
let(:unit_content_hash) do
|
46
|
+
{
|
47
|
+
"Unit" => {
|
48
|
+
"Description" => "Run system activity accounting tool every 10 minutes",
|
49
|
+
},
|
50
|
+
"Timer" => {
|
51
|
+
"OnCalendar" => "*:00/10",
|
52
|
+
},
|
53
|
+
"Install" => {
|
54
|
+
"WantedBy" => "sysstat.service",
|
55
|
+
},
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
let(:user_cmd_opts) do
|
60
|
+
{
|
61
|
+
"user" => "joe",
|
62
|
+
"environment" => {
|
63
|
+
"DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/1000/bus",
|
64
|
+
},
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
let(:shell_out_success) do
|
69
|
+
double("shell_out_with_systems_locale", :exitstatus => 0, :error? => false)
|
70
|
+
end
|
71
|
+
|
72
|
+
let(:shell_out_failure) do
|
73
|
+
double("shell_out_with_systems_locale", :exitstatus => 1, :error? => true)
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:shell_out_masked) do
|
77
|
+
double("shell_out_with_systems_locale", :exit_status => 0, :error? => false, :stdout => "masked")
|
78
|
+
end
|
79
|
+
|
80
|
+
let(:shell_out_static) do
|
81
|
+
double("shell_out_with_systems_locale", :exit_status => 0, :error? => false, :stdout => "static")
|
82
|
+
end
|
83
|
+
|
84
|
+
before(:each) do
|
85
|
+
allow(Chef::Resource::SystemdUnit).to receive(:new)
|
86
|
+
.with(unit_name)
|
87
|
+
.and_return(current_resource)
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "define_resource_requirements" do
|
91
|
+
before(:each) do
|
92
|
+
provider.action = :create
|
93
|
+
allow(provider).to receive(:active?).and_return(false)
|
94
|
+
allow(provider).to receive(:enabled?).and_return(false)
|
95
|
+
allow(provider).to receive(:masked?).and_return(false)
|
96
|
+
allow(provider).to receive(:static?).and_return(false)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "accepts valid resource requirements" do
|
100
|
+
new_resource.content(unit_content_string)
|
101
|
+
provider.load_current_resource
|
102
|
+
provider.define_resource_requirements
|
103
|
+
expect { provider.process_resource_requirements }.to_not raise_error
|
104
|
+
end
|
105
|
+
|
106
|
+
it "rejects failed resource requirements" do
|
107
|
+
new_resource.content(malformed_content_string)
|
108
|
+
provider.load_current_resource
|
109
|
+
provider.define_resource_requirements
|
110
|
+
expect { provider.process_resource_requirements }.to raise_error(IniParse::ParseError)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "load_current_resource" do
|
115
|
+
before(:each) do
|
116
|
+
allow(provider).to receive(:active?).and_return(false)
|
117
|
+
allow(provider).to receive(:enabled?).and_return(false)
|
118
|
+
allow(provider).to receive(:masked?).and_return(false)
|
119
|
+
allow(provider).to receive(:static?).and_return(false)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should create a current resource with the name of the new resource" do
|
123
|
+
expect(Chef::Resource::SystemdUnit).to receive(:new)
|
124
|
+
.with(unit_name)
|
125
|
+
.and_return(current_resource)
|
126
|
+
provider.load_current_resource
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should check if the unit is active" do
|
130
|
+
expect(provider).to receive(:active?)
|
131
|
+
provider.load_current_resource
|
132
|
+
end
|
133
|
+
|
134
|
+
it "sets the active property to true if the unit is active" do
|
135
|
+
allow(provider).to receive(:active?).and_return(true)
|
136
|
+
provider.load_current_resource
|
137
|
+
expect(current_resource.active).to be true
|
138
|
+
end
|
139
|
+
|
140
|
+
it "sets the active property to false if the unit is not active" do
|
141
|
+
allow(provider).to receive(:active?).and_return(false)
|
142
|
+
provider.load_current_resource
|
143
|
+
expect(current_resource.active).to be false
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should check if the unit is enabled" do
|
147
|
+
expect(provider).to receive(:enabled?)
|
148
|
+
provider.load_current_resource
|
149
|
+
end
|
150
|
+
|
151
|
+
it "sets the enabled property to true if the unit is enabled" do
|
152
|
+
allow(provider).to receive(:enabled?).and_return(true)
|
153
|
+
provider.load_current_resource
|
154
|
+
expect(current_resource.enabled).to be true
|
155
|
+
end
|
156
|
+
|
157
|
+
it "sets the enabled property to false if the unit is not enabled" do
|
158
|
+
allow(provider).to receive(:enabled?).and_return(false)
|
159
|
+
provider.load_current_resource
|
160
|
+
expect(current_resource.enabled).to be false
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should check if the unit is masked" do
|
164
|
+
expect(provider).to receive(:masked?)
|
165
|
+
provider.load_current_resource
|
166
|
+
end
|
167
|
+
|
168
|
+
it "sets the masked property to true if the unit is masked" do
|
169
|
+
allow(provider).to receive(:masked?).and_return(true)
|
170
|
+
provider.load_current_resource
|
171
|
+
expect(current_resource.masked).to be true
|
172
|
+
end
|
173
|
+
|
174
|
+
it "sets the masked property to false if the unit is masked" do
|
175
|
+
allow(provider).to receive(:masked?).and_return(false)
|
176
|
+
provider.load_current_resource
|
177
|
+
expect(current_resource.masked).to be false
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should check if the unit is static" do
|
181
|
+
expect(provider).to receive(:static?)
|
182
|
+
provider.load_current_resource
|
183
|
+
end
|
184
|
+
|
185
|
+
it "sets the static property to true if the unit is static" do
|
186
|
+
allow(provider).to receive(:static?).and_return(true)
|
187
|
+
provider.load_current_resource
|
188
|
+
expect(current_resource.static).to be true
|
189
|
+
end
|
190
|
+
|
191
|
+
it "sets the static property to false if the unit is not static" do
|
192
|
+
allow(provider).to receive(:static?).and_return(false)
|
193
|
+
provider.load_current_resource
|
194
|
+
expect(current_resource.static).to be false
|
195
|
+
end
|
196
|
+
|
197
|
+
it "loads the system unit content if the file exists and user is not set" do
|
198
|
+
allow(File).to receive(:exist?)
|
199
|
+
.with(unit_path_system)
|
200
|
+
.and_return(true)
|
201
|
+
allow(File).to receive(:read)
|
202
|
+
.with(unit_path_system)
|
203
|
+
.and_return(unit_content_string)
|
204
|
+
|
205
|
+
expect(File).to receive(:exist?)
|
206
|
+
.with(unit_path_system)
|
207
|
+
expect(File).to receive(:read)
|
208
|
+
.with(unit_path_system)
|
209
|
+
provider.load_current_resource
|
210
|
+
expect(current_resource.content).to eq(unit_content_string)
|
211
|
+
end
|
212
|
+
|
213
|
+
it "does not load the system unit content if the unit file is not present and the user is not set" do
|
214
|
+
allow(File).to receive(:exist?)
|
215
|
+
.with(unit_path_system)
|
216
|
+
.and_return(false)
|
217
|
+
expect(File).to_not receive(:read)
|
218
|
+
.with(unit_path_system)
|
219
|
+
provider.load_current_resource
|
220
|
+
expect(current_resource.content).to eq(nil)
|
221
|
+
end
|
222
|
+
|
223
|
+
it "loads the user unit content if the file exists and user is set" do
|
224
|
+
new_resource.user("joe")
|
225
|
+
allow(File).to receive(:exist?)
|
226
|
+
.with(unit_path_user)
|
227
|
+
.and_return(true)
|
228
|
+
allow(File).to receive(:read)
|
229
|
+
.with(unit_path_user)
|
230
|
+
.and_return(unit_content_string)
|
231
|
+
expect(File).to receive(:exist?)
|
232
|
+
.with(unit_path_user)
|
233
|
+
expect(File).to receive(:read)
|
234
|
+
.with(unit_path_user)
|
235
|
+
provider.load_current_resource
|
236
|
+
expect(current_resource.content).to eq(unit_content_string)
|
237
|
+
end
|
238
|
+
|
239
|
+
it "does not load the user unit if the file does not exist and user is set" do
|
240
|
+
new_resource.user("joe")
|
241
|
+
allow(File).to receive(:exist?)
|
242
|
+
.with(unit_path_user)
|
243
|
+
.and_return(false)
|
244
|
+
expect(File).to_not receive(:read)
|
245
|
+
.with(unit_path_user)
|
246
|
+
provider.load_current_resource
|
247
|
+
expect(current_resource.content).to eq(nil)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
%w{/bin/systemctl /usr/bin/systemctl}.each do |systemctl_path|
|
252
|
+
describe "when systemctl path is #{systemctl_path}" do
|
253
|
+
before(:each) do
|
254
|
+
provider.current_resource = current_resource
|
255
|
+
allow(provider).to receive(:which)
|
256
|
+
.with("systemctl")
|
257
|
+
.and_return(systemctl_path)
|
258
|
+
end
|
259
|
+
|
260
|
+
describe "creates/deletes the unit" do
|
261
|
+
it "creates the unit file when it does not exist" do
|
262
|
+
allow(provider).to receive(:manage_unit_file)
|
263
|
+
.with(:create)
|
264
|
+
.and_return(true)
|
265
|
+
allow(provider).to receive(:daemon_reload)
|
266
|
+
.and_return(true)
|
267
|
+
expect(provider).to receive(:manage_unit_file).with(:create)
|
268
|
+
provider.action_create
|
269
|
+
end
|
270
|
+
|
271
|
+
it "creates the file when the unit content is different" do
|
272
|
+
allow(provider).to receive(:manage_unit_file)
|
273
|
+
.with(:create)
|
274
|
+
.and_return(true)
|
275
|
+
allow(provider).to receive(:daemon_reload)
|
276
|
+
.and_return(true)
|
277
|
+
expect(provider).to receive(:manage_unit_file).with(:create)
|
278
|
+
provider.action_create
|
279
|
+
end
|
280
|
+
|
281
|
+
it "does not create the unit file when the content is the same" do
|
282
|
+
current_resource.content(unit_content_string)
|
283
|
+
allow(provider).to receive(:manage_unit_file).with(:create)
|
284
|
+
allow(provider).to receive(:daemon_reload)
|
285
|
+
.and_return(true)
|
286
|
+
expect(provider).to_not receive(:manage_unit_file)
|
287
|
+
provider.action_create
|
288
|
+
end
|
289
|
+
|
290
|
+
it "triggers a daemon-reload when creating a unit with triggers_reload" do
|
291
|
+
allow(provider).to receive(:manage_unit_file).with(:create)
|
292
|
+
expect(new_resource.triggers_reload).to eq true
|
293
|
+
allow(provider).to receive(:shell_out_with_systems_locale!)
|
294
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
295
|
+
.with("#{systemctl_path} daemon-reload")
|
296
|
+
provider.action_create
|
297
|
+
end
|
298
|
+
|
299
|
+
it "triggers a daemon-reload when deleting a unit with triggers_reload" do
|
300
|
+
allow(File).to receive(:exist?)
|
301
|
+
.with(unit_path_system)
|
302
|
+
.and_return(true)
|
303
|
+
allow(provider).to receive(:manage_unit_file).with(:delete)
|
304
|
+
expect(new_resource.triggers_reload).to eq true
|
305
|
+
allow(provider).to receive(:shell_out_with_systems_locale!)
|
306
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
307
|
+
.with("#{systemctl_path} daemon-reload")
|
308
|
+
provider.action_delete
|
309
|
+
end
|
310
|
+
|
311
|
+
it "does not trigger a daemon-reload when creating a unit without triggers_reload" do
|
312
|
+
new_resource.triggers_reload(false)
|
313
|
+
allow(provider).to receive(:manage_unit_file).with(:create)
|
314
|
+
allow(provider).to receive(:shell_out_with_systems_locale!)
|
315
|
+
expect(provider).to_not receive(:shell_out_with_systems_locale!)
|
316
|
+
.with("#{systemctl_path} daemon-reload")
|
317
|
+
provider.action_create
|
318
|
+
end
|
319
|
+
|
320
|
+
it "does not trigger a daemon-reload when deleting a unit without triggers_reload" do
|
321
|
+
new_resource.triggers_reload(false)
|
322
|
+
allow(File).to receive(:exist?)
|
323
|
+
.with(unit_path_system)
|
324
|
+
.and_return(true)
|
325
|
+
allow(provider).to receive(:manage_unit_file).with(:delete)
|
326
|
+
allow(provider).to receive(:shell_out_with_systems_locale!)
|
327
|
+
expect(provider).to_not receive(:shell_out_with_systems_locale!)
|
328
|
+
.with("#{systemctl_path} daemon-reload")
|
329
|
+
provider.action_delete
|
330
|
+
end
|
331
|
+
|
332
|
+
context "when a user is specified" do
|
333
|
+
it "deletes the file when it exists" do
|
334
|
+
new_resource.user("joe")
|
335
|
+
allow(File).to receive(:exist?)
|
336
|
+
.with(unit_path_user)
|
337
|
+
.and_return(true)
|
338
|
+
allow(provider).to receive(:manage_unit_file)
|
339
|
+
.with(:delete)
|
340
|
+
.and_return(true)
|
341
|
+
allow(provider).to receive(:daemon_reload)
|
342
|
+
expect(provider).to receive(:manage_unit_file).with(:delete)
|
343
|
+
provider.action_delete
|
344
|
+
end
|
345
|
+
|
346
|
+
it "does not delete the file when it is absent" do
|
347
|
+
new_resource.user("joe")
|
348
|
+
allow(File).to receive(:exist?)
|
349
|
+
.with(unit_path_user)
|
350
|
+
.and_return(false)
|
351
|
+
allow(provider).to receive(:manage_unit_file).with(:delete)
|
352
|
+
expect(provider).to_not receive(:manage_unit_file)
|
353
|
+
provider.action_delete
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
context "when no user is specified" do
|
358
|
+
it "deletes the file when it exists" do
|
359
|
+
allow(File).to receive(:exist?)
|
360
|
+
.with(unit_path_system)
|
361
|
+
.and_return(true)
|
362
|
+
allow(provider).to receive(:manage_unit_file)
|
363
|
+
.with(:delete)
|
364
|
+
allow(provider).to receive(:daemon_reload)
|
365
|
+
expect(provider).to receive(:manage_unit_file).with(:delete)
|
366
|
+
provider.action_delete
|
367
|
+
end
|
368
|
+
|
369
|
+
it "does not delete the file when it is absent" do
|
370
|
+
allow(File).to receive(:exist?)
|
371
|
+
.with(unit_path_system)
|
372
|
+
.and_return(false)
|
373
|
+
allow(provider).to receive(:manage_unit_file).with(:delete)
|
374
|
+
allow(provider).to receive(:daemon_reload)
|
375
|
+
expect(provider).to_not receive(:manage_unit_file)
|
376
|
+
provider.action_delete
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
describe "enables/disables the unit" do
|
382
|
+
context "when a user is specified" do
|
383
|
+
it "enables the unit when it is disabled" do
|
384
|
+
current_resource.user(user_name)
|
385
|
+
current_resource.enabled(false)
|
386
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
387
|
+
.with("#{systemctl_path} --user enable #{unit_name}", user_cmd_opts)
|
388
|
+
.and_return(shell_out_success)
|
389
|
+
provider.action_enable
|
390
|
+
end
|
391
|
+
|
392
|
+
it "does not enable the unit when it is enabled" do
|
393
|
+
current_resource.user(user_name)
|
394
|
+
current_resource.enabled(true)
|
395
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
396
|
+
provider.action_enable
|
397
|
+
end
|
398
|
+
|
399
|
+
it "does not enable the unit when it is static" do
|
400
|
+
current_resource.user(user_name)
|
401
|
+
current_resource.static(true)
|
402
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
403
|
+
provider.action_enable
|
404
|
+
end
|
405
|
+
|
406
|
+
it "disables the unit when it is enabled" do
|
407
|
+
current_resource.user(user_name)
|
408
|
+
current_resource.enabled(true)
|
409
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
410
|
+
.with("#{systemctl_path} --user disable #{unit_name}", user_cmd_opts)
|
411
|
+
.and_return(shell_out_success)
|
412
|
+
provider.action_disable
|
413
|
+
end
|
414
|
+
|
415
|
+
it "does not disable the unit when it is disabled" do
|
416
|
+
current_resource.user(user_name)
|
417
|
+
current_resource.enabled(false)
|
418
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
419
|
+
provider.action_disable
|
420
|
+
end
|
421
|
+
|
422
|
+
it "does not disable the unit when it is static" do
|
423
|
+
current_resource.user(user_name)
|
424
|
+
current_resource.static(true)
|
425
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
426
|
+
provider.action_disable
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
context "when no user is specified" do
|
431
|
+
it "enables the unit when it is disabled" do
|
432
|
+
current_resource.enabled(false)
|
433
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
434
|
+
.with("#{systemctl_path} --system enable #{unit_name}", {})
|
435
|
+
.and_return(shell_out_success)
|
436
|
+
provider.action_enable
|
437
|
+
end
|
438
|
+
|
439
|
+
it "does not enable the unit when it is enabled" do
|
440
|
+
current_resource.enabled(true)
|
441
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
442
|
+
provider.action_enable
|
443
|
+
end
|
444
|
+
|
445
|
+
it "does not enable the unit when it is static" do
|
446
|
+
current_resource.static(true)
|
447
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
448
|
+
provider.action_enable
|
449
|
+
end
|
450
|
+
|
451
|
+
it "disables the unit when it is enabled" do
|
452
|
+
current_resource.enabled(true)
|
453
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
454
|
+
.with("#{systemctl_path} --system disable #{unit_name}", {})
|
455
|
+
.and_return(shell_out_success)
|
456
|
+
provider.action_disable
|
457
|
+
end
|
458
|
+
|
459
|
+
it "does not disable the unit when it is disabled" do
|
460
|
+
current_resource.enabled(false)
|
461
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
462
|
+
provider.action_disable
|
463
|
+
end
|
464
|
+
|
465
|
+
it "does not disable the unit when it is static" do
|
466
|
+
current_resource.user(user_name)
|
467
|
+
current_resource.static(true)
|
468
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
469
|
+
provider.action_disable
|
470
|
+
end
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
describe "masks/unmasks the unit" do
|
475
|
+
context "when a user is specified" do
|
476
|
+
it "masks the unit when it is unmasked" do
|
477
|
+
current_resource.user(user_name)
|
478
|
+
current_resource.masked(false)
|
479
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
480
|
+
.with("#{systemctl_path} --user mask #{unit_name}", user_cmd_opts)
|
481
|
+
.and_return(shell_out_success)
|
482
|
+
provider.action_mask
|
483
|
+
end
|
484
|
+
|
485
|
+
it "does not mask the unit when it is masked" do
|
486
|
+
current_resource.user(user_name)
|
487
|
+
current_resource.masked(true)
|
488
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
489
|
+
provider.action_mask
|
490
|
+
end
|
491
|
+
|
492
|
+
it "unmasks the unit when it is masked" do
|
493
|
+
current_resource.user(user_name)
|
494
|
+
current_resource.masked(true)
|
495
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
496
|
+
.with("#{systemctl_path} --user unmask #{unit_name}", user_cmd_opts)
|
497
|
+
.and_return(shell_out_success)
|
498
|
+
provider.action_unmask
|
499
|
+
end
|
500
|
+
|
501
|
+
it "does not unmask the unit when it is unmasked" do
|
502
|
+
current_resource.user(user_name)
|
503
|
+
current_resource.masked(false)
|
504
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
505
|
+
provider.action_unmask
|
506
|
+
end
|
507
|
+
end
|
508
|
+
|
509
|
+
context "when no user is specified" do
|
510
|
+
it "masks the unit when it is unmasked" do
|
511
|
+
current_resource.masked(false)
|
512
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
513
|
+
.with("#{systemctl_path} --system mask #{unit_name}", {})
|
514
|
+
.and_return(shell_out_success)
|
515
|
+
provider.action_mask
|
516
|
+
end
|
517
|
+
|
518
|
+
it "does not mask the unit when it is masked" do
|
519
|
+
current_resource.masked(true)
|
520
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
521
|
+
provider.action_mask
|
522
|
+
end
|
523
|
+
|
524
|
+
it "unmasks the unit when it is masked" do
|
525
|
+
current_resource.masked(true)
|
526
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
527
|
+
.with("#{systemctl_path} --system unmask #{unit_name}", {})
|
528
|
+
.and_return(shell_out_success)
|
529
|
+
provider.action_unmask
|
530
|
+
end
|
531
|
+
|
532
|
+
it "does not unmask the unit when it is unmasked" do
|
533
|
+
current_resource.masked(false)
|
534
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
535
|
+
provider.action_unmask
|
536
|
+
end
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
540
|
+
describe "starts/stops the unit" do
|
541
|
+
context "when a user is specified" do
|
542
|
+
it "starts the unit when it is inactive" do
|
543
|
+
current_resource.user(user_name)
|
544
|
+
current_resource.active(false)
|
545
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
546
|
+
.with("#{systemctl_path} --user start #{unit_name}", user_cmd_opts)
|
547
|
+
.and_return(shell_out_success)
|
548
|
+
provider.action_start
|
549
|
+
end
|
550
|
+
|
551
|
+
it "does not start the unit when it is active" do
|
552
|
+
current_resource.user(user_name)
|
553
|
+
current_resource.active(true)
|
554
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
555
|
+
provider.action_start
|
556
|
+
end
|
557
|
+
|
558
|
+
it "stops the unit when it is active" do
|
559
|
+
current_resource.user(user_name)
|
560
|
+
current_resource.active(true)
|
561
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
562
|
+
.with("#{systemctl_path} --user stop #{unit_name}", user_cmd_opts)
|
563
|
+
.and_return(shell_out_success)
|
564
|
+
provider.action_stop
|
565
|
+
end
|
566
|
+
|
567
|
+
it "does not stop the unit when it is inactive" do
|
568
|
+
current_resource.user(user_name)
|
569
|
+
current_resource.active(false)
|
570
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
571
|
+
provider.action_stop
|
572
|
+
end
|
573
|
+
end
|
574
|
+
|
575
|
+
context "when no user is specified" do
|
576
|
+
it "starts the unit when it is inactive" do
|
577
|
+
current_resource.active(false)
|
578
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
579
|
+
.with("#{systemctl_path} --system start #{unit_name}", {})
|
580
|
+
.and_return(shell_out_success)
|
581
|
+
provider.action_start
|
582
|
+
end
|
583
|
+
|
584
|
+
it "does not start the unit when it is active" do
|
585
|
+
current_resource.active(true)
|
586
|
+
expect(provider).to_not receive(:shell_out_with_systems_locale!)
|
587
|
+
provider.action_start
|
588
|
+
end
|
589
|
+
|
590
|
+
it "stops the unit when it is active" do
|
591
|
+
current_resource.active(true)
|
592
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
593
|
+
.with("#{systemctl_path} --system stop #{unit_name}", {})
|
594
|
+
.and_return(shell_out_success)
|
595
|
+
provider.action_stop
|
596
|
+
end
|
597
|
+
|
598
|
+
it "does not stop the unit when it is inactive" do
|
599
|
+
current_resource.active(false)
|
600
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
601
|
+
provider.action_stop
|
602
|
+
end
|
603
|
+
end
|
604
|
+
end
|
605
|
+
|
606
|
+
describe "restarts/reloads the unit" do
|
607
|
+
context "when a user is specified" do
|
608
|
+
it "restarts the unit" do
|
609
|
+
current_resource.user(user_name)
|
610
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
611
|
+
.with("#{systemctl_path} --user restart #{unit_name}", user_cmd_opts)
|
612
|
+
.and_return(shell_out_success)
|
613
|
+
provider.action_restart
|
614
|
+
end
|
615
|
+
|
616
|
+
it "reloads the unit if active" do
|
617
|
+
current_resource.user(user_name)
|
618
|
+
current_resource.active(true)
|
619
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
620
|
+
.with("#{systemctl_path} --user reload #{unit_name}", user_cmd_opts)
|
621
|
+
.and_return(shell_out_success)
|
622
|
+
provider.action_reload
|
623
|
+
end
|
624
|
+
|
625
|
+
it "does not reload if the unit is inactive" do
|
626
|
+
current_resource.user(user_name)
|
627
|
+
current_resource.active(false)
|
628
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
629
|
+
provider.action_reload
|
630
|
+
end
|
631
|
+
end
|
632
|
+
|
633
|
+
context "when no user is specified" do
|
634
|
+
it "restarts the unit" do
|
635
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
636
|
+
.with("#{systemctl_path} --system restart #{unit_name}", {})
|
637
|
+
.and_return(shell_out_success)
|
638
|
+
provider.action_restart
|
639
|
+
end
|
640
|
+
|
641
|
+
it "reloads the unit if active" do
|
642
|
+
current_resource.active(true)
|
643
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
644
|
+
.with("#{systemctl_path} --system reload #{unit_name}", {})
|
645
|
+
.and_return(shell_out_success)
|
646
|
+
provider.action_reload
|
647
|
+
end
|
648
|
+
|
649
|
+
it "does not reload the unit if inactive" do
|
650
|
+
current_resource.active(false)
|
651
|
+
expect(provider).not_to receive(:shell_out_with_systems_locale!)
|
652
|
+
provider.action_reload
|
653
|
+
end
|
654
|
+
end
|
655
|
+
end
|
656
|
+
|
657
|
+
describe "try-restarts the unit" do
|
658
|
+
context "when a user is specified" do
|
659
|
+
it "try-restarts the unit" do
|
660
|
+
current_resource.user(user_name)
|
661
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
662
|
+
.with("#{systemctl_path} --user try-restart #{unit_name}", user_cmd_opts)
|
663
|
+
.and_return(shell_out_success)
|
664
|
+
provider.action_try_restart
|
665
|
+
end
|
666
|
+
end
|
667
|
+
|
668
|
+
context "when no user is specified" do
|
669
|
+
it "try-restarts the unit" do
|
670
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
671
|
+
.with("#{systemctl_path} --system try-restart #{unit_name}", {})
|
672
|
+
.and_return(shell_out_success)
|
673
|
+
provider.action_try_restart
|
674
|
+
end
|
675
|
+
end
|
676
|
+
end
|
677
|
+
|
678
|
+
describe "reload-or-restarts the unit" do
|
679
|
+
context "when a user is specified" do
|
680
|
+
it "reload-or-restarts the unit" do
|
681
|
+
current_resource.user(user_name)
|
682
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
683
|
+
.with("#{systemctl_path} --user reload-or-restart #{unit_name}", user_cmd_opts)
|
684
|
+
.and_return(shell_out_success)
|
685
|
+
provider.action_reload_or_restart
|
686
|
+
end
|
687
|
+
end
|
688
|
+
|
689
|
+
context "when no user is specified" do
|
690
|
+
it "reload-or-restarts the unit" do
|
691
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
692
|
+
.with("#{systemctl_path} --system reload-or-restart #{unit_name}", {})
|
693
|
+
.and_return(shell_out_success)
|
694
|
+
provider.action_reload_or_restart
|
695
|
+
end
|
696
|
+
end
|
697
|
+
end
|
698
|
+
|
699
|
+
describe "reload-or-try-restarts the unit" do
|
700
|
+
context "when a user is specified" do
|
701
|
+
it "reload-or-try-restarts the unit" do
|
702
|
+
current_resource.user(user_name)
|
703
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
704
|
+
.with("#{systemctl_path} --user reload-or-try-restart #{unit_name}", user_cmd_opts)
|
705
|
+
.and_return(shell_out_success)
|
706
|
+
provider.action_reload_or_try_restart
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
710
|
+
context "when no user is specified" do
|
711
|
+
it "reload-or-try-restarts the unit" do
|
712
|
+
expect(provider).to receive(:shell_out_with_systems_locale!)
|
713
|
+
.with("#{systemctl_path} --system reload-or-try-restart #{unit_name}", {})
|
714
|
+
.and_return(shell_out_success)
|
715
|
+
provider.action_reload_or_try_restart
|
716
|
+
end
|
717
|
+
end
|
718
|
+
end
|
719
|
+
|
720
|
+
describe "#active?" do
|
721
|
+
before(:each) do
|
722
|
+
provider.current_resource = current_resource
|
723
|
+
allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
|
724
|
+
end
|
725
|
+
|
726
|
+
context "when a user is specified" do
|
727
|
+
it "returns true when unit is active" do
|
728
|
+
current_resource.user(user_name)
|
729
|
+
expect(provider).to receive(:shell_out)
|
730
|
+
.with("#{systemctl_path} --user is-active #{unit_name}", user_cmd_opts)
|
731
|
+
.and_return(shell_out_success)
|
732
|
+
expect(provider.active?).to be true
|
733
|
+
end
|
734
|
+
|
735
|
+
it "returns false when unit is inactive" do
|
736
|
+
current_resource.user(user_name)
|
737
|
+
expect(provider).to receive(:shell_out)
|
738
|
+
.with("#{systemctl_path} --user is-active #{unit_name}", user_cmd_opts)
|
739
|
+
.and_return(shell_out_failure)
|
740
|
+
expect(provider.active?).to be false
|
741
|
+
end
|
742
|
+
end
|
743
|
+
|
744
|
+
context "when no user is specified" do
|
745
|
+
it "returns true when unit is active" do
|
746
|
+
expect(provider).to receive(:shell_out)
|
747
|
+
.with("#{systemctl_path} --system is-active #{unit_name}", {})
|
748
|
+
.and_return(shell_out_success)
|
749
|
+
expect(provider.active?).to be true
|
750
|
+
end
|
751
|
+
|
752
|
+
it "returns false when unit is not active" do
|
753
|
+
expect(provider).to receive(:shell_out)
|
754
|
+
.with("#{systemctl_path} --system is-active #{unit_name}", {})
|
755
|
+
.and_return(shell_out_failure)
|
756
|
+
expect(provider.active?).to be false
|
757
|
+
end
|
758
|
+
end
|
759
|
+
end
|
760
|
+
|
761
|
+
describe "#enabled?" do
|
762
|
+
before(:each) do
|
763
|
+
provider.current_resource = current_resource
|
764
|
+
allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
|
765
|
+
end
|
766
|
+
|
767
|
+
context "when a user is specified" do
|
768
|
+
it "returns true when unit is enabled" do
|
769
|
+
current_resource.user(user_name)
|
770
|
+
expect(provider).to receive(:shell_out)
|
771
|
+
.with("#{systemctl_path} --user is-enabled #{unit_name}", user_cmd_opts)
|
772
|
+
.and_return(shell_out_success)
|
773
|
+
expect(provider.enabled?).to be true
|
774
|
+
end
|
775
|
+
|
776
|
+
it "returns false when unit is not enabled" do
|
777
|
+
current_resource.user(user_name)
|
778
|
+
expect(provider).to receive(:shell_out)
|
779
|
+
.with("#{systemctl_path} --user is-enabled #{unit_name}", user_cmd_opts)
|
780
|
+
.and_return(shell_out_failure)
|
781
|
+
expect(provider.enabled?).to be false
|
782
|
+
end
|
783
|
+
end
|
784
|
+
|
785
|
+
context "when no user is specified" do
|
786
|
+
it "returns true when unit is enabled" do
|
787
|
+
expect(provider).to receive(:shell_out)
|
788
|
+
.with("#{systemctl_path} --system is-enabled #{unit_name}", {})
|
789
|
+
.and_return(shell_out_success)
|
790
|
+
expect(provider.enabled?).to be true
|
791
|
+
end
|
792
|
+
|
793
|
+
it "returns false when unit is not enabled" do
|
794
|
+
expect(provider).to receive(:shell_out)
|
795
|
+
.with("#{systemctl_path} --system is-enabled #{unit_name}", {})
|
796
|
+
.and_return(shell_out_failure)
|
797
|
+
expect(provider.enabled?).to be false
|
798
|
+
end
|
799
|
+
end
|
800
|
+
end
|
801
|
+
|
802
|
+
describe "#masked?" do
|
803
|
+
before(:each) do
|
804
|
+
provider.current_resource = current_resource
|
805
|
+
allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
|
806
|
+
end
|
807
|
+
|
808
|
+
context "when a user is specified" do
|
809
|
+
it "returns true when the unit is masked" do
|
810
|
+
current_resource.user(user_name)
|
811
|
+
expect(provider).to receive(:shell_out)
|
812
|
+
.with("#{systemctl_path} --user status #{unit_name}", user_cmd_opts)
|
813
|
+
.and_return(shell_out_masked)
|
814
|
+
expect(provider.masked?).to be true
|
815
|
+
end
|
816
|
+
|
817
|
+
it "returns false when the unit is not masked" do
|
818
|
+
current_resource.user(user_name)
|
819
|
+
expect(provider).to receive(:shell_out)
|
820
|
+
.with("#{systemctl_path} --user status #{unit_name}", user_cmd_opts)
|
821
|
+
.and_return(shell_out_static)
|
822
|
+
expect(provider.masked?).to be false
|
823
|
+
end
|
824
|
+
end
|
825
|
+
|
826
|
+
context "when no user is specified" do
|
827
|
+
it "returns true when the unit is masked" do
|
828
|
+
expect(provider).to receive(:shell_out)
|
829
|
+
.with("#{systemctl_path} --system status #{unit_name}", {})
|
830
|
+
.and_return(shell_out_masked)
|
831
|
+
expect(provider.masked?).to be true
|
832
|
+
end
|
833
|
+
|
834
|
+
it "returns false when the unit is not masked" do
|
835
|
+
expect(provider).to receive(:shell_out)
|
836
|
+
.with("#{systemctl_path} --system status #{unit_name}", {})
|
837
|
+
.and_return(shell_out_static)
|
838
|
+
expect(provider.masked?).to be false
|
839
|
+
end
|
840
|
+
end
|
841
|
+
end
|
842
|
+
|
843
|
+
describe "#static?" do
|
844
|
+
before(:each) do
|
845
|
+
provider.current_resource = current_resource
|
846
|
+
allow(provider).to receive(:which).with("systemctl").and_return("#{systemctl_path}")
|
847
|
+
end
|
848
|
+
|
849
|
+
context "when a user is specified" do
|
850
|
+
it "returns true when the unit is static" do
|
851
|
+
current_resource.user(user_name)
|
852
|
+
expect(provider).to receive(:shell_out)
|
853
|
+
.with("#{systemctl_path} --user is-enabled #{unit_name}", user_cmd_opts)
|
854
|
+
.and_return(shell_out_static)
|
855
|
+
expect(provider.static?).to be true
|
856
|
+
end
|
857
|
+
|
858
|
+
it "returns false when the unit is not static" do
|
859
|
+
current_resource.user(user_name)
|
860
|
+
expect(provider).to receive(:shell_out)
|
861
|
+
.with("#{systemctl_path} --user is-enabled #{unit_name}", user_cmd_opts)
|
862
|
+
.and_return(shell_out_masked)
|
863
|
+
expect(provider.static?).to be false
|
864
|
+
end
|
865
|
+
end
|
866
|
+
|
867
|
+
context "when no user is specified" do
|
868
|
+
it "returns true when the unit is static" do
|
869
|
+
expect(provider).to receive(:shell_out)
|
870
|
+
.with("#{systemctl_path} --system is-enabled #{unit_name}", {})
|
871
|
+
.and_return(shell_out_static)
|
872
|
+
expect(provider.static?).to be true
|
873
|
+
end
|
874
|
+
|
875
|
+
it "returns false when the unit is not static" do
|
876
|
+
expect(provider).to receive(:shell_out)
|
877
|
+
.with("#{systemctl_path} --system is-enabled #{unit_name}", {})
|
878
|
+
.and_return(shell_out_masked)
|
879
|
+
expect(provider.static?).to be false
|
880
|
+
end
|
881
|
+
end
|
882
|
+
end
|
883
|
+
end
|
884
|
+
end
|
885
|
+
end
|