mirror of
https://github.com/PyratLabs/ansible-role-k3s
synced 2025-01-19 07:50:17 +01:00
feat(systemd): unit file allows environment variables to be defined #164
This commit is contained in:
parent
dd341f6f10
commit
0c77eb143d
3 changed files with 32 additions and 7 deletions
|
@ -89,16 +89,22 @@ is run. Use this with caution, please refer to the [systemd documentation](https
|
||||||
for more information.
|
for more information.
|
||||||
|
|
||||||
| Variable | Description | Default Value |
|
| Variable | Description | Default Value |
|
||||||
|------------------------|----------------------------------------------------------------|---------------|
|
|------------------------|----------------------------------------------------------------------|---------------|
|
||||||
| `k3s_start_on_boot` | Start k3s on boot. | `true` |
|
| `k3s_start_on_boot` | Start k3s on boot. | `true` |
|
||||||
| `k3s_service_requires` | List of required systemd units to k3s service unit. | [] |
|
| `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_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_before` | Start k3s before a defined list of systemd units. | [] |
|
||||||
| `k3s_service_after` | Start k3s after 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
|
\* The systemd unit template **always** specifies `network-online.target` for
|
||||||
`wants` and `after`.
|
`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
|
### Group/Host Variables
|
||||||
|
|
||||||
Below are variables that are set against individual or groups of play hosts.
|
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.
|
# Start k3s after a defined list of systemd units.
|
||||||
k3s_service_after: []
|
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
|
# Server Configuration
|
||||||
##
|
##
|
||||||
|
|
|
@ -18,6 +18,14 @@ After={{ after_unit }}
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type={{ 'notify' if k3s_control_node else 'exec' }}
|
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 br_netfilter
|
||||||
ExecStartPre=-/sbin/modprobe overlay
|
ExecStartPre=-/sbin/modprobe overlay
|
||||||
{% filter regex_replace('\s+', ' ') %}
|
{% filter regex_replace('\s+', ' ') %}
|
||||||
|
|
Loading…
Reference in a new issue