mirror of
https://github.com/PyratLabs/ansible-role-k3s.git
synced 2024-11-22 11:48:22 +01:00
feat(systemd): unit file allows environment variables to be defined #164
This commit is contained in:
parent
dd341f6f10
commit
0c77eb143d
20
README.md
20
README.md
@ -88,17 +88,23 @@ The below variables change how and when the systemd service unit file for K3S
|
||||
is run. Use this with caution, please refer to the [systemd documentation](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#%5BUnit%5D%20Section%20Options)
|
||||
for more information.
|
||||
|
||||
| Variable | Description | Default Value |
|
||||
|------------------------|----------------------------------------------------------------|---------------|
|
||||
| `k3s_start_on_boot` | Start k3s on boot. | `true` |
|
||||
| `k3s_service_requires` | List of required systemd units to k3s service unit. | [] |
|
||||
| `k3s_service_wants` | List of "wanted" systemd unit to k3s (weaker than "requires"). | []\* |
|
||||
| `k3s_service_before` | Start k3s before a defined list of systemd units. | [] |
|
||||
| `k3s_service_after` | Start k3s after a defined list of systemd units. | []\* |
|
||||
| Variable | Description | Default Value |
|
||||
|------------------------|----------------------------------------------------------------------|---------------|
|
||||
| `k3s_start_on_boot` | Start k3s on boot. | `true` |
|
||||
| `k3s_service_requires` | List of required systemd units to k3s service unit. | [] |
|
||||
| `k3s_service_wants` | List of "wanted" systemd unit to k3s (weaker than "requires"). | []\* |
|
||||
| `k3s_service_before` | Start k3s before a defined list of systemd units. | [] |
|
||||
| `k3s_service_after` | Start k3s after a defined list of systemd units. | []\* |
|
||||
| `k3s_service_env_vars` | Dictionary of environment variables to use within systemd unit file. | {} |
|
||||
| `k3s_service_env_file` | Location on host of a environment file to include. | `false`\*\* |
|
||||
|
||||
\* The systemd unit template **always** specifies `network-online.target` for
|
||||
`wants` and `after`.
|
||||
|
||||
\*\* The file must already exist on the target host, this role will not create
|
||||
nor manage the file. You can manage this file outside of the role with
|
||||
pre-tasks in your Ansible playbook.
|
||||
|
||||
### Group/Host Variables
|
||||
|
||||
Below are variables that are set against individual or groups of play hosts.
|
||||
|
@ -91,6 +91,17 @@ k3s_service_before: []
|
||||
# Start k3s after a defined list of systemd units.
|
||||
k3s_service_after: []
|
||||
|
||||
# Dictionary of environment variables to use within systemd unit file
|
||||
# Some examples below
|
||||
k3s_service_env_vars: {}
|
||||
# PATH: /opt/k3s/bin
|
||||
# GOGC: 10
|
||||
|
||||
# Location on host of a environment file to include. This must already exist on
|
||||
# the target as this role will not populate this file.
|
||||
k3s_service_env_file: false
|
||||
|
||||
|
||||
##
|
||||
# Server Configuration
|
||||
##
|
||||
|
@ -18,6 +18,14 @@ After={{ after_unit }}
|
||||
|
||||
[Service]
|
||||
Type={{ 'notify' if k3s_control_node else 'exec' }}
|
||||
{% if k3s_service_env_vars is defined and k3s_service_env_vars is iterable %}
|
||||
{% for env_var, env_value in k3s_service_env_vars %}
|
||||
Environent={{ env_var }}={{ env_value }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if k3s_service_env_file is defined and k3s_service_env_file %}
|
||||
EnvironmentFile={{ k3s_service_env_file }}
|
||||
{% endif %}
|
||||
ExecStartPre=-/sbin/modprobe br_netfilter
|
||||
ExecStartPre=-/sbin/modprobe overlay
|
||||
{% filter regex_replace('\s+', ' ') %}
|
||||
|
Loading…
Reference in New Issue
Block a user