Merge branch 'master' of adellam/ansible-roles into master

This commit is contained in:
Andrea Dell'Amico 2019-10-13 15:37:09 +02:00 committed by Gitea
commit 0291d27743
5 changed files with 47 additions and 0 deletions

View File

@ -18,19 +18,31 @@ mw_db_table_prefix: 'mw_'
mw_local_nginx_virtualhost: '{{ mw_local_nginx }}'
mw_context: wiki
mw_doc_root: '{{ mw_install_dir }}/{{ mw_context }}'
mw_wiki_servername: '{{ ansible_fqdn }}'
mw_wiki_name: 'Mediawiki Installation'
mw_upload_subdirs:
- archive
- thumb
- temp
mw_local_mysql: True
mw_local_nginx: True
mw_local_memcached: True
mw_memcached_hosts: '"127.0.0.1:11211"'
mw_db_name: mediawiki
mw_db_user: mediawiki_u
# mw_db_pwd: 'use a vault file'
mw_system_user: mwiki
# mw_admin_pwd: 'use a vault file'
# mw_secret_key: 'use a vault file'
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_id: 'wiki'
mw_uri: '/wiki'
mw_http_port: 80
mw_https_port: 443
@ -47,6 +59,10 @@ mw_php_additional_packages:
- 'php{{ php_version }}-cli'
- 'php{{ php_version }}-zip'
- 'php{{ php_version }}-curl'
- php-apcu
- php-wikidiff2
- imagemagick
- php-imagick
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_context }}' }

View File

@ -2,4 +2,5 @@
dependencies:
- { role: '../../library/roles/mysql', when: mw_local_mysql | bool }
- role: '../../library/roles/php-fpm'
- { role: '../../library/roles/memcached', when: mw_local_memcached | bool }
- { role: '../../library/roles/nginx', when: mw_local_nginx | bool }

View File

@ -27,6 +27,11 @@
when: mw_install_from_tar
tags: mediawiki
- name: Create the images subdirs
file: dest={{ mw_doc_root }}/images/{{ item }} state=directory
with_items: '{{ mw_upload_subdirs }}'
tags: mediawiki
- name: Set the correct ownership of the mediawiki files
file: dest={{ mw_doc_root }} owner={{ item.user }} group={{ item.group }} recurse=yes state=directory
with_items: '{{ phpfpm_pools }}'
@ -35,3 +40,26 @@
- name: Create the mediawiki conf dir
file: path={{ mw_conf_dir }} state=directory
tags: mediawiki
- block:
- name: Check if the mediawiki instance has been initialized already
stat: path={{ mw_doc_root }}/.mwinitialized
register: mw_init
tags: [ 'mediawiki', 'mediawiki_init' ]
- block:
- name: Create a file with the DB password
copy: src=mw_db_passwd.j2 dest=/tmp/mw_db_passwd owner=root group=root mode=0400
- name: Create a file with the admin password
copy: src=mw_admin_passwd.j2 dest=/tmp/mw_admin_passwd owner=root group=root mode=0400
- name: Initialize the mediawiki instance
shell: cd {{ mw_doc_root }} ; php maintenance/install.php --confpath {{ mw_conf_dir }} --dbname {{ mw_db_name }} --dbprefix {{ mw_db_table_prefix }} --dbuser {{ mw_db_user }} --dbpassfile /tmp/mw_db_passwd --with-extensions --scriptpath {{ mw_uri }} --passfile /tmp/mw_admin_passwd --wiki {{ mw_id }} --dbserver {{ mw_db_host }} --dbtype mysql --server https://{{ mw_wiki_servername }} "{{ mw_wiki_name }}" {{ mw_system_user }} && touch {{ mw_doc_root }}/.mwinitialized ; rm -f /tmp/mw_db_passwd /tmp/mw_admin_passwd
args:
creates: '{{ mw_doc_root }}/.mwinitialized'
when: mw_init.stat.exists is defined and not mw_init.stat.exists
tags: [ 'mediawiki', 'mediawiki_init' ]

View File

@ -0,0 +1 @@
{{ mw_admin_pwd }}

View File

@ -0,0 +1 @@
{{ mw_db_pwd }}