blob: a957efb64e1ead836fc3e9ee80efceeed9a42234 [file] [log] [blame]
Mohammed Naser3b655592023-02-10 05:59:10 +00001# Copyright (c) 2023 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
Rico Line7132672024-02-28 00:10:53 +080015# (rlin) This is because rgw will be managed by rook operator. We need to mute
16# CEPHADM_STRAY_DAEMON until we have all daemon managed by cephadm
Giovanni Tirlonia0890072024-08-23 00:53:42 -030017- name: Set mgr/cephadm/warn_on_stray_daemons to false
Rico Line7132672024-02-28 00:10:53 +080018 run_once: true
19 delegate_to: "{{ groups[rook_ceph_cluster_mon_group][0] }}"
Giovanni Tirlonia0890072024-08-23 00:53:42 -030020 ansible.builtin.command: cephadm shell -- ceph config set mgr mgr/cephadm/warn_on_stray_daemons false
Rico Line7132672024-02-28 00:10:53 +080021 failed_when: false
22 changed_when: false
23
Mohammed Naser3b655592023-02-10 05:59:10 +000024- name: Collect "ceph quorum_status" output from a monitor
25 run_once: true
26 delegate_to: "{{ groups[rook_ceph_cluster_mon_group][0] }}"
Rico Line7132672024-02-28 00:10:53 +080027 ansible.builtin.command: cephadm shell -- ceph quorum_status -f json
Mohammed Naser3b655592023-02-10 05:59:10 +000028 changed_when: false
29 register: _rook_ceph_cluster_quorum_status_data
30
31- name: Retrieve keyring for client.admin
32 run_once: true
33 delegate_to: "{{ groups[rook_ceph_cluster_mon_group][0] }}"
Mohammed Naser545bc432023-04-16 23:02:23 +000034 vexxhost.ceph.key:
Mohammed Naser3b655592023-02-10 05:59:10 +000035 name: client.admin
36 state: info
37 output_format: json
38 register: _rook_ceph_cluster_admin_auth_data
39
40- name: Retrieve keyring for monitors
41 run_once: true
42 delegate_to: "{{ groups[rook_ceph_cluster_mon_group][0] }}"
Mohammed Naser545bc432023-04-16 23:02:23 +000043 vexxhost.ceph.key:
Mohammed Naser3b655592023-02-10 05:59:10 +000044 name: mon.
45 state: info
46 output_format: json
47 register: _rook_ceph_cluster_mon_auth_data
48
49- name: Create Ceph cluster resource
50 run_once: true
51 kubernetes.core.k8s:
52 state: present
53 definition:
54 - apiVersion: v1
55 kind: Secret
56 metadata:
57 name: rook-ceph-mon
58 namespace: "{{ rook_ceph_cluster_helm_release_namespace }}"
59 stringData:
60 cluster-name: "{{ rook_ceph_cluster_name }}"
61 fsid: "{{ _rook_ceph_cluster_quorum_status.monmap.fsid }}"
62 admin-secret: "{{ _rook_ceph_cluster_admin_auth.key }}"
63 mon-secret: "{{ _rook_ceph_cluster_mon_auth.key }}"
64
65 - apiVersion: v1
66 kind: ConfigMap
67 metadata:
68 name: rook-ceph-mon-endpoints
69 namespace: "{{ rook_ceph_cluster_helm_release_namespace }}"
70 data:
71 data: "{{ _rook_ceph_cluster_leader_name }}={{ _rook_ceph_cluster_leader_addr }}"
72 maxMonId: "0"
73 mapping: "{}"
74 vars:
75 _rook_ceph_cluster_quorum_status: "{{ _rook_ceph_cluster_quorum_status_data.stdout | from_json }}"
76 _rook_ceph_cluster_admin_auth: "{{ _rook_ceph_cluster_admin_auth_data.stdout | from_json | first }}"
77 _rook_ceph_cluster_mon_auth: "{{ _rook_ceph_cluster_mon_auth_data.stdout | from_json | first }}"
78 _rook_ceph_cluster_leader_name: "{{ _rook_ceph_cluster_quorum_status.quorum_leader_name }}"
Tadas Sutkaitis4ace4182023-02-27 04:31:52 +020079 _rook_ceph_cluster_leader_mon: "{{ (_rook_ceph_cluster_quorum_status.monmap.mons | selectattr('name', 'equalto', _rook_ceph_cluster_leader_name) | list | first) }}" # noqa: yaml[line-length]
Mohammed Naser3b655592023-02-10 05:59:10 +000080 _rook_ceph_cluster_leader_addr: "{{ _rook_ceph_cluster_leader_mon.public_addr.split('/')[0] }}"
81
82- name: Deploy Helm chart
83 run_once: true
84 kubernetes.core.helm:
85 name: "{{ rook_ceph_cluster_helm_release_name }}"
86 chart_ref: "{{ rook_ceph_cluster_helm_chart_ref }}"
87 release_namespace: "{{ rook_ceph_cluster_helm_release_namespace }}"
88 create_namespace: true
Austin Talbot78a774a2024-09-25 10:15:36 -060089 kubeconfig: "{{ rook_ceph_cluster_helm_kubeconfig }}"
Mohammed Naser3b655592023-02-10 05:59:10 +000090 values: "{{ _rook_ceph_cluster_helm_values | combine(rook_ceph_cluster_helm_values, recursive=True) }}"
91
92- name: Create OpenStack user
93 openstack.cloud.identity_user:
94 cloud: atmosphere
95 name: "{{ openstack_helm_endpoints.identity.auth.rgw.username }}"
96 password: "{{ openstack_helm_endpoints.identity.auth.rgw.password }}"
97 domain: service
98
Mohammed Naser8ccabb62025-02-05 13:20:09 -050099# NOTE(mnaser): https://storyboard.openstack.org/#!/story/2010579
Mohammed Naser3b655592023-02-10 05:59:10 +0000100- name: Grant access to "service" project
Mohammed Naser8ccabb62025-02-05 13:20:09 -0500101 changed_when: false
102 ansible.builtin.shell: |
103 set -o posix
104 source /etc/profile.d/atmosphere.sh
105 openstack role add \
106 --user-domain service \
107 --project service \
108 --user {{ openstack_helm_endpoints.identity.auth.rgw.username }} \
109 admin
110 args:
111 executable: /bin/bash
112 environment:
113 OS_CLOUD: atmosphere
Mohammed Naser3b655592023-02-10 05:59:10 +0000114
115- name: Create OpenStack service
116 openstack.cloud.catalog_service:
117 cloud: atmosphere
118 name: swift
119 service_type: object-store
120 description: OpenStack Object Storage
121
122- name: Create OpenStack endpoints
123 openstack.cloud.endpoint:
124 cloud: atmosphere
125 service: swift
126 endpoint_interface: "{{ item.interface }}"
127 url: "{{ item.url }}"
128 region: "{{ openstack_helm_endpoints.identity.auth.rgw.region_name }}"
129 loop:
130 - interface: public
131 url: "https://{{ openstack_helm_endpoints.rook_ceph_cluster.host_fqdn_override.public.host }}/swift/v1/%(tenant_id)s"
132 - interface: internal
Rico Lin90951532024-12-14 10:10:46 +0800133 url: "http://rook-ceph-rgw-{{ rook_ceph_cluster_name }}.openstack.svc.cluster.local/swift/v1/%(tenant_id)s"
Mohammed Naser3b655592023-02-10 05:59:10 +0000134
135- name: Create Ingress
136 ansible.builtin.include_role:
137 name: openstack_helm_ingress
138 vars:
139 openstack_helm_ingress_endpoint: rook_ceph_cluster
Rico Lin90951532024-12-14 10:10:46 +0800140 openstack_helm_ingress_service_name: rook-ceph-rgw-{{ rook_ceph_cluster_name }}
Mohammed Naser3b655592023-02-10 05:59:10 +0000141 openstack_helm_ingress_service_port: 80
142 openstack_helm_ingress_annotations: "{{ _rook_ceph_cluster_radosgw_annotations | combine(rook_ceph_cluster_radosgw_annotations, recursive=True) }}"
Mohammed Naserc139abc2025-02-05 14:03:20 -0500143 openstack_helm_ingress_class_name: "{{ rook_ceph_cluster_ingress_class_name }}"