From 7252761b8f9cc7b3a8a043e9525b46b0bc81adf6 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 28 Jan 2020 07:35:33 -0500 Subject: [PATCH 1/4] Variable Validation: improved error messages --- roles/0-init/tasks/validate_vars.yml | 19 +++++++------------ roles/captiveportal/tasks/main.yml | 2 +- roles/munin/tasks/main.yml | 2 +- roles/osm-vector-maps/tasks/main.yml | 2 +- roles/wordpress/tasks/main.yml | 2 +- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/roles/0-init/tasks/validate_vars.yml b/roles/0-init/tasks/validate_vars.yml index 206d3502d..d79ef73c2 100644 --- a/roles/0-init/tasks/validate_vars.yml +++ b/roles/0-init/tasks/validate_vars.yml @@ -41,6 +41,7 @@ # Should we remove {xo_services, activity_server, ejabberd_xs, idmgr} as these # are officially now UNMAINTAINED in default_vars.yml and # https://github.com/iiab/iiab/blob/master/unmaintained-roles.txt etc? + - name: Set vars_checklist for 53 + 53 + up-to-53 vars ("XYZ_install" + "XYZ_enabled" + "XYZ_installed") to be checked set_fact: vars_checklist: @@ -101,47 +102,41 @@ - name: Assert that {{ vars_checklist | length }} "XYZ_install" vars are all... defined assert: that: "{{ item }}_install is defined" - fail_msg: "PLEASE GIVE THIS VARIABLE A PROPER (UNQUOTED) BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" + fail_msg: "VARIABLE MUST BE DEFINED: '{{ item }}_install' NEEDS A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" quiet: yes loop: "{{ vars_checklist }}" - #register: install_vars_defined - name: Assert that {{ vars_checklist | length }} "XYZ_enabled" vars are all... defined assert: that: "{{ item }}_enabled is defined" - fail_msg: "PLEASE GIVE THIS VARIABLE A PROPER (UNQUOTED) BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" + fail_msg: "VARIABLE MUST BE DEFINED: '{{ item }}_enabled' NEEDS A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" quiet: yes loop: "{{ vars_checklist }}" - #register: enabled_vars_defined - name: Assert that {{ vars_checklist | length }} "XYZ_install" vars are all... type boolean (NOT type string, which can invert logic!) assert: that: "{{ item }}_install | type_debug == 'bool'" - fail_msg: "PLEASE GIVE THIS VARIABLE A PROPER (UNQUOTED) BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" + fail_msg: "VARIABLE MUST BE BOOLEAN: '{{ item }}_install' now has type '{{ lookup('vars', item + '_install') | type_debug }}' and value '{{ lookup('vars', item + '_install') }}' -- PLEASE SET A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" quiet: yes loop: "{{ vars_checklist }}" - #register: install_vars_boolean - name: Assert that {{ vars_checklist | length }} "XYZ_enabled" vars are all... type boolean (NOT type string, which can invert logic!) assert: that: "{{ item }}_enabled | type_debug == 'bool'" - fail_msg: "PLEASE GIVE THIS VARIABLE A PROPER (UNQUOTED) BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" + fail_msg: "VARIABLE MUST BE BOOLEAN: '{{ item }}_enabled' now has type '{{ lookup('vars', item + '_enabled') | type_debug }}' and value '{{ lookup('vars', item + '_enabled') }}' -- PLEASE SET A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" quiet: yes loop: "{{ vars_checklist }}" - #register: enabled_vars_boolean - name: 'DISALLOW "XYZ_install: False" WITH "XYZ_enabled: True" ...for all {{ vars_checklist | length }} var pairs' assert: that: "{{ item }}_install or not {{ item }}_enabled" - fail_msg: "IIAB DOES NOT SUPPORT UNINSTALLS. PLEASE VERIFY {{ item }}_install AND {{ item }}_enabled e.g. IN: /etc/iiab/local_vars.yml" - #fail_msg: '{{ item }}_install or not {{ item }}_enabled {{ item }}_install is {{ {{ item }}_install }} {{ item }}_enabled is {{ {{ item }}_enabled }}' # Is there a way to output var values ? + fail_msg: "DISALLOWED: '{{ item }}_install: False' WITH '{{ item }}_enabled: True' -- IIAB DOES NOT SUPPORT UNINSTALLS -- please verify those 2 variable values e.g. in /etc/iiab/local_vars.yml, and other places variables are defined?" quiet: yes loop: "{{ vars_checklist }}" - #register: var_pairs_validation - name: 'DISALLOW "XYZ_install: False" WHEN "XYZ_installed is defined" IN /etc/iiab/iiab_state.yml ...for up-to-{{ vars_checklist | length }} var pairs' assert: that: "{{ item }}_install or {{ item }}_installed is undefined" - fail_msg: "{{ item }} ALREADY INSTALLED. IIAB DOES NOT SUPPORT UNINSTALLS. PLEASE SET '{{ item }}_install: True' e.g. IN: /etc/iiab/local_vars.yml" + fail_msg: "DISALLOWED: '{{ item }}_install: False' (e.g. in /etc/iiab/local_vars.yml) WHEN '{{ item }}_installed' is defined (e.g. in /etc/iiab/iiab_state.yml) -- IIAB DOES NOT SUPPORT UNINSTALLS -- please verify those 2 files especially, and other places variables are defined?" quiet: yes loop: "{{ vars_checklist }}" diff --git a/roles/captiveportal/tasks/main.yml b/roles/captiveportal/tasks/main.yml index 959cc0268..fffd70134 100644 --- a/roles/captiveportal/tasks/main.yml +++ b/roles/captiveportal/tasks/main.yml @@ -15,7 +15,7 @@ - name: Assert that "captiveportal_enabled | type_debug == 'bool'" (boolean not string etc) assert: that: captiveportal_enabled | type_debug == 'bool' - fail_msg: "PLEASE GIVE VARIABLE 'captiveportal_enabled' A PROPER (UNQUOTED) BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" + fail_msg: "PLEASE GIVE VARIABLE 'captiveportal_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" quiet: yes diff --git a/roles/munin/tasks/main.yml b/roles/munin/tasks/main.yml index dca8a244b..5128de298 100644 --- a/roles/munin/tasks/main.yml +++ b/roles/munin/tasks/main.yml @@ -15,7 +15,7 @@ - name: Assert that "munin_enabled | type_debug == 'bool'" (boolean not string etc) assert: that: munin_enabled | type_debug == 'bool' - fail_msg: "PLEASE GIVE VARIABLE 'munin_enabled' A PROPER (UNQUOTED) BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" + fail_msg: "PLEASE GIVE VARIABLE 'munin_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" quiet: yes diff --git a/roles/osm-vector-maps/tasks/main.yml b/roles/osm-vector-maps/tasks/main.yml index e0b81ce39..3bdfbee25 100644 --- a/roles/osm-vector-maps/tasks/main.yml +++ b/roles/osm-vector-maps/tasks/main.yml @@ -15,7 +15,7 @@ - name: Assert that "osm_vector_maps_enabled | type_debug == 'bool'" (boolean not string etc) assert: that: osm_vector_maps_enabled | type_debug == 'bool' - fail_msg: "PLEASE GIVE VARIABLE 'osm_vector_maps_enabled' A PROPER (UNQUOTED) BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" + fail_msg: "PLEASE GIVE VARIABLE 'osm_vector_maps_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" quiet: yes diff --git a/roles/wordpress/tasks/main.yml b/roles/wordpress/tasks/main.yml index 7bca5e7d8..0e4986ed1 100644 --- a/roles/wordpress/tasks/main.yml +++ b/roles/wordpress/tasks/main.yml @@ -17,7 +17,7 @@ - name: Assert that "wordpress_enabled | type_debug == 'bool'" (boolean not string etc) assert: that: wordpress_enabled | type_debug == 'bool' - fail_msg: "PLEASE GIVE VARIABLE 'wordpress_enabled' A PROPER (UNQUOTED) BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" + fail_msg: "PLEASE GIVE VARIABLE 'wordpress_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml" quiet: yes From 90a0769ce5d172fb51eee9c0338cfc08d242de26 Mon Sep 17 00:00:00 2001 From: Tim Moody Date: Tue, 28 Jan 2020 17:13:02 -0500 Subject: [PATCH 2/4] Mitra's tweaks to mediawiki install --- roles/mediawiki/defaults/main.yml | 1 + roles/mediawiki/tasks/install.yml | 8 +++---- .../templates/mediawiki-nginx.conf.j2 | 22 +++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/roles/mediawiki/defaults/main.yml b/roles/mediawiki/defaults/main.yml index 072f10789..f650561f4 100644 --- a/roles/mediawiki/defaults/main.yml +++ b/roles/mediawiki/defaults/main.yml @@ -29,3 +29,4 @@ mediawiki_abs_path: "{{ mediawiki_install_path }}/mediawiki-{{ mediawiki_version mediawiki_url: /wiki mediawiki_url2: /mediawiki mediawiki_full_url: "http://{{ iiab_hostname }}.{{ iiab_domain }}{{ mediawiki_url }}" # http://box.lan/wiki +mediawiki_symlink: w # can also be mwlink. NO slashes as they are suppplied as needed in the code diff --git a/roles/mediawiki/tasks/install.yml b/roles/mediawiki/tasks/install.yml index 6d38cc4b6..e4c61fcb3 100644 --- a/roles/mediawiki/tasks/install.yml +++ b/roles/mediawiki/tasks/install.yml @@ -18,15 +18,15 @@ unarchive: src: "{{ downloads_dir }}/{{ mediawiki_src }}" dest: "{{ mediawiki_install_path }}" - owner: root + owner: "{{ apache_user }}" group: "{{ apache_user }}" mode: u+rw,g+r,o+r # '0755' forced executable bits on files keep_newer: yes -- name: Create symlink {{ doc_root }}/mwlink -> {{ mediawiki_abs_path }} +- name: Create symlink {{ doc_root }}/{{ mediawiki_symlink }} -> {{ mediawiki_abs_path }} file: src: "{{ mediawiki_abs_path }}" - path: "{{ doc_root }}/mwlink" + path: "{{ doc_root }}/{{ mediawiki_symlink }}" state: link - name: Start MySQL systemd service ({{ mysql_service }}) so we can create db @@ -55,7 +55,7 @@ --installdbpass={{ mediawiki_db_user_password }} --dbuser={{ mediawiki_db_user }} --dbpass={{ mediawiki_db_user_password }} - --scriptpath=/mwlink + --scriptpath=/{{ mediawiki_symlink }} --lang=en --pass={{ mediawiki_admin_user_password }} "{{ mediawiki_site_name }}" diff --git a/roles/mediawiki/templates/mediawiki-nginx.conf.j2 b/roles/mediawiki/templates/mediawiki-nginx.conf.j2 index 26cee7900..fdb19dba2 100644 --- a/roles/mediawiki/templates/mediawiki-nginx.conf.j2 +++ b/roles/mediawiki/templates/mediawiki-nginx.conf.j2 @@ -1,31 +1,31 @@ -# this works if (docroot)/mwlink links to install +# this works if (docroot)/{{ mediawiki_symlink }} links to install # and LocalSettings.php has -# $wgScriptPath = "/mwlink"; +# $wgScriptPath = "/{{ mediawiki_symlink }}"; # $wgArticlePath = "/wiki/$1"; # $wgUsePathInfo = true; -location ~ ^/mwlink/(index|load|api|thumb|opensearch_desc)\.php$ { +location ~ ^/{{ mediawiki_symlink }}/(index|load|api|thumb|opensearch_desc)\.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php; # or whatever port your PHP-FPM listens on } - + # Images -location /mwlink/images { +location /{{ mediawiki_symlink }}/images { # Separate location for images/ so .php execution won't apply } -location /mwlink/images/deleted { +location /{{ mediawiki_symlink }}/images/deleted { # Deny access to deleted images folder deny all; } # MediaWiki assets (usually images) -location ~ ^/mwlink/resources/(assets|lib|src) { +location ~ ^/{{ mediawiki_symlink }}/resources/(assets|lib|src) { try_files $uri 404; add_header Cache-Control "public"; expires 7d; } # Assets, scripts and styles from skins and extensions -location ~ ^/mwlink/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg)$ { +location ~ ^/{{ mediawiki_symlink }}/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg|ttf|woff|woff2)$ { try_files $uri 404; add_header Cache-Control "public"; expires 7d; @@ -34,18 +34,18 @@ location ~ ^/mwlink/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg)$ { ## Uncomment the following code if you wish to use the installer/updater ## installer/updater -#location /mwlink/mw-config/ { +#location /{{ mediawiki_symlink }}/mw-config/ { # # Do this inside of a location so it can be negated # location ~ \.php$ { # include /etc/nginx/fastcgi_params; -# fastcgi_param SCRIPT_FILENAME $document_root/mwlink/mw-config/$fastcgi_script_name; +# fastcgi_param SCRIPT_FILENAME $document_root/{{ mediawiki_symlink }}/mw-config/$fastcgi_script_name; # fastcgi_pass 127.0.0.1:9000; # or whatever port your PHP-FPM listens on # } #} # Handling for the article path (pretty URLs) location {{ mediawiki_url }}/ { - rewrite ^{{ mediawiki_url }}/(?.*)$ /mwlink/index.php; + rewrite ^{{ mediawiki_url }}/(?.*)$ /{{ mediawiki_symlink }}/index.php; } # Explicit access to the root website, redirect to main page (adapt as needed) From 88ae1bd25b34413a232dad92c1a3cf85a2718748 Mon Sep 17 00:00:00 2001 From: A Holt Date: Tue, 28 Jan 2020 22:55:11 -0500 Subject: [PATCH 3/4] Lokole 0.5.7 -> 0.5.8 --- roles/lokole/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/lokole/defaults/main.yml b/roles/lokole/defaults/main.yml index f28e8ea2d..cefc9cfe3 100644 --- a/roles/lokole/defaults/main.yml +++ b/roles/lokole/defaults/main.yml @@ -5,7 +5,7 @@ # If nec, change them by editing /etc/iiab/local_vars.yml prior to installing! # Info needed to install Lokole -lokole_version: 0.5.7 +lokole_version: 0.5.8 lokole_admin_user: admin # lowercase seems nec here (even though uppercase Admin/changeme is IIAB's OOB recommendation!) lokole_admin_password: changeme lokole_install_path: "{{ content_base }}/lokole" # /library/lokole From 3ba89dce44a9c6ce4b357a4e896862b21eab7a62 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 29 Jan 2020 08:11:01 -0500 Subject: [PATCH 4/4] Lokole 0.5.8 -> 0.5.9 --- roles/lokole/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/lokole/defaults/main.yml b/roles/lokole/defaults/main.yml index cefc9cfe3..461221572 100644 --- a/roles/lokole/defaults/main.yml +++ b/roles/lokole/defaults/main.yml @@ -5,7 +5,7 @@ # If nec, change them by editing /etc/iiab/local_vars.yml prior to installing! # Info needed to install Lokole -lokole_version: 0.5.8 +lokole_version: 0.5.9 lokole_admin_user: admin # lowercase seems nec here (even though uppercase Admin/changeme is IIAB's OOB recommendation!) lokole_admin_password: changeme lokole_install_path: "{{ content_base }}/lokole" # /library/lokole