File: //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_rsyslog.cpython-39.pyc
a
��`|8 � @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZ dZdZ dZ
i Zd Zd
Z
dZdZd
ZdZdZe�e�Ze�d�Ze�d�Ze
dfdd�Zdd� Zdd� Zd!dd�ZG dd� de�Zd"dd�Zdd � Z dS )#a�
.. _cc_rsyslog:
Rsyslog
-------
**Summary:** configure system loggig via rsyslog
This module configures remote system logging using rsyslog.
The rsyslog config file to write to can be specified in ``config_filename``,
which defaults to ``20-cloud-config.conf``. The rsyslog config directory to
write config files to may be specified in ``config_dir``, which defaults to
``/etc/rsyslog.d``.
A list of configurations for rsyslog can be specified under the ``configs`` key
in the ``rsyslog`` config. Each entry in ``configs`` is either a string or a
dictionary. Each config entry contains a configuration string and a file to
write it to. For config entries that are a dictionary, ``filename`` sets the
target filename and ``content`` specifies the config string to write. For
config entries that are only a string, the string is used as the config string
to write. If the filename to write the config to is not specified, the value of
the ``config_filename`` key is used. A file with the selected filename will be
written inside the directory specified by ``config_dir``.
The command to use to reload the rsyslog service after the config has been
updated can be specified in ``service_reload_command``. If this is set to
``auto``, then an appropriate command for the distro will be used. This is the
default behavior. To manually set the command, use a list of command args (e.g.
``[systemctl, restart, rsyslog]``).
Configuration for remote servers can be specified in ``configs``, but for
convenience it can be specified as key value pairs in ``remotes``. Each key
is the name for an rsyslog remote entry. Each value holds the contents of the
remote config for rsyslog. The config consists of the following parts:
- filter for log messages (defaults to ``*.*``)
- optional leading ``@`` or ``@@``, indicating udp and tcp respectively
(defaults to ``@``, for udp)
- ipv4 or ipv6 hostname or address. ipv6 addresses must be in ``[::1]``
format, (e.g. ``@[fd00::1]:514``)
- optional port number (defaults to ``514``)
This module will provide sane defaults for any part of the remote entry that is
not specified, so in most cases remote hosts can be specified just using
``<name>: <address>``.
For backwards compatibility, this module still supports legacy names for the
config entries. Legacy to new mappings are as follows:
- ``rsyslog`` -> ``rsyslog/configs``
- ``rsyslog_filename`` -> ``rsyslog/config_filename``
- ``rsyslog_dir`` -> ``rsyslog/config_dir``
.. note::
The legacy config format does not support specifying
``service_reload_command``.
**Internal name:** ``cc_rsyslog``
**Module frequency:** per instance
**Supported distros:** all
**Config keys**::
rsyslog:
config_dir: config_dir
config_filename: config_filename
configs:
- "*.* @@192.158.1.1"
- content: "*.* @@192.0.2.1:10514"
filename: 01-example.conf
- content: |
*.* @@syslogd.example.com
remotes:
maas: "192.168.1.1"
juju: "10.0.4.1"
service_reload_command: [your, syslog, restart, command]
**Legacy config keys**::
rsyslog:
- "*.* @@192.158.1.1"
rsyslog_dir: /etc/rsyslog-config.d/
rsyslog_filename: 99-local.conf
� N)�log)�subp)�utilz20-cloud-config.confz/etc/rsyslog.d�auto�configsZconfig_filenameZ
config_dirZservice_reload_commandZrsyslog_filenameZrsyslog_dir�remotesz[ ]*[#]+[ ]*z_^(?P<proto>[@]{0,2})(([\[](?P<bracket_addr>[^\]]*)[\]])|(?P<addr>[^:]*))([:](?P<port>[0-9]+))?$Fc C s>