Skip to content

Commit

Permalink
Add variables to control logging options
Browse files Browse the repository at this point in the history
Added 2 variables - pacemaker_corosync_use_logfile and
pacemaker_corosync_use_syslog which you can enable/disable to controll
where corosync log will be written to.
  • Loading branch information
Dmitriy Rabotyagov committed Aug 4, 2020
1 parent a5bea0c commit f1be7a6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pacemaker_corosync_fqdn: false
pacemaker_corosync_group: false
pacemaker_corosync_ring_interface: false
pacemaker_corosync_use_syslog: true
pacemaker_corosync_use_logfile: false
7 changes: 7 additions & 0 deletions tasks/pacemaker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@
owner: root
notify: Restart corosync

- name: Creates log directory
file:
path: /var/log/corosync
state: directory
when: pacemaker_corosync_use_logfile | bool is true

- name: Adds logrotate config for corosync
template:
src: corosync_logrotate.conf.j2
dest: /etc/logrotate.d/corosync
mode: "0644"
owner: root
when: pacemaker_corosync_use_logfile | bool is true

- name: Creates services directory
file:
Expand Down
12 changes: 7 additions & 5 deletions templates/corosync.conf.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% set _pacemaker_corosync_bind_addr = hostvars[inventory_hostname]['ansible_' + pacemaker_corosync_ring_interface | replace('-', '_')].ipv4.address %}
totem {
version: 2
cluster_name: {{ pacemaker_corosync_group }}
Expand All @@ -6,7 +7,7 @@ totem {
{% endif %}
interface {
ringnumber: 0
bindnetaddr: {{ hostvars[inventory_hostname]['ansible_' + pacemaker_corosync_ring_interface | replace('-', '_')].ipv4.address }}
bindnetaddr: {{ _pacemaker_corosync_bind_addr }}
broadcast: yes
mcastport: 5405
}
Expand All @@ -29,7 +30,7 @@ quorum {
nodelist {
{% for node in groups[pacemaker_corosync_group]|sort %}
node {
ring0_addr: {{ hostvars[node]['ansible_' + pacemaker_corosync_ring_interface].ipv4.address }}
ring0_addr: {{ _pacemaker_corosync_bind_addr }}
name: {{ pacemaker_corosync_fqdn | bool | ternary(hostvars[node].ansible_fqdn, node) }}
nodeid: {{ loop.index }}
}
Expand All @@ -38,9 +39,10 @@ nodelist {
{% endif %}

logging {
to_logfile: yes
to_logfile: {{ (pacemaker_corosync_use_logfile | bool) | ternary('yes', 'no') }}
{% if pacemaker_corosync_use_logfile | bool %}
logfile: /var/log/corosync/corosync.log
to_syslog: yes
{% endif %}
to_syslog: {{ (pacemaker_corosync_use_syslog | bool) | ternary('yes', 'no') }}
timestamp: on
}

0 comments on commit f1be7a6

Please sign in to comment.