Skip to content

Commit 6db34c4

Browse files
committed
Add a playbook to generate Kayobe configuration for Ceph via Cephadm
1 parent 70b0c82 commit 6db34c4

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
- name: Gather Ceph configuration and keys and populate kayobe-config
3+
gather_facts: false
4+
hosts: mons
5+
run_once: true
6+
tags:
7+
- cephadm
8+
- cephadm-gather-keys
9+
vars:
10+
# Map from an OpenStack service to the directory in which to store Ceph keys for it.
11+
kolla_service_to_key_dir:
12+
cinder-backup: cinder/cinder-backup
13+
cinder-volume: cinder/cinder-volume
14+
glance: glance
15+
manila: manila
16+
nova: nova
17+
# Map from an OpenStack service to the directory in which to store Ceph configuration for it.
18+
kolla_service_to_conf_dir:
19+
cinder-backup: cinder
20+
cinder-volume: cinder
21+
glance: glance
22+
manila: manila
23+
nova: nova
24+
tasks:
25+
- name: Get Ceph keys
26+
stackhpc.cephadm.cephadm_key:
27+
name: "{{ item }}"
28+
state: info
29+
register: cephadm_key_info
30+
become: true
31+
loop: "{{ kolla_ceph_services | selectattr('required') | map(attribute='keys') | flatten | unique }}"
32+
33+
- name: Generate ceph.conf
34+
command: "cephadm shell -- ceph config generate-minimal-conf"
35+
become: true
36+
register: cephadm_ceph_conf
37+
changed_when: false
38+
39+
- name: Ensure Kolla config directories are present
40+
file:
41+
state: directory
42+
path: "{{ kayobe_env_config_path }}/kolla/config/{{ kolla_service_to_key_dir[item.name] }}"
43+
loop: "{{ kolla_ceph_services | selectattr('required') }}"
44+
loop_control:
45+
label:
46+
service: "{{ item.name }}"
47+
delegate_to: localhost
48+
49+
- name: Save Ceph keys to Kayobe configuration
50+
vars:
51+
key_info: "{{ cephadm_key_info.results | selectattr('item', 'equalto', item.1) | first }}"
52+
cephadm_key: "{{ (key_info.stdout | from_json | first)['key'] }}"
53+
cephadm_user: "{{ (key_info.stdout | from_json | first)['entity'] }}"
54+
copy:
55+
content: "{{ cephadm_key }}"
56+
dest: "{{ kayobe_env_config_path }}/kolla/config/{{ kolla_service_to_key_dir[item.0.name] }}/ceph.{{ cephadm_user }}.keyring"
57+
loop: "{{ query('subelements', kolla_ceph_services | selectattr('required'), 'keys') }}"
58+
loop_control:
59+
label:
60+
service: "{{ item.0.name }}"
61+
key: "{{ item.1 }}"
62+
delegate_to: localhost
63+
notify: Please add and commit the Kayobe configuration
64+
65+
- name: Save ceph.conf to Kayobe configuration
66+
copy:
67+
content: "{{ cephadm_ceph_conf.stdout }}"
68+
dest: "{{ kayobe_env_config_path }}/kolla/config/{{ kolla_service_to_conf_dir[item.0.name] }}/ceph.conf"
69+
loop: "{{ query('subelements', kolla_ceph_services | selectattr('required'), 'keys') }}"
70+
loop_control:
71+
label:
72+
service: "{{ item.0.name }}"
73+
key: "{{ item.1 }}"
74+
delegate_to: localhost
75+
notify: Please add and commit the Kayobe configuration
76+
77+
handlers:
78+
- name: Please add and commit the Kayobe configuration
79+
debug:
80+
msg: >-
81+
Please add and commit the Ceph configuration files and keys in Kayobe
82+
configuration. Remember to encrypt the keys using Ansible Vault.

etc/kayobe/cephadm.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,45 @@ cephadm_cluster_network: "{{ storage_mgmt_net_name | net_cidr }}"
5656

5757
# List of Cephx keys. See stackhpc.cephadm.keys role for format.
5858
#cephadm_keys:
59+
60+
###############################################################################
61+
# Kolla Ceph auto-configuration.
62+
63+
# List of Kolla Ansible services that require Ceph configuration files.
64+
kolla_ceph_services:
65+
- name: cinder-backup
66+
keys:
67+
- client.cinder
68+
- client.cinder-backup
69+
required: "{{ kolla_ceph_cinder_backup_required | bool }}"
70+
- name: cinder-volume
71+
keys:
72+
- client.cinder
73+
required: "{{ kolla_ceph_cinder_volume_required | bool }}"
74+
- name: glance
75+
keys:
76+
- client.glance
77+
required: "{{ kolla_ceph_glance_required | bool }}"
78+
- name: manila
79+
keys:
80+
- client.manila
81+
required: "{{ kolla_ceph_manila_required | bool }}"
82+
- name: nova
83+
keys:
84+
- client.cinder
85+
required: "{{ kolla_ceph_nova_required | bool }}"
86+
87+
# Whether to generate Ceph configuration for Cinder volume.
88+
kolla_ceph_cinder_volume_required: "{{ kolla_enable_cinder | bool }}"
89+
90+
# Whether to generate Ceph configuration for Cinder backup.
91+
kolla_ceph_cinder_backup_required: "{{ kolla_enable_cinder_backup | default(false) | bool }}"
92+
93+
# Whether to generate Ceph configuration for Glance.
94+
kolla_ceph_glance_required: "{{ kolla_enable_glance | bool }}"
95+
96+
# Whether to generate Ceph configuration for Manila.
97+
kolla_ceph_manila_required: "{{ kolla_enable_manila | bool }}"
98+
99+
# Whether to generate Ceph configuration for Nova.
100+
kolla_ceph_nova_required: "{{ kolla_enable_nova | bool }}"

0 commit comments

Comments
 (0)