|
2 | 2 |
|
3 | 3 | # Renamed the file to create-admin-account.yml since that is its only purpose. |
4 | 4 | # This task file is only included when initializing new wikis. |
5 | | -# Prompt for secure admin password for Demo Wiki |
6 | | -- name: Prompt for Admin password on Demo Wiki |
7 | | - ansible.builtin.pause: |
8 | | - prompt: | |
9 | | -
|
10 | | - Creating Admin user for Demo Wiki ({{ wiki_id }}) |
11 | | -
|
12 | | - MediaWiki Password Requirements: |
13 | | - - Minimum 8 characters |
14 | | - - Must contain at least one uppercase letter |
15 | | - - Must contain at least one lowercase letter |
16 | | - - Must contain at least one number |
17 | | - - Must contain at least one special character (!@#$%^&*()_+-=[]{}|;:,.<>?) |
18 | | - - Cannot contain spaces |
19 | | -
|
20 | | - Enter a secure password for the Admin user |
21 | | - echo: false |
22 | | - register: admin_password_prompt |
23 | | - run_once: true |
24 | | - when: wiki_id == "demo" |
| 5 | +# The admin_password variable is provided by the playbook's vars_prompt |
25 | 6 |
|
26 | 7 | # Validate password meets MediaWiki requirements |
27 | 8 | - name: Validate Admin password meets requirements |
|
31 | 12 | - Must be at least 8 characters long |
32 | 13 | - Must contain uppercase, lowercase, number, and special character |
33 | 14 | - Cannot contain spaces |
34 | | - when: |
35 | | - - wiki_id == "demo" |
36 | | - - > |
37 | | - admin_password_prompt.user_input | length < 8 or |
38 | | - admin_password_prompt.user_input is not regex('[A-Z]') or |
39 | | - admin_password_prompt.user_input is not regex('[a-z]') or |
40 | | - admin_password_prompt.user_input is not regex('[0-9]') or |
41 | | - admin_password_prompt.user_input is not regex('[!@#$%^&*()_+\-=\[\]{}|;:,.<>?]') or |
42 | | - ' ' in admin_password_prompt.user_input |
| 15 | + when: > |
| 16 | + admin_password | length < 8 or |
| 17 | + admin_password is not regex('[A-Z]') or |
| 18 | + admin_password is not regex('[a-z]') or |
| 19 | + admin_password is not regex('[0-9]') or |
| 20 | + admin_password is not regex('[!@#$%^&*()_+\-=\[\]{}|;:,.<>?]') or |
| 21 | + ' ' in admin_password |
43 | 22 | run_once: true |
44 | 23 |
|
45 | | -# Create an admin user for Demo Wiki with the provided secure password |
| 24 | +# Create an admin user for the new wiki with the provided secure password |
46 | 25 | # https://www.mediawiki.org/wiki/Manual:CreateAndPromote.php |
47 | 26 | # https://meta.wikimedia.org/wiki/Password_policy |
48 | | -- name: Create Admin user on Demo Wiki |
| 27 | +- name: Create Admin user on new wiki |
49 | 28 | ansible.builtin.shell: > |
50 | | - WIKI={{ wiki_id | quote }} {{ m_mediawiki | quote }}/maintenance/run createAndPromote --force --sysop --bureaucrat Admin {{ admin_password_prompt.user_input | quote }} |
| 29 | + WIKI={{ wiki_id | quote }} {{ m_mediawiki | quote }}/maintenance/run createAndPromote --force --sysop --bureaucrat Admin {{ admin_password | quote }} |
51 | 30 | run_once: true |
52 | | - when: wiki_id == "demo" |
53 | 31 | no_log: true |
0 commit comments