Provide opportunity to define cluster_name

In some cases, like AZ scenarios, deployments may interact with
several clusters at a time, while they will be distinguished by
the cluster_name. However, ceph_client role now assumes that
cluster name is `ceph` without any way to override such assumption.

Change-Id: I9dcad1e1c63294f4f59a1755507904808acb785e
This commit is contained in:
Dmitriy Rabotyagov 2022-08-09 16:29:45 +02:00
parent d9844a4e94
commit b3e7560e80
8 changed files with 24 additions and 15 deletions

View File

@ -49,6 +49,10 @@ cephx: true
# A list of the IP addresses for your Ceph monitors
ceph_mons: []
# Name of ceph cluster that we interact with.
# It would affect config file name and commands issued to the cluster.
ceph_cluster_name: ceph
# Path to local ceph.conf file
# Leave this commented to obtain a ceph.conf from one of the monitors defined in ceph_mons
#ceph_conf_file: |

View File

@ -0,0 +1,5 @@
---
features:
- |
Added variable ``ceph_cluster_name`` that allows ceph_client role to work
with clusters that have non-default cluster name. It defaults to ``ceph``.

View File

@ -15,7 +15,7 @@
- name: Create keyring files for openstack clients from extra cluster(s)
shell: ceph auth get client.{{ item.client_name }} >/dev/null && ceph auth get-or-create client.{{ item.client_name }} > /etc/ceph/ceph.client.{{ item.client_name }}.keyring.tmp
shell: "ceph auth get client.{{ item.client_name }} --cluster {{ ceph_cluster_name }} >/dev/null && ceph auth get-or-create client.{{ item.client_name }} --cluster {{ ceph_cluster_name }} > /etc/ceph/{{ ceph_cluster_name }}.client.{{ item.client_name }}.keyring.tmp"
with_items: "{{ ceph_extra_confs }}"
delegate_to: "{{ item.mon_host }}"
when:
@ -23,7 +23,7 @@
- item.mon_host is defined
- name: Get extra keyring files
command: "scp {{ item.mon_host }}:/etc/ceph/ceph.client.{{ item.client_name }}.keyring.tmp {{ item.keyring_src }}"
command: "scp {{ item.mon_host }}:/etc/ceph/{{ ceph_cluster_name }}.client.{{ item.client_name }}.keyring.tmp {{ item.keyring_src }}"
changed_when: false
delegate_to: localhost
with_items: "{{ ceph_extra_confs }}"
@ -44,7 +44,7 @@
- name: Remove temp extra keyring files
file:
path: "/etc/ceph/ceph.client.{{ item.client_name }}.keyring.tmp"
path: "/etc/ceph/{{ ceph_cluster_name }}.client.{{ item.client_name }}.keyring.tmp"
state: absent
delegate_to: "{{ item.mon_host }}"
with_items: "{{ ceph_extra_confs }}"

View File

@ -15,7 +15,7 @@
- name: Create key files for nova_compute on extra cluster(s)
shell: ceph auth get-key client.{{ item.client_name }} > /etc/ceph/ceph.client.{{ item.client_name }}.key.tmp
shell: "ceph auth get-key client.{{ item.client_name }} --cluster {{ ceph_cluster_name }} > /etc/ceph/{{ ceph_cluster_name }}.client.{{ item.client_name }}.key.tmp"
with_items: "{{ ceph_extra_confs }}"
delegate_to: "{{ item.mon_host }}"
when:
@ -23,7 +23,7 @@
- item.mon_host is defined
- name: Get extra key files
command: "scp {{ item.mon_host }}:/etc/ceph/ceph.client.{{ item.client_name }}.key.tmp /tmp/{{ item.mon_host }}{{ item.client_name }}.key.tmp"
command: "scp {{ item.mon_host }}:/etc/ceph/{{ ceph_cluster_name }}.client.{{ item.client_name }}.key.tmp /tmp/{{ item.mon_host }}{{ item.client_name }}.key.tmp"
changed_when: false
delegate_to: localhost
with_items: "{{ ceph_extra_confs }}"
@ -42,7 +42,7 @@
- name: Remove temp extra key files
file:
path: "/etc/ceph/ceph.client.{{ item.client_name }}.key.tmp"
path: "/etc/ceph/{{ ceph_cluster_name }}.client.{{ item.client_name }}.key.tmp"
state: absent
delegate_to: "{{ item.mon_host }}"
with_items: "{{ ceph_extra_confs }}"

View File

@ -23,7 +23,7 @@
- name: Get ceph.conf and store contents when ceph_conf_file is not defined
slurp:
src: /etc/ceph/ceph.conf
src: "/etc/ceph/{{ ceph_cluster_name }}.conf"
register: ceph_conf_content_mon
delegate_to: '{{ ceph_mon_host }}'
changed_when: false
@ -45,7 +45,7 @@
- name: Create ceph.conf from mon host
openstack.config_template.config_template:
content: '{{ ceph_conf }}'
dest: /etc/ceph/ceph.conf
dest: "/etc/ceph/{{ ceph_cluster_name }}.conf"
owner: root
group: root
mode: 0644

View File

@ -15,7 +15,7 @@
- name: Get extra ceph.conf files
command: "scp {{ item.mon_host }}:/etc/ceph/ceph.conf {{ item.src }}"
command: "scp {{ item.mon_host }}:/etc/ceph/{{ item.cluster_name | default(ceph_cluster_name) }}.conf {{ item.src }}"
changed_when: false
delegate_to: localhost
with_items: "{{ ceph_extra_confs }}"

View File

@ -35,8 +35,8 @@
- name: From files | Provision ceph client keyrings
copy:
dest: "/etc/ceph/ceph.client.{{ item }}.keyring"
content: "{{ hostvars['localhost']['ceph_client_keys'][item] }}\n" # noqa 206
dest: "/etc/ceph/{{ ceph_cluster_name }}.client.{{ item }}.keyring"
content: "{{ hostvars['localhost']['ceph_client_keys'][item] }}\n" # noqa 206
group: "{{ cephkeys_access_group }}"
# ideally the permission will be: 0600 and the owner/group will be either
# glance , nova or cinder. For keys that require access by different users
@ -50,7 +50,7 @@
- Restart os services
- name: From file | Retrieve nova secret
command : echo "{{ hostvars['localhost']['ceph_client_keys'][nova_ceph_client] | regex_replace('^.*\n.*= (.*)', '\1') }}" # noqa 206
command : echo "{{ hostvars['localhost']['ceph_client_keys'][nova_ceph_client] | regex_replace('^.*\n.*= (.*)', '\1') }}" # noqa 206
register: ceph_nova_secret
when:
- inventory_hostname in groups.nova_compute

View File

@ -20,7 +20,7 @@
# the first get makes sure the client exists, so the second only runs when it
# exists, the trick is the different output of both, the second has the right
# output to put in a keyring; ceph admin should have already created the user
shell: ceph auth get client.{{ item }} >/dev/null && ceph auth get-or-create client.{{ item }}
shell: "ceph auth get client.{{ item }} --cluster {{ ceph_cluster_name }} >/dev/null && ceph auth get-or-create client.{{ item }} --cluster {{ ceph_cluster_name }}"
with_items: "{{ ceph_client_filtered_clients }}"
changed_when: false
delegate_to: '{{ ceph_mon_host }}'
@ -36,7 +36,7 @@
# ceph get-or-create ... ... -o file?
template:
src: ceph.client.keyring.j2
dest: /etc/ceph/ceph.client.{{ item.item }}.keyring
dest: "/etc/ceph/{{ ceph_cluster_name }}.client.{{ item.item }}.keyring"
backup: true
owner: root
# TODO
@ -56,7 +56,7 @@
## Ceph nova client libvirt secret
- name: Retrieve nova secret from cephcluster
command: ceph auth get-key client.{{ nova_ceph_client }}
command: ceph auth get-key client.{{ nova_ceph_client }} --cluster {{ ceph_cluster_name }}
when:
- inventory_hostname in groups.nova_compute
changed_when: false