From 995f9c0b81c47ed8eb7187a9e40404c0ee0019e9 Mon Sep 17 00:00:00 2001 From: Jack Lloyd-Walters Date: Fri, 18 Aug 2023 09:29:19 +0100 Subject: [PATCH] replace with isdefined --- README.md | 7 ++----- createadmin.yaml | 2 +- .../maas_region_controller/10-maas_region_controller | 4 +--- roles/maas_region_controller/tasks/install_maas.yaml | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2cac538..5a75993 100644 --- a/README.md +++ b/README.md @@ -140,11 +140,8 @@ There are additional optional variables that can be passed to the playbooks: - **admin_email**: The email address of the admin user\ Default: `admin@email.com` - - **admin_id**: The launchpad id of the admin user, can optionally be left blank (`admin_id=`)\ - Default: `admin` - - - **import_ssh_keys**: Boolean representing whether we should import ssh_keys to MAAS\ - Default: `true` + - **admin_id**: The launchpad id of the admin user\ + Default: `''` - **maas_proxy_postgres_proxy_enabled**: Use postgres proxy uri\ Default: `false` diff --git a/createadmin.yaml b/createadmin.yaml index 6866d87..ecde6b5 100644 --- a/createadmin.yaml +++ b/createadmin.yaml @@ -11,7 +11,7 @@ "(?i)Password: ": "{{ user_pwd }}" "(?i)Again: ": "{{ user_pwd }}" "(?i)Email:": "{{ user_email }}" - "(?i)Import SSH keys": "{{ user_ssh if import_ssh_keys else '' }}" + "(?i)Import SSH keys": "{{ user_ssh if user_ssh is defined else '' }}" become: true no_log: true gather_facts: true diff --git a/group_vars/maas_region_controller/10-maas_region_controller b/group_vars/maas_region_controller/10-maas_region_controller index 6ed3487..0f50f65 100644 --- a/group_vars/maas_region_controller/10-maas_region_controller +++ b/group_vars/maas_region_controller/10-maas_region_controller @@ -7,9 +7,7 @@ maas_https_port: 5443 # The https port MAAS uses to communicate on admin_username: "admin" admin_password: "admin" admin_email: "admin@email.com" -admin_id: "admin" - -import_ssh_keys: true +admin_id: "" maas_proxy_port: "{{ 5240 if 'maas_region_controller' not in group_names else 5050 }}" maas_proxy_postgres_port: "{{ 5432 if 'maas_postgres' not in group_names else 5051 }}" diff --git a/roles/maas_region_controller/tasks/install_maas.yaml b/roles/maas_region_controller/tasks/install_maas.yaml index 88353b8..8dffb4b 100644 --- a/roles/maas_region_controller/tasks/install_maas.yaml +++ b/roles/maas_region_controller/tasks/install_maas.yaml @@ -79,7 +79,7 @@ command: > maas init --rbac-url={{ maas_rbac_url | default('') | quote }} --candid-agent-file={{ maas_candid_auth_file | default('') | quote }} - --admin-ssh-import={{ admin_id if import_ssh_keys | bool else '' }} + --admin-ssh-import={{ admin_id if admin_id is defined else '' }} responses: "(?i)Username: ": "{{ admin_username }}" "(?i)Password: ": "{{ admin_password }}" @@ -97,7 +97,7 @@ - name: Add an administrator to MAAS ansible.builtin.command: maas createadmin \ --username={{ admin_username }} --password={{ admin_password }} \ - --email={{ admin_email }} --ssh-import={{ admin_id if import_ssh_keys | bool else '' }} + --email={{ admin_email }} --ssh-import={{ admin_id if admin_id is defined else '' }} when: not maas_region_new_installation or maas_installation_type | lower == 'snap' run_once: true