Skip to content

Commit b19e5f5

Browse files
committed
Major enhancements: Create wiki logging, etc.
"meza create wiki" logging implementation ----------------------------------------- The new create-wiki logging mirrors the deploy logging architecture with both transactional and processing logs. Transactional log: /opt/data-meza/logs/create-wiki/create-wiki.log (tracks operations with metadata) Processing log: /opt/data-meza/logs/create-wiki-output/{env}-{timestamp}.log (captures ansible output) /opt/data-meza/logs/ ├── create-wiki/ # Transactional logs │ └── create-wiki.log # Audit trail └── create-wiki-output/ # Processing logs ├── demo-2025-10-29_175734.log └── prod-2025-10-29_180234.log Added two new commands: sudo meza create-wiki-tail <env> - tells you what log its tailing and provides a way to check status on the create wiki process in real-time sudo meza create-wiki-log <env> - tells you the path of the process log e.g. /opt/data-meza/logs/create-wiki-output/monolith-2025-10-29_225319.log Meza.py uses paths from paths.yml --------------------------------- - Single Source of Truth: All paths defined in paths.yml, easy to maintain - Removed hardcoded path definitions from meza.py - Consistency: Python CLI uses same paths as Ansible roles - Deterministic: No fallbacks, clear failures - Jinja2 Template Support: variables found in yaml are resolved. {{ m_install }} resolves to 'opt' - Error Handling: Clear error messages for configuration issues such as paths.yml missing - new m_logs_create_wiki variable in paths.yml to define the location of the "meza create wiki" log Verify-wiki enhanced ---------------------- wiki_id and wiki_name (as well as password) are passed by extra_vars in meza.py when it calls create-wiki-promptless playbook. create-wiki playbook now prompts for Admin password and passes it on to the 'create-admin-account' task list in verify-wiki. src/roles/verify-wiki/tasks/import-wiki-sql.yml is enhanced with output about wiki creation status and the set_fact section was improved to clarify what's happening: - New wiki was created (truly new, not from backup) - Wiki created but from backup/import - Wiki already existed BEFORE the created_new_wiki flag logic was problematic. Admin Account creation ---------------------- The admin account creation was hardcoded to only work for wikis with wiki_id == "demo" Removed wiki_id restriction: Changed from when: wiki_id == "demo" to run for any new wiki Updated prompts: Made the messages generic to work for any wiki name Fixes Issue #217 Fixes Issue #220
1 parent 465eaee commit b19e5f5

File tree

8 files changed

+374
-61
lines changed

8 files changed

+374
-61
lines changed

config/paths.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ m_cache_directory: "{{ m_meza_data }}/cache"
3030
m_tmp: "{{ m_meza_data }}/tmp"
3131
m_logs: "{{ m_meza_data }}/logs"
3232
m_logs_deploy: "{{ m_meza_data }}/logs/deploy/deploy.log"
33+
m_logs_create_wiki: "{{ m_meza_data }}/logs/create-wiki/create-wiki.log"
3334

3435
# uploads dir. This WILL BE OVERIDDEN if multiple app servers are used, and
3536
# instead will use /opt/data-meza/uploads-gluster to use GlusterFS distributed

src/playbooks/create-wiki-promptless.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
- hosts: app_servers
44
become: true
5+
vars:
6+
# admin_password is passed via extra vars from meza.py
7+
# wiki_id and wiki_name are also passed via extra vars
58
roles:
69
- set-vars
710
- create-wiki-wrapper

src/playbooks/create-wiki.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- hosts: app_servers
44
become: true
55

6-
# prompt for wiki_id and wiki_name
6+
# prompt for wiki_id, wiki_name, and admin_password
77
vars_prompt:
88
- name: "wiki_id"
99
prompt: |
@@ -25,6 +25,21 @@
2525
Type the desired wiki name and press [ENTER]:
2626
private: false
2727

