From c25c490677bcba2c2e9fee90db10594bd43f6982 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 5 Nov 2018 23:18:54 +0100 Subject: Importing Bitraf's mediawiki o Some improvements, reusing old backup scripts. --- ansible/roles/mediawiki/tasks/main.yml | 177 +++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 ansible/roles/mediawiki/tasks/main.yml (limited to 'ansible/roles/mediawiki/tasks') 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 }}" -- cgit v1.2.3