]> git.openstreetmap.org Git - chef.git/commitdiff
Add test for dns cookbook
authorTom Hughes <tom@compton.nu>
Thu, 25 Jun 2020 19:32:50 +0000 (19:32 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 25 Jun 2020 19:32:50 +0000 (19:32 +0000)
.github/workflows/test-kitchen.yml
.kitchen.yml
cookbooks/dns/attributes/default.rb [new file with mode: 0644]
cookbooks/dns/metadata.rb
cookbooks/dns/recipes/default.rb
roles/dns.rb
test/data_bags/dns/passwords.json [new file with mode: 0644]
test/integration/dns/serverspec/apache_spec.rb [new file with mode: 0644]

index fbe5238fea492d1ce892b8f96ed71581e6c3feef..61290de5fb553b0bf470a7ab1217f091ebb82d0b 100644 (file)
@@ -25,6 +25,7 @@ jobs:
           - devices
           - dhcpd
           - dmca
+          - dns
           - docker
           - donate
           - elasticsearch
index 133d124eea8396df116445f4467ca86f5aa1fbb0..17d9839f6080f4b134af0ca6785d1d5205c2c6be 100644 (file)
@@ -93,6 +93,9 @@ suites:
   - name: dmca
     run_list:
       - recipe[dmca::default]
+  - name: dns
+    run_list:
+      - recipe[dns::default]
   - name: docker
     run_list:
       - recipe[docker::default]
diff --git a/cookbooks/dns/attributes/default.rb b/cookbooks/dns/attributes/default.rb
new file mode 100644 (file)
index 0000000..5bc8153
--- /dev/null
@@ -0,0 +1,3 @@
+default[:dns][:repository] = "/var/lib/git/public/dns.git"
+
+default[:accounts][:users][:git][:status] = :role
index ee177a46b81c26c660eb0eba8e17c3145c55f7be..fb112068119ccb5be9e87dd923fc7e5f45cf04f8 100644 (file)
@@ -6,5 +6,6 @@ description       "Configure DNS management"
 
 version           "1.0.0"
 supports          "ubuntu"
-depends           "git"
+depends           "accounts"
 depends           "apache"
+depends           "git"
index 2fbca1f24ade32adf57b1a808100875c7490a852..4d21c21f76786eef06fceac503b10fea3f46475b 100644 (file)
@@ -17,8 +17,9 @@
 # limitations under the License.
 #
 
-include_recipe "git"
+include_recipe "accounts"
 include_recipe "apache"
+include_recipe "git"
 
 geoservers = search(:node, "roles:geodns").collect(&:name).sort
 
@@ -132,6 +133,7 @@ cookbook_file "#{node[:dns][:repository]}/hooks/post-receive" do
   owner "git"
   group "git"
   mode 0o750
+  only_if { ::Dir.exist?("#{node[:dns][:repository]}/hooks") }
 end
 
 template "/usr/local/bin/dns-check" do
index 25ac17f00d2eb30ebfbedced23177de58766a525..c2af27b5895a809a3c2306f6f05aec7b2558aee2 100644 (file)
@@ -1,12 +1,6 @@
 name "dns"
 description "Role applied to DNS management servers"
 
-default_attributes(
-  :dns => {
-    :repository => "/var/lib/git/public/dns.git"
-  }
-)
-
 run_list(
   "recipe[dns]"
 )
diff --git a/test/data_bags/dns/passwords.json b/test/data_bags/dns/passwords.json
new file mode 100644 (file)
index 0000000..cd7b6c9
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "id": "passwords",
+  "rsync": "rsync",
+  "statuscake": "statuscake",
+  "gandi": "gandi",
+  "cloudflare": "cloudflare"
+}
diff --git a/test/integration/dns/serverspec/apache_spec.rb b/test/integration/dns/serverspec/apache_spec.rb
new file mode 100644 (file)
index 0000000..446d3b9
--- /dev/null
@@ -0,0 +1,21 @@
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe package("apache2") do
+  it { should be_installed }
+end
+
+describe service("apache2") do
+  it { should be_enabled }
+  it { should be_running }
+end
+
+describe port(80) do
+  it { should be_listening.with("tcp") }
+end
+
+describe port(443) do
+  it { should be_listening.with("tcp") }
+end