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 ...@@ -22,7 +22,7 @@ Variables
* kea_control_agent_config * kea_control_agent_config
* description: * description:
* This option contains the configuration file for Kea's control agent. * 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 * kea_ha_mode
* description: * description:
...@@ -32,6 +32,48 @@ Variables ...@@ -32,6 +32,48 @@ Variables
* choices: [none, loadbalancing, hotstandby] * choices: [none, loadbalancing, hotstandby]
* default: none * 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 * kea_control_agent_port
* description: * description:
* This option defines the communication port for the kea control agents. * This option defines the communication port for the kea control agents.
......
...@@ -11,9 +11,16 @@ dhcp_db_password: "" ...@@ -11,9 +11,16 @@ dhcp_db_password: ""
dhcp_db_dbname: "" dhcp_db_dbname: ""
kea_ctrl_configfile: "/usr/local/etc/kea/keactrl.conf" 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_dhcp4_config: "kea-dhcp4.conf.j2"
kea_dhcp6_config: "kea-dhcp6.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_ha_mode: "none"
kea_control_agent_port: 8080 kea_control_agent_port: 8080
kea_outbound_interface: "same-as-inbound" kea_outbound_interface: "same-as-inbound"
......
...@@ -3,22 +3,34 @@ ...@@ -3,22 +3,34 @@
name: package.dhcp name: package.dhcp
tasks_from: configure 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: template:
src: "{{ kea_dhcp4_config }}" src: "{{ kea_dhcp4_config }}"
dest: "{{ system_config_directory }}/kea/kea-dhcp4.conf" dest: "{{ system_config_directory }}/kea/kea-dhcp4.conf"
- name: install ISC kea DHCPv6 configuration - name: install ISC Kea DHCPv6 configuration
template: template:
src: "{{ kea_dhcp6_config }}" src: "{{ kea_dhcp6_config }}"
dest: "{{ system_config_directory }}/kea/kea-dhcp6.conf" dest: "{{ system_config_directory }}/kea/kea-dhcp6.conf"
- name: install ISC kea control agent configuration - name: install ISC Kea control agent configuration
template: template:
src: "{{ kea_control_agent_config }}" 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: service:
name: "{{ service }}" name: "{{ service }}"
state: started state: started
...@@ -27,7 +39,7 @@ ...@@ -27,7 +39,7 @@
loop_var: service loop_var: service
register: keastart register: keastart
- name: reload kea - name: reload ISC Kea service
service: service:
name: "{{ service }}" name: "{{ service }}"
state: reloaded state: reloaded
......
...@@ -19,5 +19,9 @@ ...@@ -19,5 +19,9 @@
"socket-name": "/tmp/kea-dhcp6-ctrl.sock" "socket-name": "/tmp/kea-dhcp6-ctrl.sock"
} }
} }
} },
{% from "kea-logger.j2" import logger with context %}
{{ logger("kea-ctrl-agent") }}
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
{%- else %} {%- else %}
{%- do has.update({"url": 'http://[%s]:%s/' | format(ifdata.ipv6 | default("::1"), kea_control_agent_port)}) %} {%- do has.update({"url": 'http://[%s]:%s/' | format(ifdata.ipv6 | default("::1"), kea_control_agent_port)}) %}
{%- endif %} {%- 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"}) %} {%- do has.update({"auto-failover": false, "role": "backup"}) %}
{%- elif fctnhst == dhcp_primary_server %} {%- elif fctnhst == dhcp_primary_server %}
{%- do has.update({"auto-failover": true, "role": "primary"}) %} {%- do has.update({"auto-failover": true, "role": "primary"}) %}
......
...@@ -104,18 +104,7 @@ ...@@ -104,18 +104,7 @@
"subnet4": {{ ipv4subnets | to_nice_json(indent=8) }} "subnet4": {{ ipv4subnets | to_nice_json(indent=8) }}
}, },
"Logging": {% from "kea-logger.j2" import logger with context %}
{ {{ logger("kea-dhcp4") }}
"loggers": [
{
"name": "kea-dhcp4",
"output_options": [
{
"output": "/var/log/kea-dhcp4.log"
}
],
"severity": "INFO"
}
]
}
} }
...@@ -92,18 +92,7 @@ ...@@ -92,18 +92,7 @@
"subnet6": {{ ipv6subnets | to_nice_json(indent=8) }} "subnet6": {{ ipv6subnets | to_nice_json(indent=8) }}
}, },
"Logging": {% from "kea-logger.j2" import logger with context %}
{ {{ logger("kea-dhcp6") }}
"loggers": [
{
"name": "kea-dhcp6",
"output_options": [
{
"output": "/var/log/kea-dhcp6.log"
}
],
"severity": "INFO"
}
]
}
} }
{% 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