launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30404
[Merge] ~cjwatson/launchpad:charm-ftpmaster-apache-website into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:charm-ftpmaster-apache-website into launchpad:master.
Commit message:
charm: Set up Apache relation for ftpmaster-publisher
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/449266
Apache needs to run on the same machine as the publisher so that it can serve the published data. The easiest way to do that is to convert the publisher into a subordinate charm and implement the `apache-website` relation, which will allow us to deploy it in conjunction with the standard `apache2` charm.
The virtual host configuration here is based on what's currently in production.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:charm-ftpmaster-apache-website into launchpad:master.
diff --git a/charm/launchpad-ftpmaster-publisher/charmcraft.yaml b/charm/launchpad-ftpmaster-publisher/charmcraft.yaml
index 96c2906..bf2137d 100644
--- a/charm/launchpad-ftpmaster-publisher/charmcraft.yaml
+++ b/charm/launchpad-ftpmaster-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-ftpmaster-publisher/config.yaml b/charm/launchpad-ftpmaster-publisher/config.yaml
index e1009bf..d871574 100644
--- a/charm/launchpad-ftpmaster-publisher/config.yaml
+++ b/charm/launchpad-ftpmaster-publisher/config.yaml
@@ -3,6 +3,10 @@ options:
type: boolean
default: true
description: If true, enable jobs that may change the database.
+ domain_ftpmaster:
+ type: string
+ description: Domain name for the published Ubuntu archive.
+ default: "archive.ubuntu.test"
signing_client_public_key:
type: string
description: Public key for encrypting communication between client and signing service.
@@ -15,3 +19,7 @@ options:
type: string
description: Endpoint for the signing service.
default: ""
+ webmaster_email:
+ type: string
+ description: Webmaster contact address.
+ default: "webmaster@xxxxxxxxxxxxxx"
diff --git a/charm/launchpad-ftpmaster-publisher/layer.yaml b/charm/launchpad-ftpmaster-publisher/layer.yaml
index 7a9f279..b027581 100644
--- a/charm/launchpad-ftpmaster-publisher/layer.yaml
+++ b/charm/launchpad-ftpmaster-publisher/layer.yaml
@@ -1,6 +1,7 @@
includes:
- layer:launchpad-db
- layer:launchpad-publisher-parts
+ - interface:apache-website
repo: https://git.launchpad.net/launchpad
options:
ols-pg:
diff --git a/charm/launchpad-ftpmaster-publisher/metadata.yaml b/charm/launchpad-ftpmaster-publisher/metadata.yaml
index f299db3..4664dfa 100644
--- a/charm/launchpad-ftpmaster-publisher/metadata.yaml
+++ b/charm/launchpad-ftpmaster-publisher/metadata.yaml
@@ -12,4 +12,8 @@ tags:
- network
series:
- focal
-subordinate: false
+subordinate: true
+requires:
+ apache-website:
+ interface: apache-website
+ scope: container
diff --git a/charm/launchpad-ftpmaster-publisher/reactive/launchpad-ftpmaster-publisher.py b/charm/launchpad-ftpmaster-publisher/reactive/launchpad-ftpmaster-publisher.py
index 925592a..0342c89 100644
--- a/charm/launchpad-ftpmaster-publisher/reactive/launchpad-ftpmaster-publisher.py
+++ b/charm/launchpad-ftpmaster-publisher/reactive/launchpad-ftpmaster-publisher.py
@@ -1,17 +1,25 @@
# Copyright 2023 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-from charmhelpers.core import hookenv, templating
+import os.path
+
+from charmhelpers.core import hookenv, host, templating
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,
when_not,
when_not_all,
)
+from ols import base
+
+
+def archives_dir():
+ return os.path.join(base.base_dir(), "archives")
def configure_logrotate(config):
@@ -32,6 +40,10 @@ def configure_logrotate(config):
def configure():
hookenv.log("Configuring ftpmaster publisher")
config = get_service_config()
+ config["archives_dir"] = archives_dir()
+ host.mkdir(
+ archives_dir(), owner=base.user(), group=base.user(), perms=0o755
+ )
config["run_parts_location"] = publisher_parts_dir()
configure_lazr(
@@ -63,3 +75,24 @@ 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())
+ config["archives_dir"] = archives_dir()
+ apache_website.set_remote(
+ domain=config["domain_ftpmaster"],
+ 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-ftpmaster-publisher/templates/launchpad-ftpmaster-publisher-lazr.conf.j2 b/charm/launchpad-ftpmaster-publisher/templates/launchpad-ftpmaster-publisher-lazr.conf.j2
index 2eb43c9..35dfef2 100644
--- a/charm/launchpad-ftpmaster-publisher/templates/launchpad-ftpmaster-publisher-lazr.conf.j2
+++ b/charm/launchpad-ftpmaster-publisher/templates/launchpad-ftpmaster-publisher-lazr.conf.j2
@@ -10,6 +10,7 @@
extends: ../launchpad-db-lazr.conf
[archivepublisher]
+archives_dir: {{ archives_dir }}
run_parts_location: {{ run_parts_location }}
[signing]
diff --git a/charm/launchpad-ftpmaster-publisher/templates/vhost.conf.j2 b/charm/launchpad-ftpmaster-publisher/templates/vhost.conf.j2
new file mode 100644
index 0000000..5206c4a
--- /dev/null
+++ b/charm/launchpad-ftpmaster-publisher/templates/vhost.conf.j2
@@ -0,0 +1,19 @@
+<VirtualHost *:80>
+ ServerName {{ domain_ftpmaster }}
+
+ DocumentRoot {{ archives_dir }}/
+
+ CustomLog /var/log/apache2/{{ domain_ftpmaster }}-access.log combined
+ ErrorLog /var/log/apache2/{{ domain_ftpmaster }}-error.log
+
+{% for distribution in ("ubuntu", "ubuntu-partner") %}
+ <Directory "{{ archives_dir }}/{{ distribution }}/">
+ IndexOptions NameWidth=* +SuppressDescription
+ Options +Indexes +FollowSymLinks
+ IndexIgnore favicon.ico
+ AllowOverride None
+ Require all granted
+ </Directory>
+{% endfor %}
+</VirtualHost>
+
Follow ups