ansible-collection-atmosphere/roles/ceph_mon/tasks/bootstrap-ceph.yml

110 lines
3.6 KiB
YAML

# Copyright (c) 2022 VEXXHOST, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# TODO(mnaser): Move to using vexxhost.atmosphere.ceph_key
- name: create monitor keyring
ansible.builtin.command:
ceph-authtool --gen-key --create-keyring
--name mon.
--cap mon 'allow *'
/tmp/ceph.mon.keyring
args:
creates: /tmp/ceph.mon.keyring
when:
- inventory_hostname == groups[ceph_mon_group][0]
# TODO(mnaser): Move to using vexxhost.atmosphere.ceph_key
- name: create admin keyring
ansible.builtin.command:
ceph-authtool --gen-key --create-keyring
--name client.admin
--cap mon 'allow *'
--cap osd 'allow *'
--cap mds 'allow *'
--cap mgr 'allow *'
/etc/ceph/ceph.client.admin.keyring
args:
creates: /etc/ceph/ceph.client.admin.keyring
when:
- inventory_hostname == groups[ceph_mon_group][0]
# TODO(mnaser): Move to using vexxhost.atmosphere.ceph_key
- name: create bootstrap-osd keyring
ansible.builtin.command:
ceph-authtool --gen-key --create-keyring
--name client.bootstrap-osd
--cap mon 'profile bootstrap-osd'
--cap mgr 'allow r'
/var/lib/ceph/bootstrap-osd/ceph.keyring
args:
creates: /var/lib/ceph/bootstrap-osd/ceph.keyring
when:
- inventory_hostname == groups[ceph_mon_group][0]
# TODO(mnaser): Move to using vexxhost.atmosphere.ceph_key
- name: add admin keyring to monitor
ansible.builtin.command:
ceph-authtool --import-keyring /etc/ceph/ceph.client.admin.keyring
/tmp/ceph.mon.keyring
when:
- inventory_hostname == groups[ceph_mon_group][0]
# TODO(mnaser): Move to using vexxhost.atmosphere.ceph_key
- name: add bootstrap-osd keyring to monitor
ansible.builtin.command:
ceph-authtool --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring
/tmp/ceph.mon.keyring
when:
- inventory_hostname == groups[ceph_mon_group][0]
- name: create monmap
ansible.builtin.command:
monmaptool --create
--fsid {{ ceph_mon_fsid }}
--add {{ inventory_hostname_short }} {{ ceph_mon_ip_address }}
/tmp/monmap
args:
creates: /tmp/monmap
when:
- inventory_hostname == groups[ceph_mon_group][0]
- name: create monitor folder
ansible.builtin.file:
path: "/var/lib/ceph/mon/ceph-{{ inventory_hostname_short }}"
state: directory
owner: ceph
group: ceph
mode: 0700
when:
- inventory_hostname == groups[ceph_mon_group][0]
- name: configure mon initial members
community.general.ini_file:
path: /etc/ceph/ceph.conf
section: global
option: mon initial members
value: "{{ inventory_hostname_short }}"
owner: ceph
group: ceph
mode: 0640
- name: start monitor
ansible.builtin.include_tasks: start-monitor.yml
when:
- inventory_hostname == groups[ceph_mon_group][0]
- name: set bootstrap node
ansible.builtin.set_fact:
_ceph_mon_bootstrap_node: "{{ groups[ceph_mon_group][0] }}"