Commit 73f3b328 authored by Pietsch, Martin's avatar Pietsch, Martin

add Kea Logger template and Kea Logger variables

parent 86037f11
......@@ -22,7 +22,7 @@ Variables
* kea_control_agent_config
* description:
* This option contains the configuration file for Kea's control agent.
* default: "kea-control-agent.conf.j2"
* default: "kea-ctrl-agent.conf.j2"
* kea_ha_mode
* description:
......@@ -32,6 +32,48 @@ Variables
* choices: [none, loadbalancing, hotstandby]
* default: none
* kea_logger_destination
* description:
* This options specifies the destination for keas log messages.
* choices: ["file", "stdout", "stderr", "syslog"]
* default: "file"
* kea_logger_severity:
* description:
* This option specifies the category of messages logged.
* choices: ["DEBUG", "ERROR", "FATAL", "INFO", "WARN"]
* default: "INFO"
* kea_logger_debuglevel:
* description:
* When a logger's severity is set to DEBUG, this value specifies what level of debug messages should be printed.
* It ranges from 0(least verbose) to 99 (most verbose).
* default: "0"
* kea_logger_directory
* description:
* This option specifies the path for keas log files.
* default: "/var/log"
* note: This option is only used if the variable *kea_logger_destination* is set to "file".
* kea_logger_file_maxsize
* description:
* This is maximum size in bytes that a log file may reach.
* default: 10240000 (10MB)
* note: This option is only used if the variable *kea_logger_destination* is set to "file".
* kea_logger_file_maxver
* description:
* This is maximum number of rotated versions that will be kept.
* default: 1
* note: This option is only used if the variable *kea_logger_destination* is set to "file".
* kea_logger_file_flush:
* description:
* Flush buffers after each log message.
* choices: [true, false]
* default: true
* kea_control_agent_port
* description:
* This option defines the communication port for the kea control agents.
......
......@@ -11,9 +11,16 @@ dhcp_db_password: ""
dhcp_db_dbname: ""
kea_ctrl_configfile: "/usr/local/etc/kea/keactrl.conf"
kea_logger_destination: "file"
kea_logger_directory: "/var/log"
kea_logger_severity: "INFO"
kea_logger_file_maxsize: 10240000
kea_logger_file_maxver: 1
kea_logger_file_flush: true
kea_dhcp4_config: "kea-dhcp4.conf.j2"
kea_dhcp6_config: "kea-dhcp6.conf.j2"
kea_control_agent_config: "kea-control-agent.conf.j2"
kea_control_agent_config: "kea-ctrl-agent.conf.j2"
kea_ha_mode: "none"
kea_control_agent_port: 8080
kea_outbound_interface: "same-as-inbound"
......
......@@ -3,22 +3,34 @@
name: package.dhcp
tasks_from: configure
- name: install ISC kea DHCPv4 configuration
- name: create ISC Kea Logger directory
file:
path: "{{ kea_logger_directory }}"
state: directory
- name: install ISC Kea DHCPv4 configuration
template:
src: "{{ kea_dhcp4_config }}"
dest: "{{ system_config_directory }}/kea/kea-dhcp4.conf"
- name: install ISC kea DHCPv6 configuration
- name: install ISC Kea DHCPv6 configuration
template:
src: "{{ kea_dhcp6_config }}"
dest: "{{ system_config_directory }}/kea/kea-dhcp6.conf"
- name: install ISC kea control agent configuration
- name: install ISC Kea control agent configuration
template:
src: "{{ kea_control_agent_config }}"
dest: "{{ system_config_directory }}/kea/kea-control-agent.conf"
dest: "{{ system_config_directory }}/kea/kea-ctrl-agent.conf"
- name: Workaround to start within a FreeBSD jail container
lineinfile:
path: "{{ system_config_directory }}/rc.d/kea"
regexp: "^# KEYWORD: nojail"
line: "# KEYWORD: shutdown"
when: ansible_distribution == "FreeBSD"
- name: start kea
- name: start ISC Kea service
service:
name: "{{ service }}"
state: started
......@@ -27,7 +39,7 @@
loop_var: service
register: keastart
- name: reload kea
- name: reload ISC Kea service
service:
name: "{{ service }}"
state: reloaded
......
......@@ -19,5 +19,9 @@
"socket-name": "/tmp/kea-dhcp6-ctrl.sock"
}
}
}
},
{% from "kea-logger.j2" import logger with context %}
{{ logger("kea-ctrl-agent") }}
}
......@@ -10,7 +10,7 @@
{%- else %}
{%- do has.update({"url": 'http://[%s]:%s/' | format(ifdata.ipv6 | default("::1"), kea_control_agent_port)}) %}
{%- endif %}
{%- if fctnhst != dhcp_primary_server or fctnhst != dhcp_secondary_server %}
{%- if fctnhst != dhcp_primary_server and fctnhst != dhcp_secondary_server %}
{%- do has.update({"auto-failover": false, "role": "backup"}) %}
{%- elif fctnhst == dhcp_primary_server %}
{%- do has.update({"auto-failover": true, "role": "primary"}) %}
......
......@@ -104,18 +104,7 @@
"subnet4": {{ ipv4subnets | to_nice_json(indent=8) }}
},
"Logging":
{
"loggers": [
{
"name": "kea-dhcp4",
"output_options": [
{
"output": "/var/log/kea-dhcp4.log"
}
],
"severity": "INFO"
}
]
}
{% from "kea-logger.j2" import logger with context %}
{{ logger("kea-dhcp4") }}
}
......@@ -92,18 +92,7 @@
"subnet6": {{ ipv6subnets | to_nice_json(indent=8) }}
},
"Logging":
{
"loggers": [
{
"name": "kea-dhcp6",
"output_options": [
{
"output": "/var/log/kea-dhcp6.log"
}
],
"severity": "INFO"
}
]
}
{% from "kea-logger.j2" import logger with context %}
{{ logger("kea-dhcp6") }}
}
{% macro logger(service) %}
{% set logdata = {"name": service, "output_options": [{}], "severity": kea_logger_severity } %}
{% if kea_logger_severity == "DEBUG" -%}
{% do logdata.update({"debuglevel": kea_logger_debuglevel }) %}
{% endif %}
{% if kea_logger_destination == "file" %}
{% do logdata.output_options[0].update({"output": "%s/%s.log" | format(kea_logger_directory, service) }) %}
{% if kea_logger_file_maxsize is defined %}
{% do logdata.output_options[0].update({"maxsize": kea_logger_file_maxsize }) %}
{% endif %}
{% if kea_logger_file_maxver is defined %}
{% do logdata.output_options[0].update({"maxver": kea_logger_file_maxver }) %}
{% endif %}
{% if kea_logger_file_flush is defined %}
{% do logdata.output_options[0].update({"flush": kea_logger_file_flush }) %}
{% endif %}
{% else %}
{% do logdata.output_options[0].update({"output": kea_logger_destination }) %}
{% endif %}
"Logging":
{
"loggers": [
{{ logdata | to_nice_json(indent=8) }}
]
}
{% endmacro %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment