ceph-ansible/roles/ceph-mon/tasks/deploy_monitors.yml

67 lines
2.5 KiB
YAML

---
- name: generate monitor initial keyring
local_action: shell python -c "import os ; import struct ; import time; import base64 ; key = os.urandom(16) ; header = struct.pack('<hiih',1,int(time.time()),0,len(key)) ; print base64.b64encode(header + key)" | tee {{ fetch_directory }}/monitor_keyring.conf
creates={{ fetch_directory }}/monitor_keyring.conf
register: monitor_keyring
sudo: false
when: monitor_secret != 'AQAWqilTCDh7CBAAawXt6kyTgLFCxSvJhTEmuw=='
- name: read monitor initial keyring if it already exists
local_action: command cat {{ fetch_directory }}/monitor_keyring.conf
removes={{ fetch_directory }}/monitor_keyring.conf
changed_when: false
register: monitor_keyring
sudo: false
when: monitor_secret != 'AQAWqilTCDh7CBAAawXt6kyTgLFCxSvJhTEmuw=='
- name: create monitor initial keyring
command: ceph-authtool /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} --create-keyring --name=mon. --add-key={{ monitor_secret }} --cap mon 'allow *'
args:
creates: /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }}
- name: set initial monitor key permissions (for or after infernalis release)
file:
path: /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }}
mode: 0600
owner: ceph
group: ceph
when: is_ceph_infernalis
- name: set initial monitor key permissions (before infernalis release)
file:
path: /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }}
mode: 0600
owner: root
group: root
when: not is_ceph_infernalis
- name: create monitor directory (for or after infernalis release)
file:
path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}
state: directory
owner: ceph
group: ceph
mode: 0755
when: is_ceph_infernalis
- name: create monitor directory (before infernalis release)
file:
path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}
state: directory
owner: root
group: root
mode: 0755
when: not is_ceph_infernalis
- name: ceph monitor mkfs (for or after infernalis release)
command: ceph-mon --setuser ceph --setgroup ceph --mkfs -i {{ ansible_hostname }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }}
args:
creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/keyring
when: is_ceph_infernalis
- name: ceph monitor mkfs (before infernalis release)
command: ceph-mon --mkfs -i {{ ansible_hostname }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }}
args:
creates: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/keyring
when: not is_ceph_infernalis