Add --daemons option to deployed ceph

This change introduces a new option that allows the operators to deploy
additional daemons when the ceph cluster is deployed.  The purpose of
this patch is to support [1], where ceph_nfs, mds and the ingress
daemons can be deployed as part of deployed ceph.

[1] https://review.opendev.org/c/openstack/tripleo-ansible/+/825440

Depends-On: Ic0b26d7ee505ca84129782f58f9d14f815467854
Change-Id: Ic078324843e64c684073af7c563f70be1faa138c
This commit is contained in:
Francesco Pantano 2022-02-22 14:43:47 +01:00
parent 944c11b97f
commit 0f78798014
4 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,22 @@
---
features:
- |
A new option --daemons for the "openstack overcloud ceph deploy" command
has been added. This option may be used to define additional Ceph daemons
that should be deployed at this stage.
For instance, a generic Ceph daemons definition can be something like the
following::
---
ceph_nfs:
cephfs_data: 'manila_data'
cephfs_metadata: 'manila_metadata'
ceph_rgw: {}
ceph_ingress:
tripleo_cephadm_haproxy_container_image: undercloud.ctlplane.mydomain.tld:8787/ceph/haproxy:2.3
tripleo_cephadm_keepalived_container_image: undercloud.ctlplane.mydomain.tld:8787/ceph/keepalived:2.5.1
For each service added to the data structure above, additional options can
be defined and passed as extra_vars to the tripleo-ansible flow.
If no option is specified, the default values provided by the cephadm
tripleo-ansible role will be used.

View File

@ -2791,3 +2791,27 @@ class TestCephSpecStandalone(TestCase):
list(io.open(my_spec.name)))
expected_spec.close()
my_spec.close()
class TestProcessCephDaemons(TestCase):
def test_process_ceph_daemons(self):
daemon_opt = yaml.safe_load('''
ceph_nfs:
cephfs_data: manila_data
cephfs_metadata: manila_metadata
''')
expected = {
'tripleo_cephadm_daemon_ceph_nfs': True,
'cephfs_data': 'manila_data',
'cephfs_metadata': 'manila_metadata'
}
# daemon_input = tempfile.NamedTemporaryFile()
with tempfile.NamedTemporaryFile(mode='w') as f:
yaml.safe_dump(daemon_opt, f)
found = utils.process_ceph_daemons(f.name)
self.assertEqual(found, expected)

View File

@ -3485,3 +3485,22 @@ def standalone_ceph_inventory(working_dir):
with open(path, 'w') as f:
f.write(yaml.safe_dump(inv))
return path
def process_ceph_daemons(daemon_path):
"""Load the ceph daemons related extra_vars and return the associated dict
:param daemon_path: the path where the daemon definition is stored
:return: dict mapping each daemon option to a value passes to ansible
"""
extra_vars = dict()
with open(daemon_path, 'r') as f:
ceph_daemons = yaml.safe_load(f.read())
try:
for daemon in ceph_daemons.keys():
extra_vars['tripleo_cephadm_daemon_' + daemon] = True
# process current daemon paramters/options
for k, v in ceph_daemons.get(daemon).items():
extra_vars[k] = v
except AttributeError:
return extra_vars
return extra_vars

View File

@ -179,6 +179,11 @@ class OvercloudCephDeploy(command.Command):
"Path to an existing Ceph services/network "
"mapping file."),
default=None),
parser.add_argument('--daemons',
help=_(
"Path to an existing Ceph daemon options "
"definition."),
default=None),
parser.add_argument('--single-host-defaults', default=False,
action='store_true',
help=_("Adjust configuration defaults to suit "
@ -403,6 +408,16 @@ class OvercloudCephDeploy(command.Command):
else:
extra_vars['tripleo_cephadm_ha_services_path'] = \
os.path.abspath(parsed_args.ceph_vip)
if parsed_args.daemons:
if not os.path.exists(parsed_args.daemons):
raise oscexc.CommandError(
"ceph daemon options file not found --daemons %s."
% os.path.abspath(parsed_args.daemons))
else:
daemon_opt = oooutils.process_daemons(
os.path.abspath(parsed_args.daemons))
# merge the processed extra_vars for daemons
extra_vars = {**extra_vars, **daemon_opt}
# optional container vars to pass to playbook
keys = ['ceph_namespace', 'ceph_image', 'ceph_tag']
push_sub_keys = ['ceph_namespace']