From 564f6e5a0804ede2dad4eebad9082858a520db63 Mon Sep 17 00:00:00 2001 From: Martin Kalcok <69471063+mkalcok@users.noreply.github.com> Date: Fri, 19 Aug 2022 20:08:14 +0200 Subject: [PATCH] Ubuntu Jammy support. (#96) * Ubuntu Jammy support. * Add build instructions to README.md --- README.md | 15 +++++++++++++++ charmcraft.yaml | 32 ++++++++++++++++++++++++++++++++ reactive/filebeat.py | 13 ++++++------- templates/filebeat-6.yml | 6 ++++++ wheelhouse.txt | 1 - 5 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 charmcraft.yaml delete mode 100644 wheelhouse.txt diff --git a/README.md b/README.md index 11faf34..544ee3e 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,21 @@ To monitor additional applications, simply relate the filebeat subordinate: juju add-relation filebeat:beats-host my-charm +## Build and publish new versions + +This charm uses the reactive framework. `charm pack` is used to build a +deployable charm. In order to publish new versions of the charm, the following +commands need to be run: + +**Note:** Use appropriate revision number in `charmcraft release` command. + +``` +charmcraft pack +charmcraft upload filebeat_ubuntu-22.04-amd64_ubuntu-20.04-amd64_ubuntu-18.04-amd64.charm +charmcraft release filebeat --revision=34 --channel=edge +charmcraft status filebeat +``` + ## Contact Information - diff --git a/charmcraft.yaml b/charmcraft.yaml new file mode 100644 index 0000000..d3ceb26 --- /dev/null +++ b/charmcraft.yaml @@ -0,0 +1,32 @@ +# Learn more about charmcraft.yaml configuration at: +# https://juju.is/docs/sdk/charmcraft-config +# This is a template `charmcraft.yaml` file for reactive charms +# This file is managed by bootstack-charms-spec and should not be modified +# within individual charm repos. https://launchpad.net/bootstack-charms-spec + +type: charm + +parts: + charm: + source: ./ + plugin: reactive + build-snaps: [ charm ] + +bases: + - build-on: + - name: ubuntu + channel: "20.04" + architectures: ["amd64"] + run-on: + - name: ubuntu + channel: "22.04" + architectures: + - amd64 + - name: ubuntu + channel: "20.04" + architectures: + - amd64 + - name: ubuntu + channel: "18.04" + architectures: + - amd64 \ No newline at end of file diff --git a/reactive/filebeat.py b/reactive/filebeat.py index 96ba800..3a35790 100644 --- a/reactive/filebeat.py +++ b/reactive/filebeat.py @@ -6,7 +6,6 @@ from charms.reactive import remove_state from charms.reactive import hook from charms.reactive.helpers import data_changed -from charms.templating.jinja2 import render from charmhelpers.core import unitdata from charmhelpers.core.hookenv import config, log @@ -108,13 +107,13 @@ def manage_filebeat_logstash_ssl(): key = base64.b64decode(logstash_ssl_key).decode('utf8') if data_changed('logstash_cert', cert): - render(template='{{ data }}', - context={'data': cert}, - target=LOGSTASH_SSL_CERT, perms=0o444) + with open(LOGSTASH_SSL_CERT, "w") as cert_file: + cert_file.write(cert) + os.chmod(LOGSTASH_SSL_CERT, 0o444) if data_changed('logstash_key', key): - render(template='{{ data }}', - context={'data': key}, - target=LOGSTASH_SSL_KEY, perms=0o400) + with open(LOGSTASH_SSL_KEY, "w") as key_file: + key_file.write(key) + os.chmod(LOGSTASH_SSL_KEY, 0o400) else: if not logstash_ssl_cert and os.path.exists(LOGSTASH_SSL_CERT): os.remove(LOGSTASH_SSL_CERT) diff --git a/templates/filebeat-6.yml b/templates/filebeat-6.yml index 007efeb..34f48b1 100644 --- a/templates/filebeat-6.yml +++ b/templates/filebeat-6.yml @@ -133,3 +133,9 @@ output: {% if juju_principal_unit -%} name: {{ juju_principal_unit }} {%- endif %} +seccomp: + default_action: errno + syscalls: + - action: allow + names: + - clone3 diff --git a/wheelhouse.txt b/wheelhouse.txt deleted file mode 100644 index 5792c82..0000000 --- a/wheelhouse.txt +++ /dev/null @@ -1 +0,0 @@ -charms.templating.jinja2>1.0.0,<=2.0.0ri