Merge pull request #678 from ceph/rbd-mirror

ceph-rbd-mirror: add new role
pull/698/head
Leseb 2016-04-08 12:12:30 +02:00
commit f783adcc9e
13 changed files with 224 additions and 1 deletions

View File

@ -25,6 +25,7 @@ dummy:
#rgw_group_name: rgws
#mds_group_name: mdss
#restapi_group_name: restapis
#rbdmirror_group_name: rbdmirrors
# If check_firewall is true, then ansible will try to determine if the
# Ceph ports are blocked by a firewall. If the machine running ansible

View File

@ -0,0 +1,37 @@
---
# Variables here are applicable to all host groups NOT roles
# This sample file generated by generate_group_vars_sample.sh
# Dummy variable to avoid error because ansible does not recognize the
# file as a good configuration file when no variable in it.
dummy:
#########
# SETUP #
#########
# NOTE (leseb): the rbd-mirror daemon needs a user to start
# because it has to authenticate with the local cluster.
# By default, using the admin user is fine, so you should not
# need to change 'ceph_rbd_mirror_local_user' unless you have
# a dedicated key available in /etc/ceph/.
# Generally Ansible will use the admin key and put it
# under /etc/ceph/. The same goes for 'ceph_rbd_mirror_remote_user'
# there should not be any reason to change it.
#ceph_rbd_mirror_local_user: admin
#ceph_rbd_mirror_remote_user: admin
# NOTE (leseb): the following variable needs the name of the remote cluster.
# The name of this cluster must be different than your local cluster simply
# because we need to have both keys and ceph.conf inside /etc/ceph.
# Thus if cluster names are identical we can not have them under /etc/ceph
#ceph_rbd_mirror_remote_cluster: ""
#################
# CONFIGURATION #
#################
#ceph_rbd_mirror_configure: false
#ceph_rbd_mirror_pool: ""

View File

@ -44,6 +44,7 @@
mon_group_name: mons
rgw_group_name: rgws
mds_group_name: mdss
rbdmirror_group_name: rbdmirrors
# When set to true both groups of packages are purged.
# This can cause problem with qemu-kvm
@ -156,6 +157,15 @@
systemd_unit_files.stdout != "0" and
rgw_group_name in group_names
- name: stop ceph rbd mirror with systemd
service:
name: ceph-rbd-mirror@admin.service
state: stopped
when:
ansible_os_family == 'RedHat' and
systemd_unit_files.stdout != "0" and
rbdmirror_group_name in group_names
# before infernalis
- name: stop ceph osds
command: service ceph stop osd
@ -218,6 +228,13 @@
ansible_distribution == 'Ubuntu' and
rgw_group_name in group_names
- name: stop ceph rbd mirror on ubuntu
command: initctl stop ceph-rbd-mirorr cluster={{ cluster }} id=admin
failed_when: false
when:
ansible_distribution == 'Ubuntu' and
rbdmirror_group_name in group_names
- name: check for anything running ceph
shell: "ps awux | grep -v grep | grep -q -- ceph-"
register: check_for_running_ceph

View File

@ -17,6 +17,7 @@ osd_group_name: osds
rgw_group_name: rgws
mds_group_name: mdss
restapi_group_name: restapis
rbdmirror_group_name: rbdmirrors
# If check_firewall is true, then ansible will try to determine if the
# Ceph ports are blocked by a firewall. If the machine running ansible

View File

