diff --git a/files/haproxy-logging.cfg b/files/haproxy-logging.cfg deleted file mode 100644 index 0828a2b..0000000 --- a/files/haproxy-logging.cfg +++ /dev/null @@ -1,15 +0,0 @@ -$ModLoad imudp -$UDPServerRun 514 -$template Haproxy,"%msg%\n" -if $programname startswith 'haproxy' then { - # Connections are logged at level "info". - # See https://www.haproxy.org/download/1.6/doc/configuration.txt. - local0.=info -/var/log/haproxy/haproxy.log - # Level "notice" will be used to indicate a server going up, - # "warning" will be used for termination signals and definitive service - # termination, and "alert" will be used for when a server goes down. - # See https://www.haproxy.org/download/1.6/doc/configuration.txt. - local1.notice -/var/log/haproxy/haproxy-status.log - # Discard HAProxy messages to prevent further processing/logging. - local0.*;local1.* ~ -} diff --git a/handlers/main.yml b/handlers/main.yml index cf6280d..611fd98 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -26,16 +26,16 @@ tags: - haproxy-general-config -- name: Reload haproxy - service: - name: "haproxy" - state: "reloaded" - enabled: yes - daemon_reload: yes - - name: Restart rsyslog service: name: "rsyslog" state: "restarted" enabled: yes daemon_reload: yes + +- name: Reload haproxy + service: + name: "haproxy" + state: "reloaded" + enabled: yes + daemon_reload: yes diff --git a/tasks/haproxy_post_install.yml b/tasks/haproxy_post_install.yml index 4438d59..e561767 100644 --- a/tasks/haproxy_post_install.yml +++ b/tasks/haproxy_post_install.yml @@ -23,6 +23,20 @@ tags: - haproxy-non-local-bind-config +# NOTE (noonedeadpunk) Debian/Ubuntu haproxy packages configure rsyslog +# to handle log collection and log file rotation. This is not needed since +# journald is used for this purpose +- name: Delete rsyslog and logrotate configs + file: + path: "{{ item }}" + state: absent + with_items: + - /etc/rsyslog.d/49-haproxy.conf + - /etc/logrotate.d/haproxy + notify: Restart rsyslog + tags: + - haproxy-logging-config + - name: Drop base haproxy config template: src: "haproxy.cfg.j2" @@ -31,23 +45,6 @@ tags: - haproxy-base-config -# remove config file from old location (ie releases 14-18) -- name: Delete prior haproxy logging config - file: - path: "/etc/rsyslog.d/99-haproxy-local-logging.conf" - state: absent - notify: Restart rsyslog - tags: - - haproxy-logging-config - -- name: Drop haproxy logging config - copy: - src: "haproxy-logging.cfg" - dest: "/etc/rsyslog.d/10-haproxy-local-logging.conf" - notify: Restart rsyslog - tags: - - haproxy-logging-config - - include_tasks: haproxy_service_config.yml tags: - haproxy-service-config diff --git a/tasks/haproxy_pre_install.yml b/tasks/haproxy_pre_install.yml index 04aea2a..41a2c9d 100644 --- a/tasks/haproxy_pre_install.yml +++ b/tasks/haproxy_pre_install.yml @@ -13,22 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# NOTE(cloudnull): -# Any packages needed to be installed to support the system will -# be installed at this point, as a pre-task. This is done to -# ensure application and role assumptions are resolved on all of -# our supporting OS's up front. -- name: Install HAProxy Packages - package: - name: "{{ haproxy_distro_pre_packages }}" - state: "{{ haproxy_package_state }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" - cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}" - register: install_pre_packages - until: install_pre_packages is success - retries: 5 - delay: 2 - # NOTE(cloudnull): # While the haproxy distro packages provide for an haproxy # group this group is being created upfront to support @@ -59,31 +43,6 @@ tags: - haproxy-user -- name: create the system group - group: - name: "adm" - state: "present" - system: "yes" - tags: - - haproxy-dirs - - haproxy-logs - -- name: Create haproxy log dir - file: - path: "{{ '/var/log/haproxy' | realpath }}" - state: directory - owner: "{{ haproxy_log_directory_owner }}" - group: adm - mode: "0755" - tags: - - haproxy-dirs - - haproxy-logs - -- name: Remove conflicting distro packages - package: - name: "{{ haproxy_distro_packages_remove }}" - state: absent - - name: Create haproxy conf.d dir file: path: "/etc/haproxy/conf.d" diff --git a/templates/haproxy.cfg.j2 b/templates/haproxy.cfg.j2 index 49f9bd0..5e544e4 100644 --- a/templates/haproxy.cfg.j2 +++ b/templates/haproxy.cfg.j2 @@ -1,8 +1,7 @@ # {{ ansible_managed }} global - log 127.0.0.1 local0 - log 127.0.0.1 local1 notice + log /dev/log local0 chroot /var/lib/haproxy user haproxy group haproxy diff --git a/vars/debian.yml b/vars/debian.yml index 0a8b5e5..c6eab52 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -16,16 +16,8 @@ ## APT Cache options cache_timeout: 600 -haproxy_distro_pre_packages: - - rsyslog # Used for local logging - haproxy_distro_packages: - haproxy - netcat # Used for the Ansible haproxy module - psmisc - vim-haproxy - -# On Debian rsyslog runs as the "root" user, so have the -# HAProxy log directory be owned by the same user so that rsyslog can write -# HAProxy's logs to that directory. -haproxy_log_directory_owner: root diff --git a/vars/main.yml b/vars/main.yml deleted file mode 100644 index 1c3e797..0000000 --- a/vars/main.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -# Copyright 2017, SUSE LINUX GmbH. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -haproxy_distro_packages_remove: [] - -haproxy_log_directory_owner: haproxy diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index dcbfd78..108214b 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -13,9 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -haproxy_distro_pre_packages: - - rsyslog # Used for local logging - haproxy_distro_packages: - haproxy - nc # Used for the Ansible haproxy module diff --git a/vars/suse.yml b/vars/suse.yml index eb21eaa..bc77b01 100644 --- a/vars/suse.yml +++ b/vars/suse.yml @@ -13,15 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -haproxy_distro_pre_packages: - - rsyslog # Used for local logging - haproxy_distro_packages: - apparmor-parser - apparmor-profiles - apparmor-utils - haproxy - netcat # Used for the Ansible haproxy module - -haproxy_distro_packages_remove: - - systemd-logger # conflicts with rsyslog diff --git a/vars/ubuntu.yml b/vars/ubuntu.yml index 3edda91..c6eab52 100644 --- a/vars/ubuntu.yml +++ b/vars/ubuntu.yml @@ -16,16 +16,8 @@ ## APT Cache options cache_timeout: 600 -haproxy_distro_pre_packages: - - rsyslog # Used for local logging - haproxy_distro_packages: - haproxy - netcat # Used for the Ansible haproxy module - psmisc - vim-haproxy - -# On Ubuntu 16.04 and 18.04 rsyslog runs as the "syslog" user, so have the -# HAProxy log directory be owned by the same user so that rsyslog can write -# HAProxy's logs to that directory. -haproxy_log_directory_owner: syslog