2014-09-05 03:14:11 +08:00
|
|
|
---
|
2015-07-17 00:42:12 +08:00
|
|
|
- name: generate monitor initial keyring
|
2018-11-01 19:50:31 +08:00
|
|
|
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)) ;
|
2018-11-16 17:50:38 +08:00
|
|
|
print(base64.b64encode(header + key).decode())"
|
2015-07-17 20:06:25 +08:00
|
|
|
register: monitor_keyring
|
2016-02-25 21:57:50 +08:00
|
|
|
when: cephx
|
2018-11-16 17:50:38 +08:00
|
|
|
run_once: true # must run on a single mon only
|
2015-07-17 00:42:12 +08:00
|
|
|
|
2018-11-16 17:50:38 +08:00
|
|
|
# add code to read the key or/and try to find it on other nodes
|
2015-07-17 00:42:12 +08:00
|
|
|
|
2015-05-16 00:27:41 +08:00
|
|
|
- name: create monitor initial keyring
|
2018-04-04 22:22:36 +08:00
|
|
|
ceph_key:
|
|
|
|
name: mon.
|
|
|
|
state: present
|
|
|
|
dest: "/var/lib/ceph/tmp/"
|
2018-11-16 17:50:38 +08:00
|
|
|
secret: "{{ monitor_keyring.stdout }}"
|
2018-04-04 22:22:36 +08:00
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
caps:
|
|
|
|
mon: allow *
|
|
|
|
import_key: False
|
2018-11-16 17:50:38 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
mode: "0400"
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2016-02-25 21:57:50 +08:00
|
|
|
when: cephx
|
2014-09-05 03:14:11 +08:00
|
|
|
|
2018-11-16 17:50:38 +08:00
|
|
|
- name: copy the initial key in /etc/ceph (for containers)
|
|
|
|
command: >
|
|
|
|
cp /var/lib/ceph/tmp/{{ cluster }}.mon..keyring /etc/ceph/{{ cluster }}.mon.keyring
|
|
|
|
changed_when: false
|
|
|
|
when:
|
|
|
|
- cephx
|
|
|
|
- containerized_deployment
|
2015-11-17 23:10:02 +08:00
|
|
|
|
2017-06-30 16:17:23 +08:00
|
|
|
- name: create (and fix ownership of) monitor directory
|
2015-11-17 23:10:02 +08:00
|
|
|
file:
|
2016-03-29 21:37:31 +08:00
|
|
|
path: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}
|
2015-11-17 23:10:02 +08:00
|
|
|
state: directory
|
2018-11-16 17:50:38 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
2019-02-27 01:30:31 +08:00
|
|
|
mode: "u=rwX,g=rX,o=rX"
|
2017-06-30 16:17:23 +08:00
|
|
|
recurse: true
|
2015-11-17 23:10:02 +08:00
|
|
|
|
2017-07-05 17:07:00 +08:00
|
|
|
- name: create custom admin keyring
|
2018-04-04 22:22:36 +08:00
|
|
|
ceph_key:
|
|
|
|
name: client.admin
|
|
|
|
state: present
|
|
|
|
secret: "{{ admin_secret }}"
|
|
|
|
caps: "{{ client_admin_ceph_authtool_cap }}"
|
|
|
|
import_key: False
|
|
|
|
cluster: "{{ cluster }}"
|
2018-11-16 17:50:38 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
mode: "0400"
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2017-07-05 17:07:00 +08:00
|
|
|
register: create_custom_admin_secret
|
|
|
|
when:
|
|
|
|
- cephx
|
|
|
|
- admin_secret != 'admin_secret'
|
|
|
|
|
2018-11-16 17:50:38 +08:00
|
|
|
- name: set_fact ceph-authtool container command
|
|
|
|
set_fact:
|
2019-02-01 05:17:20 +08:00
|
|
|
ceph_authtool_cmd: "{{ container_binary + ' run --net=host --rm -v /var/lib/ceph:/var/lib/ceph:z -v /etc/ceph/:/etc/ceph/:z --entrypoint=ceph-authtool ' + ceph_client_docker_registry + '/' + ceph_client_docker_image + ':' + ceph_client_docker_image_tag if containerized_deployment else 'ceph-authtool' }}"
|
2017-07-05 17:07:00 +08:00
|
|
|
|
|
|
|
- name: import admin keyring into mon keyring
|
2018-11-16 17:50:38 +08:00
|
|
|
command: >
|
|
|
|
{{ ceph_authtool_cmd }}
|
2019-01-16 17:27:23 +08:00
|
|
|
/var/lib/ceph/tmp/{{ cluster }}.mon..keyring --import-keyring /etc/ceph/{{ cluster }}.client.admin.keyring
|
2017-07-05 17:07:00 +08:00
|
|
|
when:
|
2017-08-22 20:10:10 +08:00
|
|
|
- not create_custom_admin_secret.get('skipped')
|
2017-07-05 17:07:00 +08:00
|
|
|
- cephx
|
|
|
|
- admin_secret != 'admin_secret'
|
|
|
|
|
2018-11-16 17:50:38 +08:00
|
|
|
- name: set_fact ceph-mon container command
|
|
|
|
set_fact:
|
|
|
|
ceph_mon_cmd: "{{ container_binary + ' run --rm --net=host -v /var/lib/ceph/:/var/lib/ceph:z -v /etc/ceph/:/etc/ceph/:z --entrypoint=ceph-mon ' + ceph_client_docker_registry + '/' + ceph_client_docker_image + ':' +ceph_client_docker_image_tag if containerized_deployment else 'ceph-mon' }}"
|
|
|
|
|
2017-01-20 17:14:35 +08:00
|
|
|
- name: ceph monitor mkfs with keyring
|
2018-11-16 17:50:38 +08:00
|
|
|
command: >
|
|
|
|
{{ ceph_mon_cmd }}
|
|
|
|
--cluster {{ cluster }}
|
2019-02-08 23:05:20 +08:00
|
|
|
--setuser "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
--setgroup "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
2018-11-16 17:50:38 +08:00
|
|
|
--mkfs
|
|
|
|
-i {{ monitor_name }}
|
|
|
|
--fsid {{ fsid }}
|
|
|
|
--keyring /var/lib/ceph/tmp/{{ cluster }}.mon..keyring
|
2015-11-17 23:10:02 +08:00
|
|
|
args:
|
2016-03-29 21:37:31 +08:00
|
|
|
creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring
|
2016-02-25 21:57:50 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- cephx
|
2014-09-05 03:14:11 +08:00
|
|
|
|
2017-01-20 17:14:35 +08:00
|
|
|
- name: ceph monitor mkfs without keyring
|
2018-11-16 17:50:38 +08:00
|
|
|
command: >
|
|
|
|
{{ ceph_mon_cmd }}
|
|
|
|
--cluster {{ cluster }}
|
2019-02-08 23:05:20 +08:00
|
|
|
--setuser "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
--setgroup "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
2018-11-16 17:50:38 +08:00
|
|
|
--mkfs
|
|
|
|
-i {{ monitor_name }}
|
|
|
|
--fsid {{ fsid }}
|
2016-02-25 21:57:50 +08:00
|
|
|
args:
|
2016-03-29 21:37:31 +08:00
|
|
|
creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/store.db
|
2016-02-25 21:57:50 +08:00
|
|
|
when:
|
2018-11-16 17:50:38 +08:00
|
|
|
- not cephx
|