@ -0,0 +1,41 @@
# Ansible role: Ceph Storage Agent
This role bootstraps the Ceph RBD mirror agent.
# Requirements
Nothing, it runs out of the box.
# Role variables
Have a look at: `defaults/main.yml`.
## Mandatory variables
None.
# Dependencies
The role `ceph.ceph-common` must be installed.
# Example Playbook
```
- hosts: servers
remote_user: ubuntu
roles:
- { role: ceph.ceph-rbd-mirror }
```
# Contribution
**THIS REPOSITORY DOES NOT ACCEPT PULL REQUESTS**
**PULL REQUESTS MUST GO THROUGH [CEPH-ANSIBLE](https://github.com/ceph/ceph-ansible)**
# License
Apache
# Author Information
This role was created by S2bastien Han.

View File

@ -0,0 +1,28 @@
---
#########
# SETUP #
#########
# NOTE (leseb): the rbd-mirror daemon needs a user to start
# because it has to authenticate with the local cluster.
# By default, using the admin user is fine, so you should not
# need to change 'ceph_rbd_mirror_local_user' unless you have
# a dedicated key available in /etc/ceph/.
# Generally Ansible will use the admin key and put it
# under /etc/ceph/. The same goes for 'ceph_rbd_mirror_remote_user'
# there should not be any reason to change it.
ceph_rbd_mirror_local_user: admin
ceph_rbd_mirror_remote_user: admin
# NOTE (leseb): the following variable needs the name of the remote cluster.
# The name of this cluster must be different than your local cluster simply
# because we need to have both keys and ceph.conf inside /etc/ceph.
# Thus if cluster names are identical we can not have them under /etc/ceph
ceph_rbd_mirror_remote_cluster: ""
#################
# CONFIGURATION #
#################
ceph_rbd_mirror_configure: false
ceph_rbd_mirror_pool: ""

View File

@ -0,0 +1,17 @@
---
galaxy_info:
author: Sébastien Han
description: Installs Ceph Mirror Agent
license: Apache
min_ansible_version: 1.7
platforms:
- name: Ubuntu
versions:
- trusty
- name: EL
versions:
- 7
categories:
- system
dependencies:
- { role: ceph.ceph-common }

View File

@ -0,0 +1,3 @@
---
- name: add a peer
shell: "rbd mirror pool peer add {{ ceph_rbd_mirror_pool }} {{ ceph_rbd_mirror_remote_user }}@{{ ceph_rbd_mirror_remote_cluster }}"

View File

@ -0,0 +1,5 @@
---
- include: pre_requisite.yml
- include: start_rbd_mirror.yml
- include: configure_mirroring.yml
when: ceph_rbd_mirror_configure

View File

@ -0,0 +1,28 @@
---
- name: install dependencies
apt:
pkg: rbd-mirror
state: present
when: ansible_os_family == 'Debian'
tags:
- package-install
- name: install dependencies
# XXX Determine what RH repository this will belong to so that it can be
# properly checked and errored if the repository is not enabled.
yum:
name: rbd-mirror
state: present
when: ansible_os_family == 'RedHat'
tags:
- package-install
- name: copy ceph admin key
copy:
src: "{{ fetch_directory }}/{{ fsid }}/etc/ceph/{{ cluster }}.client.admin.keyring"
dest: "/etc/ceph/{{ cluster }}.client.admin.keyring"
owner: "{{ key_owner }}"
group: "{{ key_group }}"
mode: "{{ key_mode }}"
when:
cephx

View File

@ -0,0 +1,36 @@
---
- name: start and add that the rbd mirror service to the init sequence (ubuntu)
command: initctl emit ceph-rbd-mirror cluster={{ cluster }} id={{ ansible_hostname }}
changed_when: false
failed_when: false
when: ansible_distribution == "Ubuntu"
# NOTE (leseb): somehow the service ansible module is messing things up
# as a safety measure we run the raw command
- name: start and add that the rbd mirror service to the init sequence
command: service ceph start ceph-rbd-mirror
changed_when: false
when:
ansible_distribution != "Ubuntu" and
not is_ceph_infernalis
- name: enable systemd unit file for the rbd mirror service (for or after infernalis)
file:
src: /usr/lib/systemd/system/ceph-rbd-mirror@.service
dest: "/etc/systemd/system/multi-user.target.wants/ceph-rbd-mirror@{{ ceph_rbd_mirror_local_user }}.service"
state: link
changed_when: false
failed_when: false
when:
ansible_distribution != "Ubuntu" and
is_ceph_infernalis
- name: start and add that the rbd mirror service to the init sequence (for or after infernalis)
service:
name: "ceph-rbd-mirror@{{ ceph_rbd_mirror_local_user }}"
state: started
enabled: yes
changed_when: false
when:
ansible_distribution != "Ubuntu" and
is_ceph_infernalis

View File

@ -30,3 +30,8 @@
become: True
roles:
- ceph-restapi
- hosts: rbdmirrors
become: True
roles:
- ceph-rbd-mirror

View File

@ -1,9 +1,13 @@
---
- hosts: localhost
sudo: true
become: true
roles:
- ceph.ceph-common
- ceph-mon
- ceph-osd
- ceph-mds
- ceph-rgw
- ceph-fetch-keys
- ceph-agent
- ceph-common-coreos
- ceph-rbd-mirror