]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-rbd-mirror: add new role 678/head
authorSébastien Han <seb@redhat.com>
Sun, 3 Apr 2016 22:35:09 +0000 (00:35 +0200)
committerSébastien Han <seb@redhat.com>
Fri, 8 Apr 2016 10:12:15 +0000 (12:12 +0200)
Signed-off-by: Sébastien Han <seb@redhat.com>
13 files changed:
group_vars/all.sample
group_vars/rbd-mirrors.sample [new file with mode: 0644]
purge-cluster.yml
roles/ceph-common/defaults/main.yml
roles/ceph-rbd-mirror/README.md [new file with mode: 0644]
roles/ceph-rbd-mirror/defaults/main.yml [new file with mode: 0644]
roles/ceph-rbd-mirror/meta/main.yml [new file with mode: 0644]
roles/ceph-rbd-mirror/tasks/configure_mirroring.yml [new file with mode: 0644]
roles/ceph-rbd-mirror/tasks/main.yml [new file with mode: 0644]
roles/ceph-rbd-mirror/tasks/pre_requisite.yml [new file with mode: 0644]
roles/ceph-rbd-mirror/tasks/start_rbd_mirror.yml [new file with mode: 0644]
site.yml.sample
test.yml

index 3fb36ea4072f3baf6a66a8823258a49e8116d0f9..4c76b44b6d23221d77bff3e4ba45a4f6439aa457 100644 (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
diff --git a/group_vars/rbd-mirrors.sample b/group_vars/rbd-mirrors.sample
new file mode 100644 (file)
index 0000000..ad0f46f
--- /dev/null
@@ -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: ""
+
index f9ecdcf093182d5eedf89bba5247b963ae2e3cc4..6e9138b3915b2211ef8d2f50db9931a0fb4eaf89 100644 (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
       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
       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
index c951a7386c2ffd1640123db032b01207c59b6dce..131d50eab37fa04eac9fb2f8b2657254e7c33eec 100644 (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
diff --git a/roles/ceph-rbd-mirror/README.md b/roles/ceph-rbd-mirror/README.md
new file mode 100644 (file)
index 0000000..59cbc94
--- /dev/null
@@ -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.
diff --git a/roles/ceph-rbd-mirror/defaults/main.yml b/roles/ceph-rbd-mirror/defaults/main.yml
new file mode 100644 (file)
index 0000000..12207b1
--- /dev/null
@@ -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: ""
diff --git a/roles/ceph-rbd-mirror/meta/main.yml b/roles/ceph-rbd-mirror/meta/main.yml
new file mode 100644 (file)
index 0000000..648af5a
--- /dev/null
@@ -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 }
diff --git a/roles/ceph-rbd-mirror/tasks/configure_mirroring.yml b/roles/ceph-rbd-mirror/tasks/configure_mirroring.yml
new file mode 100644 (file)
index 0000000..66c32e1
--- /dev/null
@@ -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 }}"
diff --git a/roles/ceph-rbd-mirror/tasks/main.yml b/roles/ceph-rbd-mirror/tasks/main.yml
new file mode 100644 (file)
index 0000000..05fbfff
--- /dev/null
@@ -0,0 +1,5 @@
+---
+- include: pre_requisite.yml
+- include: start_rbd_mirror.yml
+- include: configure_mirroring.yml
+  when: ceph_rbd_mirror_configure
diff --git a/roles/ceph-rbd-mirror/tasks/pre_requisite.yml b/roles/ceph-rbd-mirror/tasks/pre_requisite.yml
new file mode 100644 (file)
index 0000000..3d74d3f
--- /dev/null
@@ -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
diff --git a/roles/ceph-rbd-mirror/tasks/start_rbd_mirror.yml b/roles/ceph-rbd-mirror/tasks/start_rbd_mirror.yml
new file mode 100644 (file)
index 0000000..cf2c47f
--- /dev/null
@@ -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
index 90239cb4bf70016c980d6bc16ffcc2eee287fb37..f2e81dce7860fbf16ec143a9eb0d4f04ac3eba7b 100644 (file)
@@ -30,3 +30,8 @@
   become: True
   roles:
   - ceph-restapi
+
+- hosts: rbdmirrors
+  become: True
+  roles:
+  - ceph-rbd-mirror
index d01a16d2b6b9636f4eba1021c7b4d3d30ed6f8ab..f5feddb40908b62533ede604e498eb93208b9152 100644 (file)
--- a/test.yml
+++ b/test.yml
@@ -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