28+
- name: "admin_password"
29+
prompt: |
30+
Creating Admin user for this new wiki.
31+
32+
MediaWiki Password Requirements:
33+
- Minimum 8 characters
34+
- Must contain at least one uppercase letter
35+
- Must contain at least one lowercase letter
36+
- Must contain at least one number
37+
- Must contain at least one special character (!@#$%^&*()_+-=[]{}|;:,.<>?)
38+
- Cannot contain spaces
39+
40+
Enter a secure password for the Admin user:
41+
private: true
42+
2843
roles:
2944
- set-vars
3045
- create-wiki-wrapper

src/roles/create-wiki-wrapper/tasks/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
include_role:
3131
name: verify-wiki
3232

33+
# Create symlink to core for short urls (from mediawiki role)
34+
# This is needed for new wikis created individually (not during full deploy)
35+
- name: Create symlink to core, to enable short urls
36+
file:
37+
src: "{{ m_mediawiki }}"
38+
dest: "{{ m_htdocs }}/{{ wiki_id }}"
39+
state: link
40+
force: yes
41+
owner: "{{ user_apache }}"
42+
group: "{{ group_apache }}"
43+
3344
# Wikis are totally built at this point, but search needs rebuilding?
3445
# Pretty sure this is taken care of in the MedidaWiki role.
3546
- name: (Re-)build search index for each wiki

src/roles/mediawiki/tasks/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,10 @@
513513
msg: "{{ item }}"
514514
loop: "{{ list_of_wikis|flatten(levels=1) }}"
515515

516-
# create symlink to core for short urls
517-
# tag it latest, so that the symlink gets created whenever core is downloaded
516+
# Create symlink to core for short urls
517+
# Tag it latest, so that the symlink gets created whenever core is downloaded
518+
# This essential task is duplicated in the create-wiki-wrapper role for individual
519+
# wiki creation outside of full deploys.
518520
- name: Create symlink to core, to enable short urls
519521
file:
520522
src: "{{ m_mediawiki }}"

src/roles/verify-wiki/tasks/create-admin-account.yml

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,7 @@
22

33
# Renamed the file to create-admin-account.yml since that is its only purpose.
44
# 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
256

267
# Validate password meets MediaWiki requirements
278
- name: Validate Admin password meets requirements
@@ -31,23 +12,20 @@
3112
- Must be at least 8 characters long
3213
- Must contain uppercase, lowercase, number, and special character
3314
- 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
4322
run_once: true
4423

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
4625
# https://www.mediawiki.org/wiki/Manual:CreateAndPromote.php
4726
# https://meta.wikimedia.org/wiki/Password_policy
48-
- name: Create Admin user on Demo Wiki
27+
- name: Create Admin user on new wiki
4928
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 }}
5130
run_once: true
52-
when: wiki_id == "demo"
5331
no_log: true

src/roles/verify-wiki/tasks/import-wiki-sql.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,22 @@
7474
#
7575
# Set fact if new wiki was created
7676
#
77-
- name: SET FACT - New wiki was created
77+
- name: SET FACT - New wiki was created (truly new, not from backup)
7878
set_fact:
7979
created_new_wiki: true
8080
when: (not wiki_exists) and (not imported_wiki_sql_on_db_master.stat.exists)
81-
- name: SET FACT - New wiki NOT created
81+
82+
- name: SET FACT - Wiki created but from backup/import
8283
set_fact:
8384
created_new_wiki: false
84-
# not a "new" wiki if one already existed _or_ an imported SQL file was used
85-
when: (wiki_exists) or (imported_wiki_sql_on_db_master.stat.exists)
85+
created_from_backup: true
86+
when: (not wiki_exists) and (imported_wiki_sql_on_db_master.stat.exists)
87+
88+
- name: SET FACT - Wiki already existed
89+
set_fact:
90+
created_new_wiki: false
91+
created_from_backup: false
92+
when: wiki_exists
8693

8794
#
8895
# Do rebuild scripts (SMW and search index) need to run?
@@ -119,6 +126,16 @@
119126
#
120127
# SECTION: init new wiki
121128
#
129+
- name: Debug wiki creation status
130+
debug:
131+
msg: |
132+
Wiki creation status for {{ wiki_id }}:
133+
- wiki_exists: {{ wiki_exists | default('undefined') }}
134+
- imported_wiki_sql_on_db_master.stat.exists: {{ imported_wiki_sql_on_db_master.stat.exists | default('undefined') }}
135+
- created_new_wiki: {{ created_new_wiki | default('undefined') }}
136+
- created_from_backup: {{ created_from_backup | default('undefined') }}
137+
- Will create admin account: {{ created_new_wiki | default(false) }}
138+
122139
- name: "Include create-admin-account.yml for a new (not imported) wiki - {{ wiki_id }}"
123140
include_tasks: create-admin-account.yml
124141
when: created_new_wiki

0 commit comments

Comments
 (0)