From: Tom Hughes Date: Thu, 13 Feb 2020 22:39:44 +0000 (+0000) Subject: Add basic tests for clamav, exim and spamassassin cookbooks X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/d1406cdadc022639bc0c3121c801f8997c331363?ds=sidebyside Add basic tests for clamav, exim and spamassassin cookbooks --- diff --git a/.kitchen.yml b/.kitchen.yml index d5132931b..0f9e0f7a1 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -42,6 +42,12 @@ suites: run_list: - recipe[accounts::default] - recipe[blogs::default] + - name: clamav + run_list: + - recipe[clamav::default] + - name: exim + run_list: + - recipe[exim::default] - name: forum run_list: - recipe[accounts::default] @@ -78,6 +84,9 @@ suites: - name: python run_list: - recipe[python::default] + - name: spamassassin + run_list: + - recipe[spamassassin::default] - name: tools run_list: - recipe[tools::default] diff --git a/.travis.yml b/.travis.yml index e5568cf8e..9cd34d6e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,12 @@ jobs: - name: "Test Kitchen (blogs)" script: - bundle exec kitchen test blogs-ubuntu-1804 + - name: "Test Kitchen (clamav)" + script: + - bundle exec kitchen test clamav-ubuntu-1804 + - name: "Test Kitchen (exim)" + script: + - bundle exec kitchen test exim-ubuntu-1804 - name: "Test Kitchen (forum)" script: - bundle exec kitchen test forum-ubuntu-1804 @@ -50,6 +56,9 @@ jobs: - name: "Test Kitchen (python)" script: - bundle exec kitchen test python-ubuntu-1804 + - name: "Test Kitchen (spamassassin)" + script: + - bundle exec kitchen test spamassassin-ubuntu-1804 - name: "Test Kitchen (tools)" script: - bundle exec kitchen test tools-ubuntu-1804 diff --git a/cookbooks/clamav/recipes/default.rb b/cookbooks/clamav/recipes/default.rb index 8e07f4fb7..3c95527ce 100644 --- a/cookbooks/clamav/recipes/default.rb +++ b/cookbooks/clamav/recipes/default.rb @@ -30,6 +30,13 @@ template "/etc/clamav-unofficial-sigs.conf.d/50-chef.conf" do mode 0o644 end +execute "freshclam" do + command "/usr/bin/freshclam" + user "clamav" + group "clamav" + not_if { ::File.exist?("/var/lib/clamav/daily.cvd") } +end + service "clamav-daemon" do action [:enable, :start] supports :status => true, :restart => true diff --git a/cookbooks/exim/metadata.rb b/cookbooks/exim/metadata.rb index 754ee82de..0c083b991 100644 --- a/cookbooks/exim/metadata.rb +++ b/cookbooks/exim/metadata.rb @@ -6,6 +6,7 @@ description "Installs and configures exim" version "1.0.0" supports "ubuntu" +depends "accounts" +depends "apache" depends "networking" depends "ssl" -depends "apache" diff --git a/cookbooks/spamassassin/metadata.rb b/cookbooks/spamassassin/metadata.rb index 470463eaf..acd564bf7 100644 --- a/cookbooks/spamassassin/metadata.rb +++ b/cookbooks/spamassassin/metadata.rb @@ -6,3 +6,4 @@ description "Installs and configures spamassassin" version "1.0.0" supports "ubuntu" +depends "exim" diff --git a/test/integration/clamav/serverspec/clamav_spec.rb b/test/integration/clamav/serverspec/clamav_spec.rb new file mode 100644 index 000000000..ce8687e5b --- /dev/null +++ b/test/integration/clamav/serverspec/clamav_spec.rb @@ -0,0 +1,22 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("clamav-daemon") do + it { should be_installed } +end + +describe service("clamav-daemon") do + it { should be_enabled } + it { should be_running } +end + +describe package("clamav-freshclam") do + it { should be_installed } +end + +describe service("clamav-freshclam") do + it { should be_enabled } + it { should be_running } +end diff --git a/test/integration/exim/serverspec/exim_spec.rb b/test/integration/exim/serverspec/exim_spec.rb new file mode 100644 index 000000000..752a58ad4 --- /dev/null +++ b/test/integration/exim/serverspec/exim_spec.rb @@ -0,0 +1,17 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("exim4") do + it { should be_installed } +end + +describe service("exim4") do + it { should be_enabled } + it { should be_running } +end + +describe port(25) do + it { should be_listening } +end diff --git a/test/integration/spamassassin/serverspec/spamassassin_spec.rb b/test/integration/spamassassin/serverspec/spamassassin_spec.rb new file mode 100644 index 000000000..2f2e643cf --- /dev/null +++ b/test/integration/spamassassin/serverspec/spamassassin_spec.rb @@ -0,0 +1,17 @@ +require "serverspec" + +# Required by serverspec +set :backend, :exec + +describe package("spamassassin") do + it { should be_installed } +end + +describe service("spamassassin") do + it { should be_enabled } + it { should be_running } +end + +describe port(783) do + it { should be_listening } +end