-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cephadm-bootstrap: add missing options to module
All existing 'cephadm bootstrap' options were not available in the cephadm-boostrap module. Added xtra_opt_cli parameter to list additional parameters Added shebang and coding information to all modules as advised by(1) (1) https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_documenting.html#python-shebang-utf-8-coding Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2246266 Signed-off-by: Teoman ONAY <[email protected]>
- Loading branch information
Showing
1 changed file
with
118 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright Red Hat | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
@@ -121,6 +124,10 @@ | |
description: | ||
- subnet to use for cluster replication, recovery and heartbeats. | ||
required: false | ||
xtra_opt_cli: | ||
description: | ||
- add option not available in the list above. Check available parameters by running "cephadm bootstrap --help" | ||
required: false | ||
author: | ||
- Dimitri Savineau <[email protected]> | ||
''' | ||
|
@@ -149,37 +156,80 @@ | |
RETURN = '''# ''' | ||
|
||
|
||
def main() -> None: | ||
def run_module() -> None: | ||
|
||
cephadm_params = dict( | ||
docker=dict(type='bool', required=False, default=False), | ||
image=dict(type='str', required=False), | ||
pull=dict(type='bool', required=False, default=True), | ||
) | ||
|
||
cephadm_bootstrap_params = dict( | ||
allow_fqdn_hostname=dict(type=bool, required=False, default=False), | ||
allow_mismatched_release=dict(type=bool, required=False), | ||
allow_overwrite=dict(type=bool, required=False, default=False), | ||
apply_spec=dict(type=str, required=False), | ||
cluster_network=dict(type=str, required=False), | ||
config=dict(type=str, required=False), | ||
dashboard_crt=dict(type=str, required=False), | ||
dashboard_key=dict(type=str, required=False), | ||
dashboard_password_noupdate=dict(type=bool, required=False), | ||
fsid=dict(type=str, required=False), | ||
initial_dashboard_password=dict(type=str, required=False), | ||
initial_dashboard_user=dict(type=str, required=False), | ||
log_to_file=dict(type=bool, required=False), | ||
mgr_id=dict(type=str, required=False), | ||
mon_addrv=dict(type=str, required=False), | ||
mon_id=dict(type=str, required=False), | ||
mon_ip=dict(type=str, required=True), | ||
no_cleanup_on_failure=dict(type=bool, required=False), | ||
no_minimize_config=dict(type=bool, required=False), | ||
orphan_initial_daemons=dict(type=bool, required=False), | ||
output_config=dict(type=str, required=False), | ||
output_dir=dict(type=str, required=False), | ||
output_keyring=dict(type=str, required=False), | ||
output_pub_ssh_key=dict(type=str, required=False), | ||
registry_json=dict(type=str, required=False), | ||
registry_password=dict(type=str, required=False, no_log=True), | ||
registry_url=dict(type=str, required=False), | ||
registry_username=dict(type=str, required=False), | ||
shared_ceph_folder=dict(type=str, required=False), | ||
single_host_defaults=dict(type=bool, required=False), | ||
skip_admin_label=dict(type=bool, required=False), | ||
skip_dashboard=dict(type=bool, required=False, default=True), | ||
skip_firewalld=dict(type=bool, required=False, default=True), | ||
skip_monitoring_stack=dict(type=bool, required=False, default=True), | ||
skip_mon_network=dict(type=bool, required=False), | ||
skip_ping_check=dict(type=bool, required=False), | ||
skip_prepare_host=dict(type=bool, required=False), | ||
skip_pull=dict(type=bool, required=False), | ||
skip_ssh=dict(type=bool, required=False), | ||
ssh_config=dict(type=str, required=False), | ||
ssh_private_key=dict(type=str, required=False), | ||
ssh_public_key=dict(type=str, required=False), | ||
ssh_signed_cert=dict(type=str, required=False), | ||
ssh_user=dict(type=str, required=False), | ||
ssl_dashboard_port=dict(type=str, required=False), | ||
with_centralized_logging=dict(type=bool, required=False), | ||
) | ||
|
||
argument_spec = dict( | ||
cephadm_params=dict(type=dict, required=True, options=cephadm_params), | ||
cephadm_bootstrap_params=dict(type=dict, required=True, options=cephadm_bootstrap_params), # noqa: E501 | ||
) | ||
|
||
module = AnsibleModule( | ||
argument_spec=dict( | ||
mon_ip=dict(type='str', required=True), | ||
image=dict(type='str', required=False), | ||
docker=dict(type='bool', required=False, default=False), | ||
fsid=dict(type='str', required=False), | ||
pull=dict(type='bool', required=False, default=True), | ||
dashboard=dict(type='bool', required=False, default=True), | ||
dashboard_user=dict(type='str', required=False), | ||
dashboard_password=dict(type='str', required=False, no_log=True), | ||
monitoring=dict(type='bool', required=False, default=True), | ||
firewalld=dict(type='bool', required=False, default=True), | ||
allow_overwrite=dict(type='bool', required=False, default=False), | ||
registry_url=dict(type='str', require=False), | ||
registry_username=dict(type='str', require=False), | ||
registry_password=dict(type='str', require=False, no_log=True), | ||
registry_json=dict(type='path', require=False), | ||
ssh_user=dict(type='str', required=False), | ||
ssh_config=dict(type='str', required=False), | ||
allow_fqdn_hostname=dict(type='bool', required=False, default=False), | ||
cluster_network=dict(type='str', required=False), | ||
), | ||
argument_spec=argument_spec, | ||
supports_check_mode=True, | ||
mutually_exclusive=[ | ||
('registry_json', 'registry_url'), | ||
('registry_json', 'registry_username'), | ||
('registry_json', 'registry_password'), | ||
('mon_addrv', 'mon_ip'), | ||
], | ||
required_together=[ | ||
('registry_url', 'registry_username', 'registry_password') | ||
('registry_url', 'registry_username', 'registry_password'), | ||
|
||
], | ||
) | ||
|
||
|
@@ -211,6 +261,7 @@ def main() -> None: | |
ceph_keyring = 'ceph.client.admin.keyring' | ||
ceph_pubkey = 'ceph.pub' | ||
|
||
|
||
if fsid: | ||
if os.path.exists(os.path.join(data_dir, fsid)): | ||
out = 'A cluster with fsid {} is already deployed.'.format(fsid) | ||
|
@@ -246,48 +297,49 @@ def main() -> None: | |
|
||
cmd.extend(['bootstrap', '--mon-ip', mon_ip]) | ||
|
||
if fsid: | ||
cmd.extend(['--fsid', fsid]) | ||
|
||
if not pull: | ||
cmd.append('--skip-pull') | ||
|
||
if dashboard: | ||
if dashboard_user: | ||
cmd.extend(['--initial-dashboard-user', dashboard_user]) | ||
if dashboard_password: | ||
cmd.extend(['--initial-dashboard-password', dashboard_password]) | ||
else: | ||
cmd.append('--skip-dashboard') | ||
|
||
if not monitoring: | ||
cmd.append('--skip-monitoring-stack') | ||
|
||
if not firewalld: | ||
cmd.append('--skip-firewalld') | ||
for k in module.params: | ||
if module.params.get(k): | ||
cmd.extend(["--" + k]) | ||
|
||
if allow_overwrite: | ||
cmd.append('--allow-overwrite') | ||
|
||
if registry_url and registry_username and registry_password: | ||
cmd.extend(['--registry-url', registry_url, | ||
'--registry-username', registry_username, | ||
'--registry-password', registry_password]) | ||
|
||
if registry_json: | ||
cmd.extend(['--registry-json', registry_json]) | ||
|
||
if ssh_user: | ||
cmd.extend(['--ssh-user', ssh_user]) | ||
|
||
if ssh_config: | ||
cmd.extend(['--ssh-config', ssh_config]) | ||
|
||
if allow_fqdn_hostname: | ||
cmd.append('--allow-fqdn-hostname') | ||
|
||
if cluster_network: | ||
cmd.extend(['--cluster-network', cluster_network]) | ||
# if not pull: | ||
# cmd.append('--skip-pull') | ||
# | ||
# if dashboard: | ||
# if dashboard_user: | ||
# cmd.extend(['--initial-dashboard-user', dashboard_user]) | ||
# if dashboard_password: | ||
# cmd.extend(['--initial-dashboard-password', dashboard_password]) | ||
# else: | ||
# cmd.append('--skip-dashboard') | ||
# | ||
# if not monitoring: | ||
# cmd.append('--skip-monitoring-stack') | ||
# | ||
# if not firewalld: | ||
# cmd.append('--skip-firewalld') | ||
# | ||
# if allow_overwrite: | ||
# cmd.append('--allow-overwrite') | ||
# | ||
# if registry_url and registry_username and registry_password: | ||
# cmd.extend(['--registry-url', registry_url, | ||
# '--registry-username', registry_username, | ||
# '--registry-password', registry_password]) | ||
# | ||
# if registry_json: | ||
# cmd.extend(['--registry-json', registry_json]) | ||
# | ||
# if ssh_user: | ||
# cmd.extend(['--ssh-user', ssh_user]) | ||
# | ||
# if ssh_config: | ||
# cmd.extend(['--ssh-config', ssh_config]) | ||
# | ||
# if allow_fqdn_hostname: | ||
# cmd.append('--allow-fqdn-hostname') | ||
# | ||
# if cluster_network: | ||
# cmd.extend(['--cluster-network', cluster_network]) | ||
|
||
if module.check_mode: | ||
exit_module( | ||
|
@@ -311,6 +363,8 @@ def main() -> None: | |
changed=True | ||
) | ||
|
||
def main(): | ||
run_module() | ||
|
||
if __name__ == '__main__': | ||
main() |