From 1ee45a1c546e9c942a67e80dbf617b427d2f73a9 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 9 Oct 2019 16:11:17 +0200 Subject: [PATCH] Some changes to the mediawiki role, now with explicit dependencies. --- library/roles/mediawiki/defaults/main.yml | 57 +++++++++++++++++------ library/roles/mediawiki/meta/main.yml | 5 ++ library/roles/mediawiki/tasks/main.yml | 11 ++--- library/roles/mediawiki/vars/main.yml | 14 ++++++ 4 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 library/roles/mediawiki/meta/main.yml create mode 100644 library/roles/mediawiki/vars/main.yml diff --git a/library/roles/mediawiki/defaults/main.yml b/library/roles/mediawiki/defaults/main.yml index d34ff6bb..7296cf22 100644 --- a/library/roles/mediawiki/defaults/main.yml +++ b/library/roles/mediawiki/defaults/main.yml @@ -1,27 +1,54 @@ --- # -# This playbook depends on the php-fpm, mysql role and nginx or apache2 +# This playbook depends on the php-fpm, mysql role and nginx # mw_install_from_package: False -# We have some cases when we only want to install the dependencies and prepare the environment +# Distribution packages are always obsolete mw_install_from_tar: True -mw_version: 1.25 -mw_minor_minor: 1 +mw_version: 1.33 +mw_minor_minor: 0 mw_download_url: http://releases.wikimedia.org/mediawiki/{{ mw_version }}/mediawiki-{{ mw_version }}.{{ mw_minor_minor }}.tar.gz mw_download_dir: /srv/mediawiki -mw_install_dir: /var/www +mw_install_dir: /var/www/html mw_conf_dir: /etc/mediawiki +mw_servername: '{{ ansible_fqdn }}' +mw_db_host: localhost +mw_db_table_prefix: 'mw_' -mw_php_prereq: - - php5-intl - - php5-cli - - php5-mysqlnd - - php-apc - - php-pear - - php5-ldap - - imagemagick - - spawn-fcgi - - fcgiwrap +mw_local_nginx_virtualhost: '{{ mw_local_nginx }}' +mw_doc_root: '{{ mw_install_dir }}/wiki' + + +mw_local_mysql: True +mw_local_nginx: True + +mw_db_name: mediawiki +mw_db_user: mediawiki_u +# mw_db_pwd: 'use a vault file' +mw_system_user: mwiki + +mw_mysql_db_data: + - { name: '{{ mw_db_name }}', user: '{{ mw_db_user }}', pwd: '{{ mw_db_pwd }}', collation: '{{ mysql_default_collation }}', encoding: '{{ mysql_default_encoding }}', user_grant: 'ALL', allowed_hosts: [ '{{ ansible_fqdn }}/32', '127.0.0.1/8', 'localhost' ] } + +mw_http_port: 80 +mw_https_port: 443 + +mw_php_version: 7.2 + +mw_php_additional_packages: + - 'php{{ php_version }}-mbstring' + - 'php{{ php_version }}-xmlrpc' + - 'php{{ php_version }}-soap' + - 'php{{ php_version }}-gd' + - 'php{{ php_version }}-xml' + - 'php{{ php_version }}-intl' + - 'php{{ php_version }}-mysql' + - 'php{{ php_version }}-cli' + - 'php{{ php_version }}-zip' + - 'php{{ php_version }}-curl' + +mw_phpfpm_pools: + - { pool_name: '{{ phpfpm_default_pool_name }}', app_context: '{{ phpfpm_default_context }}', user: '{{ phpfpm_default_user }}', group: '{{ phpfpm_default_group }}', listen: '{{ phpfpm_default_listen }}', allowed_clients: '{{ phpfpm_default_allowed_clients }}', pm: '{{ phpfpm_default_pm }}', pm_max_children: '{{ phpfpm_default_pm_max_children }}', pm_start_servers: '{{ phpfpm_default_pm_start_servers }}', pm_min_spare: '{{ phpfpm_default_pm_min_spare_servers }}', pm_max_spare: '{{ phpfpm_default_pm_max_spare_servers }}', pm_max_requests: '{{ phpfpm_default_pm_max_requests }}', pm_status_enabled: '{{ phpfpm_default_pm_status_enabled }}', pm_status_path: '{{ phpfpm_default_pm_status_path }}', ping_enabled: '{{ phpfpm_default_ping_enabled }}', ping_path: '{{ phpfpm_default_ping_path }}', ping_response: '{{ phpfpm_default_ping_response }}', display_errors: '{{ phpfpm_default_display_errors }}', log_errors: '{{ phpfpm_default_log_errors }}', memory_limit: '{{ phpfpm_default_memory_limit }}', slowlog_timeout: '{{ phpfpm_default_slowlog_timeout }}', rlimit_files: '{{ phpfpm_default_rlimit_files }}', php_extensions: '{{ phpfpm_default_extensions }}', define_custom_variables: '{{ phpfpm_default_define_custom_variables }}', admin_write: True, doc_root: '{{ mw_doc_root }}', virthost: '{{ mw_servername }}' } # This choice is not recommended. The package has a poor list of dependencies. We do not want to deal with those mw_package: diff --git a/library/roles/mediawiki/meta/main.yml b/library/roles/mediawiki/meta/main.yml new file mode 100644 index 00000000..e1248c61 --- /dev/null +++ b/library/roles/mediawiki/meta/main.yml @@ -0,0 +1,5 @@ +--- +dependencies: + - { role: '../../library/roles/mysql', when: mw_local_mysql | bool } + - role: '../../library/roles/php-fpm' + - { role: '../../library/roles/nginx', when: mw_local_nginx | bool } diff --git a/library/roles/mediawiki/tasks/main.yml b/library/roles/mediawiki/tasks/main.yml index 5584f212..c385ac39 100644 --- a/library/roles/mediawiki/tasks/main.yml +++ b/library/roles/mediawiki/tasks/main.yml @@ -1,9 +1,4 @@ --- -- name: Install the php prerequisites - apt: name={{ item }} state=present - with_items: '{{ mw_php_prereq }}' - tags: mediawiki - - name: Ensure that the download and install dirs exist file: path={{ item }} state=directory with_items: @@ -26,15 +21,15 @@ tags: mediawiki - name: Move the mediawiki files to the right place - command: cp -a {{ mw_download_dir }}/mediawiki-{{ mw_version }}.{{ mw_minor_minor }} {{ mw_install_dir }}/{{ item.virthost }} + command: cp -a {{ mw_download_dir }}/mediawiki-{{ mw_version }}.{{ mw_minor_minor }} {{ mw_doc_root }} args: - creates: '{{ mw_install_dir }}/{{ item.virthost }}/index.php' + creates: '{{ mw_doc_root }}/index.php' with_items: '{{ phpfpm_pools }}' when: mw_install_from_tar tags: mediawiki - name: Set the correct ownership of the mediawiki files - file: dest={{ mw_install_dir }}/{{ item.virthost }} owner={{ item.user }} group={{ item.group }} recurse=yes state=directory + file: dest={{ mw_doc_root }} owner={{ item.user }} group={{ item.group }} recurse=yes state=directory with_items: '{{ phpfpm_pools }}' tags: mediawiki diff --git a/library/roles/mediawiki/vars/main.yml b/library/roles/mediawiki/vars/main.yml new file mode 100644 index 00000000..0c9fd813 --- /dev/null +++ b/library/roles/mediawiki/vars/main.yml @@ -0,0 +1,14 @@ +--- +http_port: '{{ mw_http_port }}' +https_port: '{{ mw_https_port }}' + +php_version: '{{ mw_php_version }}' + +php_additional_packages: '{{ mw_php_additional_packages }}' + +mysql_db_data: '{{ mw_mysql_db_data }}' + +phpfpm_default_pool_name: '{{ mw_system_user }}' +phpfpm_default_user: '{{ mw_system_user }}' + +phpfpm_pools: '{{ mw_phpfpm_pools }}'