From ae6be71b081b379e19035d6abc05475ed8a00e5d Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Sun, 10 Oct 2021 02:22:08 +0330 Subject: [PATCH] cephadm: set ssh configs at bootstrap step Add support ssh_user and ssh_config to cephadm bootstrap plugin Signed-off-by: Seena Fallah --- infrastructure-playbooks/cephadm.yml | 8 ++------ library/cephadm_bootstrap.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/infrastructure-playbooks/cephadm.yml b/infrastructure-playbooks/cephadm.yml index 95b7feefc..7456e4c95 100644 --- a/infrastructure-playbooks/cephadm.yml +++ b/infrastructure-playbooks/cephadm.yml @@ -161,6 +161,8 @@ dashboard_password: "{{ dashboard_admin_password if dashboard_enabled | bool else omit }}" monitoring: false firewalld: "{{ configure_firewall }}" + ssh_user: "{{ cephadm_ssh_user | default('root') }}" + ssh_config: "{{ cephadm_ssh_config | default(omit) }}" - name: set default container image in ceph configuration command: "{{ cephadm_cmd }} shell -- ceph --cluster {{ cluster }} config set global container_image {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}" @@ -232,12 +234,6 @@ user: "{{ cephadm_ssh_user | default('root') }}" key: '{{ cephadm_pubpkey.stdout }}' - - name: set cephadm ssh user to {{ cephadm_ssh_user | default('root') }} - command: "{{ cephadm_cmd }} shell -- ceph --cluster {{ cluster }} cephadm set-user {{ cephadm_ssh_user | default('root') }}" - changed_when: false - run_once: true - delegate_to: "{{ groups[mon_group_name][0] }}" - - name: run cephadm prepare-host command: cephadm prepare-host changed_when: false diff --git a/library/cephadm_bootstrap.py b/library/cephadm_bootstrap.py index cf7f813ab..7787d50a1 100644 --- a/library/cephadm_bootstrap.py +++ b/library/cephadm_bootstrap.py @@ -98,6 +98,14 @@ options: - JSON file with custom registry login info (URL, username, password). required: false + ssh_user: + description: + - SSH user used for cephadm ssh to the hosts + required: false + ssh_config: + description: + - SSH config file path for cephadm ssh client + required: false author: - Dimitri Savineau ''' @@ -143,6 +151,8 @@ def main(): 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), ), supports_check_mode=True, mutually_exclusive=[ @@ -169,6 +179,8 @@ def main(): registry_username = module.params.get('registry_username') registry_password = module.params.get('registry_password') registry_json = module.params.get('registry_json') + ssh_user = module.params.get('ssh_user') + ssh_config = module.params.get('ssh_config') startd = datetime.datetime.now() @@ -210,6 +222,12 @@ def main(): 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 module.check_mode: exit_module( module=module,