Skip to content

Commit 62792ec

Browse files
committed
Initial revision
Initial revision with single ring support
0 parents  commit 62792ec

File tree

12 files changed

+178
-0
lines changed

12 files changed

+178
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.vagrant
2+
vagrant
3+

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ansible-pacemaker-corosync role
2+
===============================
3+
4+
Deploys corosync/pacemaker on Ubuntu 14.04
5+
6+
# Variables
7+
8+
- `pacemaker_corosync_group`: Ansible group name for corosync cluster (default: false, *mandatory*)
9+
- `pacemaker_corosync_ring_interface`: Interface to use for ring0 communications (default: false, *mandatory*)
10+

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pacemaker_corosync_group: false
2+
pacemaker_corosync_ring_interface: false

files/pcmk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
service {
2+
name: pacemaker
3+
ver: 1
4+
}

handlers/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- name: Restart corosync
2+
service:
3+
name: "{{ item }}"
4+
state: restarted
5+
with_items:
6+
- corosync
7+
- pacemaker

meta/main.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
3+
dependencies: []
4+
5+
galaxy_info:
6+
author: Michel Blanc
7+
company: ACME Corp
8+
description: ansible-pacemaker-corosync role
9+
license: MIT
10+
min_ansible_version: 1.6
11+
platforms:
12+
- name: Ubuntu
13+
versions:
14+
- all
15+
categories:
16+
- system

tasks/check_vars.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- name: Checking that required variables are set
2+
fail: msg="{{ item }} is not defined"
3+
when: not {{ item }}
4+
with_items:
5+
- pacemaker_corosync_group
6+
- pacemaker_corosync_ring_interface

tasks/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- include: check_vars.yml tags=pacemaker,check
2+
- include: pacemaker.yml tags=pacemaker

tasks/pacemaker.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
- name: Installs pacemaker & corosync
2+
apt: pkg={{item}} state=latest
3+
with_items:
4+
- corosync
5+
- pacemaker
6+
- haveged
7+
8+
- name: Generates corosync key
9+
become: true
10+
become_user: root
11+
command: corosync-keygen
12+
args:
13+
creates: /etc/corosync/authkey
14+
when: inventory_hostname == groups[pacemaker_corosync_group][0]
15+
register: __corosync_authkey_created
16+
notify: Restart corosync
17+
18+
- name: Copy authkey to other nodes
19+
synchronize: src=/etc/corosync/authkey dest=/etc/corosync/authkey
20+
delegate_to: "{{ groups[pacemaker_corosync_group][0] }}"
21+
when: inventory_hostname != groups[pacemaker_corosync_group][0]
22+
notify: Restart corosync
23+
24+
- name: Chowns authkeys
25+
file:
26+
path: /etc/corosync/authkey
27+
mode: 0400
28+
owner: root
29+
notify: Restart corosync
30+
31+
- name: Creates corosync config
32+
template:
33+
src: corosync.conf.j2
34+
dest: /etc/corosync/corosync.conf
35+
mode: 0400
36+
owner: root
37+
notify: Restart corosync
38+
39+
- name: Adds logrotate config for corosync
40+
template:
41+
src: corosync_logrotate.conf.j2
42+
dest: /etc/logrotate.d/corosync
43+
mode: 0644
44+
owner: root
45+
46+
- name: Adds pacemaker service
47+
copy:
48+
src: pcmk
49+
dest: /etc/corosync/service.d/pcmk
50+
owner: root
51+
mode: 0400
52+
notify: Restart corosync
53+
54+
- name: Adds ferm filtering
55+
template:
56+
src: "../templates/ferm.j2"
57+
dest: /etc/ferm/filter-input.d/60_corosync.conf
58+
when: ferm_enabled | default(false)
59+
tags: ferm
60+
notify: Restart ferm
61+
62+
- name: Enables corosync at boot
63+
copy:
64+
dest: /etc/default/corosync
65+
content: "START=yes"
66+
67+
- name: Registers pacemaker service
68+
service:
69+
name: pacemaker
70+
enabled: true
71+

templates/corosync.conf.j2

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
totem {
2+
version: 2
3+
cluster_name: {{ pacemaker_corosync_group }}
4+
transport: udpu
5+
interface {
6+
ringnumber: 0
7+
bindnetaddr: {{ hostvars[inventory_hostname]['ansible_' + pacemaker_corosync_ring_interface].ipv4.address }}
8+
broadcast: yes
9+
mcastport: 5405
10+
}
11+
}
12+
13+
quorum {
14+
provider: corosync_votequorum
15+
{% if groups[pacemaker_corosync_group]|count == 2 %}
16+
two_node: 1
17+
{% else %}
18+
wait_for_all: 1
19+
last_man_standing: 1
20+
{% endif %}
21+
}
22+
23+
nodelist {
24+
{% for node in groups[pacemaker_corosync_group]|sort %}
25+
node {
26+
ring0_addr: {{ hostvars[node]['ansible_' + pacemaker_corosync_ring_interface].ipv4.address }}
27+
name: {{ node }}
28+
nodeid: {{ loop.index }}
29+
}
30+
{% endfor %}
31+
}
32+
33+
logging {
34+
to_logfile: yes
35+
logfile: /var/log/corosync/corosync.log
36+
to_syslog: yes
37+
timestamp: on
38+
}
39+

0 commit comments

Comments
 (0)