aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/mediawiki/tasks
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-11-05 23:18:54 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2018-11-05 23:18:54 +0100
commitc25c490677bcba2c2e9fee90db10594bd43f6982 (patch)
tree23bde01f60bf0e4421f680bcd9912b5a12f5b42d /ansible/roles/mediawiki/tasks
parentb5b7e21c8ba3c68eab9cd244602f27c21aa5f36b (diff)
downloadinfra-c25c490677bcba2c2e9fee90db10594bd43f6982.tar.gz
infra-c25c490677bcba2c2e9fee90db10594bd43f6982.tar.bz2
infra-c25c490677bcba2c2e9fee90db10594bd43f6982.tar.xz
infra-c25c490677bcba2c2e9fee90db10594bd43f6982.zip
Importing Bitraf's mediawiki
o Some improvements, reusing old backup scripts.
Diffstat (limited to 'ansible/roles/mediawiki/tasks')
-rw-r--r--ansible/roles/mediawiki/tasks/main.yml177
1 files changed, 177 insertions, 0 deletions
diff --git a/ansible/roles/mediawiki/tasks/main.yml b/ansible/roles/mediawiki/tasks/main.yml
new file mode 100644
index 0000000..6d1850b
--- /dev/null
+++ b/ansible/roles/mediawiki/tasks/main.yml
@@ -0,0 +1,177 @@
+- become: yes
+ tags:
+ - mediawiki
+ - mediawiki-packages
+ block:
+ - name: packages
+ vars:
+ items:
+ - composer
+ - php-apcu
+ - php-gd
+ - php-intl
+ - php-mbstring
+ - php-pgsql
+ - php-xml
+ - php-zip
+ apt:
+ name: "{{ items }}"
+ install_recommends: no
+
+- become: yes
+ tags:
+ - mediawiki
+ - mediawiki-php
+ block:
+ - name: increase maximum file size (for uploads) to 20M
+ notify: service restart php-fpm
+ ini_file:
+ path: /etc/php/7.0/fpm/php.ini
+ section: PHP
+ option: "{{ item.option }}"
+ value: "{{ item.value }}"
+ with_items:
+ - option: upload_max_filesize
+ value: 20M
+ - option: post_max_size
+ value: 20M
+
+- become: yes
+ tags:
+ - mediawiki
+ - mediawiki-clone
+ block:
+ - name: mkdir /opt/mediawiki
+ file:
+ path: /opt/mediawiki
+ state: directory
+
+ - name: mkdir /opt/mediawiki/mediawiki
+ file:
+ path: /opt/mediawiki/mediawiki
+ state: directory
+ owner: www-data
+
+ - name: git clone
+ become: yes
+ become_user: www-data
+ vars:
+ ansible_ssh_pipelining: true
+ git:
+ repo: https://github.com/bitraf/mediawiki
+ dest: /opt/mediawiki/mediawiki
+ version: "{{ mediawiki__version }}"
+ update: "{{ 'yes' if mediawiki__force_update else 'no' }}"
+ force: "{{ 'yes' if mediawiki__force_update else 'no' }}"
+
+- become: yes
+ tags:
+ - mediawiki
+ - mediawiki-composer
+ block:
+ - name: mkdirs
+ with_items:
+ - /var/www/.ansible
+ - /var/www/.composer
+ file:
+ path: "{{ item }}"
+ state: directory
+ group: www-data
+ owner: www-data
+
+ - name: Create composer.local.json
+ when: mediawiki__composer_require is defined
+ vars:
+ content: |
+ {{ '{ "require": {' }}
+ {% for k, v in mediawiki__composer_require.items() %}
+ "{{ k }}": "{{ v }}"{% if not loop.last %},{% endif %}
+ {% endfor %}
+ {{ '} }' }}
+ copy:
+ dest: /opt/mediawiki/mediawiki/composer.local.json
+ content: "{{ content | to_nice_json }}"
+
+ - name: run composer
+ become: yes
+ become_user: www-data
+ vars:
+ ansible_ssh_pipelining: true
+ composer:
+ command: update
+ working_dir: /opt/mediawiki/mediawiki
+
+- name: "Extensions"
+ become: yes
+ tags:
+ - mediawiki
+ - mediawiki-extensions
+ with_items: "{{ mediawiki__extensions }}"
+ git:
+ repo: "{{ item.repo }}"
+ dest: "/opt/mediawiki/mediawiki/extensions/{{ item.dest }}"
+ version: "{{ item.version }}"
+
+- become: yes
+ tags:
+ - mediawiki
+ - mediawiki-backup
+ block:
+ # TODO: install systemd timer and service to run these
+ - name: mkdir
+ file:
+ state: directory
+ path: "/opt/mediawiki/backup"
+ - copy:
+ src: "{{ item }}"
+ dest: "/{{ item }}"
+ mode: a+rx
+ with_items:
+ - bin/mw-dump-backup
+ - bin/mw-dump-db
+
+- become: yes
+ tags:
+ - mediawiki
+ - mediawiki-config
+ block:
+ - file:
+ path: /etc/mediawiki
+ state: directory
+ - file:
+ dest: /opt/mediawiki/mediawiki/LocalSettings.php
+ src: /etc/mediawiki/LocalSettings.php
+ state: link
+ force: yes
+
+ - name: mediawiki systemd timer
+ notify: systemd daemon-reload
+ copy:
+ src: "systemd/{{ item }}"
+ dest: "/etc/systemd/system/{{ item }}"
+ with_items:
+ - mediawiki-jobqueue.service
+ - mediawiki-jobqueue.timer
+
+- meta: flush_handlers
+
+- become: yes
+ tags:
+ - mediawiki
+ - mediawiki-config
+ block:
+ - systemd:
+ enabled: true
+ state: started
+ name: mediawiki-jobqueue.timer
+
+- become: yes
+ tags:
+ - mediawiki
+ - mediawiki-config
+ - update-password
+ block:
+ - name: LocalSettings.php
+ template:
+ dest: /etc/mediawiki
+ src: "{{ mediawiki__local_settings }}"