Created
March 6, 2013 13:48
-
-
Save kafecho/5099412 to your computer and use it in GitHub Desktop.
Reworked my Ansible playbook to install, configure and start Corosync and Pacemaker. Only tested it on CentOS 6.2 64 bit.
The playbook now makes use of the built-it Ansible modules to enable services at boot time and to configure SELinux.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This playbook installs and configure corosync and pacemaker on a set of nodes part of a given group. | |
--- | |
# See the file /etc/ansible/hosts where the group is actually defined. There might be a way to define groups in a file 'closer' to this playbook. | |
- hosts: clusternodes | |
vars: | |
mcastport : 5405 | |
tasks: | |
# It would be better to use Ansible to change the IP tables config to allow corosync/pacemaker on the nodes part of the cluster. | |
- name: ensure iptables is stopped and is not running at boot time. | |
action: service name=iptables state=stopped enabled=no | |
- name: ensure python-selinux is installed on all nodes. | |
action: yum name=libselinux-python state=installed | |
- name: set SELinux to permissive | |
action: selinux policy=targeted state=permissive | |
- name: ensure SELinux is turned off | |
action: command /usr/sbin/setenforce 0 | |
- name: ensure corosync is installed. | |
action: yum name=corosync state=installed | |
- name: write the corosync config files | |
action: template src=corosync.conf dest=/etc/corosync/corosync.conf | |
- name: add the pcmk file in the folder service.d for corosync configuration | |
action: copy src=pcmk dest=/etc/corosync/service.d/pcmk | |
- name: ensure Pacemaker is installed. | |
action: yum name=pacemaker state=installed | |
- name: ensure corosync is running (and automatically at boot time) | |
action: service name=corosync state=started enabled=yes | |
- name: ensure pacemaker is running automatically at boot time | |
action: command /sbin/chkconfig pacemaker on | |
- name: ensure Pacemaker is running (and also enabled to start at boot time). For some reason, Pacemaker will fail to start when the steps below are done synchronously. | |
action: service name=pacemaker state=started enabled=yes | |
async: 60 | |
poll: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please read the corosync.conf.5 manual page | |
compatibility: whitetank | |
totem { | |
version: 2 | |
secauth: off | |
interface { | |
{% for host in hostvars %} | |
member { | |
memberaddr: {{ hostvars[host]['ansible_eth1']['ipv4']['address']}} | |
} | |
{% endfor %} | |
ringnumber: 0 | |
bindnetaddr: {{ bindnetaddr }} | |
mcastport: {{ mcastport }} | |
ttl: 1 | |
} | |
transport: udpu | |
} | |
logging { | |
fileline: off | |
to_logfile: yes | |
to_syslog: yes | |
debug: on | |
logfile: /var/log/corosync.log | |
debug: off | |
timestamp: on | |
logger_subsys { | |
subsys: AMF | |
debug: off | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service{ | |
name: pacemaker | |
ver: 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where does the {{ bindnetaddr }} variable in this example come from? Manually, I'd use ipcalc to find that value but I'm curious if you've found a better way.