Skip to content

Commit f1be7a6

Browse files
author
Dmitriy Rabotyagov
committed
Add variables to control logging options
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.
1 parent a5bea0c commit f1be7a6

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
pacemaker_corosync_fqdn: false
22
pacemaker_corosync_group: false
33
pacemaker_corosync_ring_interface: false
4+
pacemaker_corosync_use_syslog: true
5+
pacemaker_corosync_use_logfile: false

tasks/pacemaker.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,19 @@
7979
owner: root
8080
notify: Restart corosync
8181

82+
- name: Creates log directory
83+
file:
84+
path: /var/log/corosync
85+
state: directory
86+
when: pacemaker_corosync_use_logfile | bool is true
87+
8288
- name: Adds logrotate config for corosync
8389
template:
8490
src: corosync_logrotate.conf.j2
8591
dest: /etc/logrotate.d/corosync
8692
mode: "0644"
8793
owner: root
94+
when: pacemaker_corosync_use_logfile | bool is true
8895

8996
- name: Creates services directory
9097
file:

templates/corosync.conf.j2

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% set _pacemaker_corosync_bind_addr = hostvars[inventory_hostname]['ansible_' + pacemaker_corosync_ring_interface | replace('-', '_')].ipv4.address %}
12
totem {
23
version: 2
34
cluster_name: {{ pacemaker_corosync_group }}
@@ -6,7 +7,7 @@ totem {
67
{% endif %}
78
interface {
89
ringnumber: 0
9-
bindnetaddr: {{ hostvars[inventory_hostname]['ansible_' + pacemaker_corosync_ring_interface | replace('-', '_')].ipv4.address }}
10+
bindnetaddr: {{ _pacemaker_corosync_bind_addr }}
1011
broadcast: yes
1112
mcastport: 5405
1213
}
@@ -29,7 +30,7 @@ quorum {
2930
nodelist {
3031
{% for node in groups[pacemaker_corosync_group]|sort %}
3132
node {
32-
ring0_addr: {{ hostvars[node]['ansible_' + pacemaker_corosync_ring_interface].ipv4.address }}
33+
ring0_addr: {{ _pacemaker_corosync_bind_addr }}
3334
name: {{ pacemaker_corosync_fqdn | bool | ternary(hostvars[node].ansible_fqdn, node) }}
3435
nodeid: {{ loop.index }}
3536
}
@@ -38,9 +39,10 @@ nodelist {
3839
{% endif %}
3940

4041
logging {
41-
to_logfile: yes
42+
to_logfile: {{ (pacemaker_corosync_use_logfile | bool) | ternary('yes', 'no') }}
43+
{% if pacemaker_corosync_use_logfile | bool %}
4244
logfile: /var/log/corosync/corosync.log
43-
to_syslog: yes
45+
{% endif %}
46+
to_syslog: {{ (pacemaker_corosync_use_syslog | bool) | ternary('yes', 'no') }}
4447
timestamp: on
4548
}
46-

0 commit comments

Comments
 (0)