From 89d8e1ea57a6f474facbcb83efca48956d18b715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Fri, 27 Aug 2021 15:52:30 +0200 Subject: [PATCH] Manage color with fusioninventory__agent_conf_log_color var --- CHANGELOG.md | 1 + README.md | 1 + defaults/main.yml | 13 +++++ templates/etc/fusioninventory/agent.cfg.j2 | 58 ++++++++++------------ 4 files changed, 42 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31da6a1..9ae49e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * **logfacility** with fusioninventory__agent_conf_log_facility variable * **logfile** with fusioninventory__agent_conf_log_file variable * **logfile-maxsize** with fusioninventory__agent_conf_log_file_maxsize variable + * **color** with fusioninventory__agent_conf_log_color variable ## v1.3.1 diff --git a/README.md b/README.md index bb1824f..5be4ad4 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Some variables used to generate FusionInventery agent.cfg file from Ansible temp * **fusioninventory__agent_conf_log_facility** : Specifies the syslog facility to use for the syslog logger backend [default⎵: `LOG_DAEMON`]. * **fusioninventory__agent_conf_log_file** : Specifies the file to use for the file logger backend [default⎵: `/var/log/fusioninventory.log`]. * **fusioninventory__agent_conf_log_file_maxsize** : Specifies the maximum size for the log file, in MB [default⎵: `0`]. +* **fusioninventory__agent_conf_log_color** : Enables color display for the stderr logger backend [default⎵: `False`]. * **fusioninventory__agent_conf_tag** : Add given tag to inventory results [default⎵: ``]. * **fusioninventory__agent_conf_debug** : If debug mode should be enabled [default⎵: `False`]. diff --git a/defaults/main.yml b/defaults/main.yml index bbbf308..45973ac 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -256,6 +256,19 @@ fusioninventory__agent_conf_log_file: '/var/log/fusioninventory.log' # Default. 0 means unlimited size. # fusioninventory__agent_conf_log_file_maxsize: '0' + # ]]] +# .. envvar:: fusioninventory__agent_conf_log_color [[[ +# +# Enables color display for the stderr logger backend. Possible options : +# +# ``False`` +# Default. +# +# ``True`` +# Enable colors. +# +fusioninventory__agent_conf_log_color: False + # ]]] # .. envvar:: fusioninventory__agent_conf_tag [[[ # diff --git a/templates/etc/fusioninventory/agent.cfg.j2 b/templates/etc/fusioninventory/agent.cfg.j2 index c590852..41725da 100644 --- a/templates/etc/fusioninventory/agent.cfg.j2 +++ b/templates/etc/fusioninventory/agent.cfg.j2 @@ -1,15 +1,12 @@ # {{ ansible_managed }} +# .. vim: foldmarker=[[[,]]]:foldmethod=marker # fusioninventory agent configuration -# all defined values match default # all commented values are examples -# -# Target definition options -# - +# Target definition options [[[ # send tasks results to an OCS server #server = http://server.domain.com/ocsinventory # send tasks results to a FusionInventory for GLPI server @@ -23,10 +20,9 @@ server = {{ fusioninventory__agent_conf_server_url }} local = {{ fusioninventory__agent_conf_local_dir }} {% endif %} -# -# Task definition options -# +# ]]] +# Task definition options [[[ # disable software deployment tasks #no-task = deploy {% if fusioninventory__agent_conf_no_task %} @@ -37,19 +33,17 @@ no-task = {{ fusioninventory__agent_conf_no_task }} tasks = {{ fusioninventory__agent_conf_tasks }} {% endif %} -# -# Target scheduling options -# +# ]]] +# Target scheduling options [[[ # maximum delay before first target, in seconds delaytime = {{ fusioninventory__agent_conf_delaytime }} # do not contact the target before next scheduled time lazy = 0 -# -# Inventory task specific options -# +# ]]] +# Inventory task specific options [[[ # do not list local printers # no-category = printer {% if fusioninventory__agent_conf_no_category %} @@ -78,17 +72,15 @@ force = 0 # additional inventory content file additional-content = -# -# Package deployment task specific options -# +# ]]] +# Package deployment task specific options [[[ # do not use peer to peer to download files no-p2p = 0 -# -# Network options -# +# ]]] +# Network options [[[ # proxy address proxy = # user name for server authentication @@ -109,10 +101,9 @@ no-ssl-check = 0 # connection timeout, in seconds timeout = 180 -# -# Web interface options -# +# ]]] +# Web interface options [[[ {% if fusioninventory__agent_conf_no_httpd %} # disable embedded web server no-httpd = 1 @@ -127,10 +118,9 @@ httpd-port = {{ fusioninventory__agent_conf_httpd_port }} # trust requests without authentication token httpd-trust = {{ fusioninventory__agent_conf_httpd_trust }} -# -# Logging options -# +# ]]] +# Logging options [[[ # Logger backend, either Stderr, File or Syslog (Stderr) logger = {{ fusioninventory__agent_conf_log_logger }} {% if fusioninventory__agent_conf_log_logger == 'file' %} @@ -143,13 +133,17 @@ logfile-maxsize = {{ fusioninventory__agent_conf_log_file_maxsize }} # Syslog facility logfacility = {{ fusioninventory__agent_conf_log_facility }} {% endif %} -# Use color in the console +{% if fusioninventory__agent_conf_log_color %} +# Use color in the console with stderr backend +color = 1 +{% else %} +# Don't use color in the console with stderr backend color = 0 +{% endif %} -# -# Execution mode options -# +# ]]] +# Execution mode options [[[ # add given tag to inventory results tag = {{ fusioninventory__agent_conf_tag }} {% if fusioninventory__agent_conf_debug %} @@ -161,7 +155,9 @@ debug = 0 {% endif %} # time to wait to reload config (0 means no reload, it's default value) -# conf-reload-interval = 0 +# conf-reload-interval = 0 + +# ]]] # Since 2.4, you can include all .cfg files from a folder or any given file # For example: