Skip to content

Commit c8c213d

Browse files
authored
Clean up admin password initial checks to only require minimum of 2 chars by default (#21)
Remove admin_password from early globals setup, and reserve for final init calls to avoid excessive logging Add init_call_cdp_public to test if top level keys have been set to request CDP Public actions which may require password enforcement Set regex enforcement of CDP Public Password to 8-64 chars, 1 special, 1 number, 1 capital if CDP Public is being called Signed-off-by: Daniel Chaffelson <chaffelson@gmail.com>
1 parent 53a6a37 commit c8c213d

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

roles/cloudera_deploy/tasks/init.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@
8585

8686
# Admin Password
8787
- name: Prompt User for a password if not provided in config or vault
88-
when: admin_password is undefined or admin_password | length < 4
88+
when: admin_password is undefined or admin_password | length < 2
8989
block:
9090
- name: Prompt User for Password if not supplied
91-
when: admin_password is undefined
9291
no_log: true
9392
pause:
94-
prompt: "No admin password found in profile.yml or extra_vars, please provide a Password"
93+
prompt: "No admin password found in profile.yml or extra_vars, or provided password too short; please provide a Password"
9594
register: __user_input_password
9695

9796
- name: Set Admin password
@@ -105,8 +104,8 @@
105104
quiet: yes
106105
that:
107106
- admin_password is defined
108-
- admin_password | length > 3
109-
fail_msg: "You must supply an Admin Password"
107+
- admin_password | length > 2
108+
fail_msg: "You must supply an Admin Password of at least 2 chars"
110109

111110
# Handle Definition File
112111
- name: Seek Definition files in Definition Path
@@ -165,7 +164,6 @@
165164
vars:
166165
user_config:
167166
name_prefix: "{{ name_prefix | default(default_name_prefix) }}"
168-
admin_password: "{{ admin_password }}"
169167
tags: "{{ tags | default(omit) }}"
170168
region: "{{ infra_region | default(default_infra_region) }}"
171169
infra_type: "{{ infra_type | default(default_infra_type) }}"
@@ -343,14 +341,24 @@
343341
msg: "{{ globals }}"
344342
verbosity: 3
345343

344+
- name: Determine if Cloud Roles should be called
345+
ansible.builtin.set_fact:
346+
init__call_cloud_role: "{{ infra is defined or env is defined or ml is defined or de is defined or datahub is defined or opdb is defined or dw is defined | default(False) }}"
347+
init__call_cdp_public: "{{ env is defined or ml is defined or de is defined or datahub is defined or opdb is defined or dw is defined | default(False) }}"
348+
349+
- name: Check Admin Password is CDP Public compliant when calling CDP Public
350+
when: init__call_cdp_public | bool
351+
ansible.builtin.assert:
352+
that:
353+
- admin_password is match('^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@$!%*#?&])[A-Za-z\\d@$!%*#?&]{8,64}$')
354+
fail_msg: >-
355+
Admin Password must comply with CDP Public requirements: 1 Upper, 1 Special, 1 Number, 8-64 chars.
356+
quiet: yes
357+
346358
- name: Add no_log variables to globals at end of init
347359
no_log: true
348360
ansible.builtin.set_fact:
349361
globals: "{{ globals | default({}) | combine(__no_log_globals, recursive=True) }}"
350362
vars:
351363
__no_log_globals:
352364
admin_password: "{{ admin_password | mandatory }}"
353-
354-
- name: Determine if Cloud Roles should be called
355-
ansible.builtin.set_fact:
356-
init__call_cloud_role: "{{ infra is defined or env is defined or ml is defined or de is defined or datahub is defined or opdb is defined or dw is defined | default(False) }}"

0 commit comments

Comments
 (0)