diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-05-06 19:57:11 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-05-06 19:57:11 -0700 |
commit | b305c3134c9af268e9008e25487c6dfaf905410b (patch) | |
tree | 2b9e8b525cf96bebbc4920c56c4b2ec363b0912f /kitchen-tests | |
parent | 215ceafb1bbe0abeadf090fe0c1c18e073b41450 (diff) | |
download | chef-b305c3134c9af268e9008e25487c6dfaf905410b.tar.gz |
Expand our sudo, sysctl, execute, apt_update and apt_preference testing
Test more scenarios
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'kitchen-tests')
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/_apt.rb (renamed from kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb) | 12 | ||||
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/_sudo.rb | 63 | ||||
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb | 9 | ||||
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/_yum.rb | 16 | ||||
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/default.rb | 43 |
5 files changed, 113 insertions, 30 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_apt.rb index 6b492230f1..901cd8c36c 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/_apt_preference.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/_apt.rb @@ -3,12 +3,22 @@ # Recipe:: apt_preference # +apt_update "periodic apt update" do + frequency 86400 + action :periodic +end + apt_preference "dotdeb" do glob "*" pin "origin packages.dotdeb.org" pin_priority "700" end +apt_preference "a_fake_package" do + pin "version 5.1.49-3" + pin_priority "700" +end + apt_preference "libmysqlclient16" do action :remove -end
\ No newline at end of file +end diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_sudo.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_sudo.rb new file mode 100644 index 0000000000..4f08405ae9 --- /dev/null +++ b/kitchen-tests/cookbooks/end_to_end/recipes/_sudo.rb @@ -0,0 +1,63 @@ +# +# Cookbook:: end_to_end +# Recipe:: sudo +# + +sudo "sysadmins" do + users "bob_bobberson" + groups "sysadmins, superusers" + nopasswd true +end + +sudo "tomcat" do + user "%tomcat" + runas "app_user" + commands ["/etc/init.d/tomcat restart", "/etc/init.d/tomcat stop", "/etc/init.d/tomcat start"] + defaults ["!requiretty", "env_reset"] +end + +sudo "bob" do + user "bob" +end + +sudo "invalid.user" do + user "bob" +end + +sudo "tilde-invalid~user" do + user "bob" + action :create +end + +# Like above, but ensure the tilde at the front gets munged as well +sudo "~bob" do + user "bob" +end + +sudo "alice" do + user "alice" + command_aliases [{ name: "STARTSSH", command_list: ["/etc/init.d/ssh start", "/etc/init.d/ssh restart", "! /etc/init.d/ssh stop"] }] + commands ["STARTSSH"] +end + +sudo "git" do + user "git" + runas "phabricator" + nopasswd true + setenv true + commands ["/usr/bin/git-upload-pack", "/usr/bin/git-receive-pack"] +end + +sudo "jane" do + user "jane" + noexec true + commands ["/usr/bin/less"] +end + +sudo "rbenv" do + env_keep_add %w{PATH RBENV_ROOT RBENV_VERSION} +end + +sudo "java_home" do + env_keep_subtract ["JAVA_HOME"] +end diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb index 8c644e01c6..b5943180d0 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/_sysctl.rb @@ -8,5 +8,14 @@ sysctl "vm.swappiness" do end sysctl "kernel.msgmax" do + value 9000 +end + +sysctl "kernel.msgmax" do + action :remove +end + +sysctl_param "bogus.sysctl_val" do + value 9000 action :remove end
\ No newline at end of file diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_yum.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_yum.rb new file mode 100644 index 0000000000..f6f48a89c9 --- /dev/null +++ b/kitchen-tests/cookbooks/end_to_end/recipes/_yum.rb @@ -0,0 +1,16 @@ +bash "disable yum metadata caching" do + code <<-EOH + echo http_caching=packages >> /etc/yum.conf + EOH + only_if { File.exist?("/etc/yum.conf") && File.readlines("/etc/yum.conf").grep(/http_caching=packages/).empty? } +end + +yum_repository "epel" do + enabled true + description "Extra Packages for Enterprise Linux #{node["platform_version"].to_i} - $basearch" + failovermethod "priority" + gpgkey "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-#{node["platform_version"].to_i}" + gpgcheck true + mirrorlist "https://mirrors.fedoraproject.org/metalink?repo=epel-#{node["platform_version"].to_i}&arch=$basearch" + only_if { rhel? } +end
\ No newline at end of file diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb index b8ab746f55..efb3ff5367 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb @@ -11,27 +11,22 @@ apt_update chef_sleep "2" -timezone "UTC" +execute "sleep 1" -if platform_family?("rhel", "fedora", "amazon") - include_recipe "selinux::disabled" +execute "sleep 1 second" do + command "sleep 1" + live_stream true end -bash "disable yum metadata caching" do - code <<-EOH - echo http_caching=packages >> /etc/yum.conf - EOH - only_if { File.exist?("/etc/yum.conf") && File.readlines("/etc/yum.conf").grep(/http_caching=packages/).empty? } +execute "sensitive sleep" do + command "sleep 1" + sensitive true end -yum_repository "epel" do - enabled true - description "Extra Packages for Enterprise Linux #{node["platform_version"].to_i} - $basearch" - failovermethod "priority" - gpgkey "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-#{node["platform_version"].to_i}" - gpgcheck true - mirrorlist "https://mirrors.fedoraproject.org/metalink?repo=epel-#{node["platform_version"].to_i}&arch=$basearch" - only_if { rhel? } +timezone "UTC" + +if platform_family?("rhel", "fedora", "amazon") + include_recipe "selinux::disabled" end build_essential do @@ -51,18 +46,6 @@ end ssh_known_hosts_entry "github.com" -sudo "sysadmins" do - group ["sysadmin", "%superadmin"] - nopasswd true -end - -sudo "some_person" do - nopasswd true - user "some_person" - commands ["/opt/chef/bin/chef-client"] - env_keep_add %w{PATH RBENV_ROOT RBENV_VERSION} -end - include_recipe "chef-client::delete_validation" include_recipe "chef-client::config" @@ -122,9 +105,11 @@ locale "set system locale" do only_if { debian? } end +include_recipe "::_apt" if platform_family?("debian") +include_recipe "::_yum" if platform_family?("rhel") include_recipe "::_chef-vault" unless includes_recipe?("end_to_end::chef-vault") +include_recipe "::_sudo" include_recipe "::_sysctl" -include_recipe "::_apt_preference" include_recipe "::_alternatives" include_recipe "::_cron" include_recipe "::_ohai_hint" |