Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Podman systemd #50

Merged
merged 10 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes and corrections
  • Loading branch information
Robert Fekete authored and Robert Fekete committed Feb 20, 2024
commit 4b04cea71e93026de60beb26d53af203e690bfdf
35 changes: 21 additions & 14 deletions content/install/podman-systemd/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ The steps in this procedure were tested on CentOS 9, but should work on other si

1. Edit the unit file as needed for your environment.

- We recommend using the mount points suggested.
We recommend using the default mount points:

| Purpose | On the host | In the container |
| -------- | ------- | ------- |
| Disk-buffer and persist files | `/var/lib/syslog-ng` | `/var/lib/syslog-ng` |
| `syslog-ng` configuration file | `/opt/axosyslog/etc` | `/etc/syslog-ng` |
| Output log files | `/opt/axosyslog/var/log` | `/var/log` |

1. (Optional) Create an `override.conf` file to set custom environment values. This can be useful if you don't want to modify `/etc/containers/systemd/axosyslog.container`. Run:

Expand All @@ -73,11 +79,6 @@ The steps in this procedure were tested on CentOS 9, but should work on other si

You can customize the configuration file according to your needs. For a few pointers, see {{% xref "/quickstart/configure-servers/_index.md" %}} and the rest of this guide.

eldarnash marked this conversation as resolved.
Show resolved Hide resolved

<!-- FIXME Add a unitfile mount point /var/logs that points to /opt/axosyslog/var/log
> Where do we set the /var/log part?
> Do we have to manually create /opt/axosyslog/var/log/messages outside? -->

1. Run the following commands to reload the systemd configuration and launch the `axosyslog` service. Though the systemctl commands are run as root, the container will run as the specified user if set appropriately in the unit file.

```shell
Expand Down Expand Up @@ -124,23 +125,21 @@ The steps in this procedure were tested on CentOS 9, but should work on other si
echo '<5> localhost test: this is a test message' | nc localhost 514
```

<!-- FIXME ncat connection refused, seems that the ports are not open in the container, syslog-ng is not listening on any port (netstat -antp)

There is a default /etc/syslog-ng/syslog-ng.conf file in the container, and syslog-ng is using that
-->

Check that the test message has arrived into the log file:

```shell
less /opt/axosyslog/var/log/messages
```

<!-- FIXME add sample output -->
The output should be similar to:

```shell
Feb 19 15:49:12 localhost test: this is a test message
```

eldarnash marked this conversation as resolved.
Show resolved Hide resolved
fekete-robert marked this conversation as resolved.
Show resolved Hide resolved
## Customize the configuration

To customize the configuration, edit the `/etc/syslog-ng/syslog-ng.conf` file on the host, then reload the service.
<!-- FIXME check external configfile path -->
To customize the configuration, edit the `/opt/axosyslog/etc/syslog-ng.conf` file on the host, then reload the service.

{{< include-headless "disk-buffer-in-container.md" >}}
<!-- FIXME check and adapt the diskbuffer section, note that the sample unit file uses the persist dir for storing diskbuffers-->
Expand All @@ -159,6 +158,14 @@ To customize the configuration, edit the `/etc/syslog-ng/syslog-ng.conf` file on
{{< param "command" >}} exec -ti AxoSyslog syslog-ng-ctl show-license-info
```

If you use `syslog-ng-ctl` regularly, you can create the `/opt/axosyslog/bin/syslog-ng-ctl` file with the following content, make it executable, and add it to your path. That way running `syslog-ng-ctl <command>` will execute the command in the AxoSyslog container.

```shell
#!/bin/bash

podman exec -ti AxoSyslog syslog-ng-ctl "$@"
```

- The traditional method of starting a service at boot (`systemctl enable`) is not supported for container services. To automatically start the {{% param "product.abbrev" %}} service, make sure that the following line is included in the unit file. (It is included in the sample template.)

```systemd
Expand Down
20 changes: 4 additions & 16 deletions content/install/podman-systemd/axosyslog.container
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Description=AxoSyslog Container
Wants=NetworkManager.service network-online.target
After=NetworkManager.service network-online.target


[Install]
WantedBy=multi-user.target default.target

Expand All @@ -17,48 +16,37 @@ WantedBy=multi-user.target default.target
# User=1000
# Group=1000


ContainerName=AxoSyslog


AddCapability=CAP_NET_BIND_SERVICE CAP_CHOWN CAP_FOWNER CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_SYS_ADMIN


Image=${AXOSYSLOG_IMAGE}


Volume=${PERSIST_MOUNT}:/opt/axosyslog/var/lib:z
Volume=${CONFIG_MOUNT}:/opt/axosyslog/etc:z
Volume=${LOG_MOUNT}:/opt/axosyslog/var/log:z
Volume=${PERSIST_MOUNT}:/var/lib/syslog-ng:z
Volume=${CONFIG_MOUNT}:/etc/syslog-ng:z
Volume=${LOG_MOUNT}:/var/log:z

Exec=-e
LogDriver=journald
Network=host
SecurityLabelDisable=true


[Service]
# Set up environment for container above
# Container image pulled from repository
Environment="AXOSYSLOG_IMAGE=ghcr.io/axoflow/axosyslog:latest"


Environment="PERSIST_MOUNT=/var/lib/syslog-ng"


# Required local mount point for syslog-ng config file and associated subdirectories
Environment="CONFIG_MOUNT=/opt/axosyslog/etc"


# Required local mount point for storing collected logs
Environment="LOG_MOUNT=/var/logs"

Environment="LOG_MOUNT=/opt/axosyslog/var/log"

# Ensure local filesystem mount points are created and set with appropriate permissions
ExecStartPre = +mkdir -p $PERSIST_MOUNT $CONFIG_MOUNT $LOG_MOUNT


ExecReload=podman kill --signal="SIGHUP" AxoSyslog


Restart=on-failure
2 changes: 1 addition & 1 deletion content/install/podman-systemd/syslog-ng.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
@include "scl.conf"
log {
source { default-network-drivers(); system(); internal(); };
destination { file("/var/logs/messages"); };
destination { file("/var/log/messages"); };
};
Loading