]> git.openstreetmap.org Git - chef.git/commitdiff
Add test for trac cookbook
authorTom Hughes <tom@compton.nu>
Wed, 19 Feb 2020 23:33:41 +0000 (23:33 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 19 Feb 2020 23:33:41 +0000 (23:33 +0000)
.kitchen.yml
.travis.yml
cookbooks/trac/attributes/default.rb [new file with mode: 0644]
cookbooks/trac/metadata.rb
cookbooks/trac/recipes/default.rb
roles/trac.rb
test/data_bags/accounts/trac.json [new file with mode: 0644]
test/integration/trac/serverspec/apache_spec.rb [new file with mode: 0644]

index ec4e81755f4852c06720bf0c51fa20a8d21a9bda..2e48b43d527ed0ac7b1870b3e3823606e5ffb68e 100644 (file)
@@ -219,6 +219,9 @@ suites:
   - name: tools
     run_list:
       - recipe[tools::default]
+  - name: trac
+    run_list:
+      - recipe[trac::default]
   - name: web-backend
     run_list:
       - recipe[web::backend]
index e5f5b0b23d0667f241fcba9f87fd6c75340410ef..4df85e1041bc37945e3952652c2dd2306cf4d988 100644 (file)
@@ -163,6 +163,9 @@ jobs:
     - name: "Test Kitchen (tools)"
       script:
         - bundle exec kitchen test tools-ubuntu-1804
+    - name: "Test Kitchen (trac)"
+      script:
+        - bundle exec kitchen test trac-ubuntu-1804
     - name: "Test Kitchen (web::backend)"
       script:
         - bundle exec kitchen test web-backend-ubuntu-1804
diff --git a/cookbooks/trac/attributes/default.rb b/cookbooks/trac/attributes/default.rb
new file mode 100644 (file)
index 0000000..1683a2a
--- /dev/null
@@ -0,0 +1 @@
+default[:accounts][:users][:trac][:status] = :role
index 57fe9e358f1518472c3abd4a8e9b496c6cea429c..4c308e1e19c12c27a1817f2ee3c9ee7f6b4de16f 100644 (file)
@@ -6,4 +6,5 @@ description       "Installs and configures trac servers"
 
 version           "1.0.0"
 supports          "ubuntu"
+depends           "accounts"
 depends           "apache"
index 8c397db8a6f943e8725cc6aec8a13f4767f4f205..347b41b9bb67924e683d22f6a28d2c7f8d7d31d3 100644 (file)
 # limitations under the License.
 #
 
+include_recipe "accounts"
 include_recipe "apache"
 
 package %w[
   trac
-  trac-git
   ruby
 ]
 
 site_name = "trac.openstreetmap.org"
 site_directory = "/srv/#{site_name}"
 
+directory "/var/lib/trac" do
+  owner "trac"
+  group "trac"
+  mode 0o755
+end
+
+execute "trac-initenv-#{site_name}" do
+  command "trac-admin /var/lib/trac initenv #{site_name} sqlite:db/trac.db"
+  user "trac"
+  group "trac"
+  not_if { ::File.exist?("/var/lib/trac/VERSION") }
+end
+
 template "/var/lib/trac/conf/trac.ini" do
   source "trac.ini.erb"
   owner "trac"
@@ -73,6 +86,10 @@ end
 
 apache_module "wsgi"
 
+apache_module "authnz_external" do
+  package "libapache2-mod-authnz-external"
+end
+
 ssl_certificate "trac.openstreetmap.org" do
   domains ["trac.openstreetmap.org", "trac.osm.org"]
   notifies :reload, "service[apache2]"
index 8f916ed13ebbfe65e320f86fc9658537ab3e90a7..9276c88951aa4ac980b9508d803ea2f1af5dd39a 100644 (file)
@@ -1,13 +1,6 @@
 name "trac"
 description "Role applied to all trac servers"
 
-default_attributes(
-  :accounts => {
-    :users => {
-      :trac => { :status => :role }
-    }
-  }
-)
 run_list(
   "recipe[trac]"
 )
diff --git a/test/data_bags/accounts/trac.json b/test/data_bags/accounts/trac.json
new file mode 100644 (file)
index 0000000..9c89cb1
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "id": "trac",
+  "uid": "509",
+  "comment": "trac.openstreetmap.org",
+  "home": "/var/lib/trac",
+  "manage_home": false
+}
diff --git a/test/integration/trac/serverspec/apache_spec.rb b/test/integration/trac/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