Merge ~przemeklal/charm-juju-ro:add-apache2 into charm-juju-ro:main

Proposed by Przemyslaw Lal
Status: Work in progress
Proposed branch: ~przemeklal/charm-juju-ro:add-apache2
Merge into: charm-juju-ro:main
Prerequisite: ~przemeklal/charm-juju-ro:initial-code-drop
Diff against target: 73 lines (+16/-6)
2 files modified
config.yaml (+1/-1)
src/charm.py (+15/-5)
Reviewer Review Type Date Requested Status
Jose Guedez (community) Needs Fixing
Paul Goins Approve
BootStack Reviewers mr tracking; do not claim Pending
Review via email: mp+423550@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Goins (vultaire) wrote :

LGTM.

review: Approve
Revision history for this message
Jose Guedez (jfguedez) wrote :

Overall looks good. Just a couple comments inline that might help maintainability going forward.

review: Needs Fixing
Revision history for this message
Eric Chen (eric-chen) wrote :

Mark it as WIP until Przemeklal has time to fix it.

Unmerged commits

aa64d7d... by Przemyslaw Lal

Publish juju-ro output using apache2

Signed-off-by: Przemyslaw Lal <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index ff36f8c..a49bec0 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -11,7 +11,7 @@ options:
6 dumpdirectory:
7 type: string
8 description: "location to store the juju status output and dump the bundles."
9- default: "/var/lib/jujureadonly"
10+ default: "/var/www/html"
11 interval:
12 type: int
13 default: 30
14diff --git a/src/charm.py b/src/charm.py
15index eb213f6..ca8742f 100755
16--- a/src/charm.py
17+++ b/src/charm.py
18@@ -13,6 +13,7 @@ outputs and bundle exports.
19 import pathlib
20 import os
21 import logging
22+import subprocess
23
24 from ops.charm import CharmBase
25 from ops.framework import StoredState
26@@ -29,6 +30,8 @@ from charms.juju_ro.v0.lib_juju_addons import (
27
28 logger = logging.getLogger(__name__)
29
30+APACHE2_DEFAULT_HTML_DIR = "/var/www/html/"
31+APACHE2_DEFAULT_HTML_FILE = APACHE2_DEFAULT_HTML_DIR + "index.html"
32
33 class JujuROHelper:
34 """Juju Sanitizer helper object."""
35@@ -109,10 +112,18 @@ class JujuRoCharm(CharmBase):
36 }
37 self.logger = logging.getLogger(__name__)
38
39- def on_install(self, event):
40- """Install juju snap and cron scripts."""
41+ def install_services(self):
42+ subprocess.check_call(["apt-get", "install", "-y", "apache2"])
43+ # remove the default Apache2 HTML file as we don't need it
44+ if os.path.exists(APACHE2_DEFAULT_HTML_FILE):
45+ os.unlink(APACHE2_DEFAULT_HTML_FILE)
46+
47 self.jujuro_helper.install_snap()
48 self.jujuro_helper.install_scripts()
49+
50+ def on_install(self, event):
51+ """Install juju snap, cron scripts and apache server."""
52+ self.install_services()
53 self.state.installed = True
54 self.update_status(event)
55
56@@ -120,8 +131,7 @@ class JujuRoCharm(CharmBase):
57 """Handle upgrade and resource updates."""
58 # Reinstall snaps and scripts
59 logging.info("upgrade-charm: reinstall")
60- self.jujuro_helper.install_snap()
61- self.jujuro_helper.install_scripts()
62+ self.install_services()
63 self.update_status(event)
64
65 def config_juju_readonly_user(self):
66@@ -139,7 +149,7 @@ class JujuRoCharm(CharmBase):
67 self.ctxt["dumpdir"],
68 owner=self.ctxt["user"],
69 group=self.ctxt["group"],
70- perms=0o700,
71+ perms=0o755,
72 force=True,
73 )
74

Subscribers

People subscribed via source and target branches

to all changes: