← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~jugmac00/launchpad:add-apache-config-to-copy-archive-publisher into launchpad:master

 

Jürgen Gmach has proposed merging ~jugmac00/launchpad:add-apache-config-to-copy-archive-publisher into launchpad:master.

Commit message:
Turn copy-archive-publisher into a subordinate charm

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/launchpad/+git/launchpad/+merge/453215
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/launchpad:add-apache-config-to-copy-archive-publisher into launchpad:master.
diff --git a/charm/launchpad-copy-archive-publisher/charmcraft.yaml b/charm/launchpad-copy-archive-publisher/charmcraft.yaml
index f6278aa..b3b3126 100644
--- a/charm/launchpad-copy-archive-publisher/charmcraft.yaml
+++ b/charm/launchpad-copy-archive-publisher/charmcraft.yaml
@@ -48,10 +48,23 @@ parts:
       - layers
     prime:
       - "-layers"
+  interface-apache-website:
+    source: https://github.com/juju-solutions/interface-apache-website
+    source-commit: "2f736ebcc90d19ac142a2d898a2ec7e1aafaa13f"
+    source-submodules: []
+    source-type: git
+    plugin: dump
+    organize:
+      "*": layers/interface/apache-website/
+    stage:
+      - layers
+    prime:
+      - "-layers"
   charm:
     after:
       - charm-wheels
       - launchpad-layers
+      - interface-apache-website
     source: .
     plugin: reactive
     build-snaps: [charm]
diff --git a/charm/launchpad-copy-archive-publisher/config.yaml b/charm/launchpad-copy-archive-publisher/config.yaml
index e1009bf..6f5a431 100644
--- a/charm/launchpad-copy-archive-publisher/config.yaml
+++ b/charm/launchpad-copy-archive-publisher/config.yaml
@@ -3,6 +3,10 @@ options:
     type: boolean
     default: true
     description: If true, enable jobs that may change the database.
+  domain:
+    type: string
+    description: Domain name for this instance.
+    default: "launchpad.test"
   signing_client_public_key:
     type: string
     description: Public key for encrypting communication between client and signing service. 
diff --git a/charm/launchpad-copy-archive-publisher/layer.yaml b/charm/launchpad-copy-archive-publisher/layer.yaml
index c314294..da8e726 100644
--- a/charm/launchpad-copy-archive-publisher/layer.yaml
+++ b/charm/launchpad-copy-archive-publisher/layer.yaml
@@ -1,12 +1,14 @@
 includes:
   - layer:launchpad-db
   - layer:launchpad-publisher-parts
+  - interface:apache-website
 repo: https://git.launchpad.net/launchpad
 options:
   apt:
     packages:
       - launchpad-soyuz-dependencies
       - procmail # Needed for the 'lockfile' command.
+      - libapache2-mod-wsgi-py3
   ols-pg:
     databases:
       db:
diff --git a/charm/launchpad-copy-archive-publisher/metadata.yaml b/charm/launchpad-copy-archive-publisher/metadata.yaml
index 7a45716..50da3ed 100644
--- a/charm/launchpad-copy-archive-publisher/metadata.yaml
+++ b/charm/launchpad-copy-archive-publisher/metadata.yaml
@@ -7,4 +7,8 @@ maintainer: Launchpad Developers <launchpad-dev@xxxxxxxxxxxxxxxxxxx>
 description: |
   Launchpad is an open source suite of tools that help people and teams
   to work together on software projects.
-subordinate: false
+subordinate: true
+requires:
+  apache-website:
+    interface: apache-website
+    scope: container
diff --git a/charm/launchpad-copy-archive-publisher/reactive/launchpad-copy-archive-publisher.py b/charm/launchpad-copy-archive-publisher/reactive/launchpad-copy-archive-publisher.py
index 5a9ae67..07d27bf 100644
--- a/charm/launchpad-copy-archive-publisher/reactive/launchpad-copy-archive-publisher.py
+++ b/charm/launchpad-copy-archive-publisher/reactive/launchpad-copy-archive-publisher.py
@@ -8,6 +8,7 @@ from charms.launchpad.base import configure_email, get_service_config
 from charms.launchpad.payload import configure_cron, configure_lazr
 from charms.launchpad.publisher_parts import publisher_parts_dir
 from charms.reactive import (
+    endpoint_from_flag,
     remove_state,
     set_state,
     when,
@@ -82,3 +83,23 @@ def check_is_running():
 )
 def deconfigure():
     remove_state("service.configured")
+
+
+@when("apache-website.available", "service.configured")
+@when_not("service.apache-website.configured")
+def configure_apache_website():
+    apache_website = endpoint_from_flag("apache-website.available")
+    config = dict(hookenv.config())
+    apache_website.set_remote(
+        domain=config["domain"],
+        enabled="true",
+        ports="80",
+        site_config=templating.render("vhost.conf.j2", None, config),
+    )
+    set_state("service.apache-website.configured")
+
+
+@when("service.apache-website.configured")
+@when_not_all("apache-website.available", "service.configured")
+def deconfigure_apache_website():
+    remove_state("service.apache-website.configured")
diff --git a/charm/launchpad-copy-archive-publisher/templates/derived.vhost.conf.j2 b/charm/launchpad-copy-archive-publisher/templates/derived.vhost.conf.j2
new file mode 100644
index 0000000..cbd1539
--- /dev/null
+++ b/charm/launchpad-copy-archive-publisher/templates/derived.vhost.conf.j2
@@ -0,0 +1,15 @@
+<VirtualHost *:80>
+	ServerName derived.archive.canonical.com
+
+	CustomLog /var/log/apache2/derived.archive.canonical.com-access.log combined
+	ErrorLog /var/log/apache2/derived.archive.canonical.com-error.log
+
+	DocumentRoot /srv/launchpad.net/archives/
+
+	<Directory /srv/launchpad.net/archives>
+		Options Indexes FollowSymLinks
+		AllowOverride None
+		Require all granted
+	</Directory>
+
+</VirtualHost>
diff --git a/charm/launchpad-copy-archive-publisher/templates/rebuild-test.vhost.conf.j2 b/charm/launchpad-copy-archive-publisher/templates/rebuild-test.vhost.conf.j2
new file mode 100644
index 0000000..d4ef0a8
--- /dev/null
+++ b/charm/launchpad-copy-archive-publisher/templates/rebuild-test.vhost.conf.j2
@@ -0,0 +1,19 @@
+<VirtualHost *:80>
+        #NOWEBSTATS
+        ServerName rebuild-test.internal
+        ServerAlias toolchain.ubuntu.com
+        ServerAlias rebuild-test.ubuntu.com
+
+        CustomLog /var/log/apache2/rebuild-test.internal.access.log combined
+        ErrorLog /var/log/apache2/rebuild-test.internal.error.log
+
+        DocumentRoot /srv/rebuild-test.internal/ftp
+        Alias /ubuntu "/srv/rebuild-test.internal/ftp"
+
+        <Directory "/srv/rebuild-test.internal/">
+          IndexOptions NameWidth=* +SuppressDescription
+          Options +Indexes +FollowSymLinks
+          IndexIgnore favicon.ico
+          Require all granted
+        </Directory>
+</VirtualHost>

Follow ups