From 0a6da2506c38681f7138f3787c6f0dd20696ad0d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 23 Sep 2018 01:10:23 +0200 Subject: o Adding back mw-backend role for mw.yml. o Adding backup scripts for mediawiki. o Fixing broken Debian logo. o Adding .pdf as valid file updload type. --- ansible/mw.yml | 4 +++ ansible/roles/mw-backend/files/bin/mw-dump-backup | 9 ++++++ ansible/roles/mw-backend/files/bin/mw-dump-db | 11 +++++++ ansible/roles/mw-backend/files/bin/mw-make-backup | 5 +++ ansible/roles/mw-backend/tasks/main.yml | 37 ++++++++++++++++++++-- .../templates/etc/mediawiki/LocalSettings.php.j2 | 7 ++-- 6 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 ansible/roles/mw-backend/files/bin/mw-dump-backup create mode 100644 ansible/roles/mw-backend/files/bin/mw-dump-db create mode 100644 ansible/roles/mw-backend/files/bin/mw-make-backup (limited to 'ansible') diff --git a/ansible/mw.yml b/ansible/mw.yml index d4d6c1a..211678f 100644 --- a/ansible/mw.yml +++ b/ansible/mw.yml @@ -13,3 +13,7 @@ - name: lxc-machine import_role: name=lxc-machine tags: lxc-machine + + - name: mw-backend + import_role: name=mw-backend + tags: mw-backend diff --git a/ansible/roles/mw-backend/files/bin/mw-dump-backup b/ansible/roles/mw-backend/files/bin/mw-dump-backup new file mode 100644 index 0000000..5530b03 --- /dev/null +++ b/ansible/roles/mw-backend/files/bin/mw-dump-backup @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euo pipefail + +exec php /usr/share/mediawiki/maintenance/dumpBackup.php \ + --full \ + --include-files \ + --uploads \ + > /mediawiki-backup/content-dump.xml diff --git a/ansible/roles/mw-backend/files/bin/mw-dump-db b/ansible/roles/mw-backend/files/bin/mw-dump-db new file mode 100644 index 0000000..0a82059 --- /dev/null +++ b/ansible/roles/mw-backend/files/bin/mw-dump-db @@ -0,0 +1,11 @@ +#!/bin/bash + +set -euo pipefail + +export PGHOST=$(sed -n 's,^.wgDBserver.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) +export PGUDATABASE=$(sed -n 's,^.wgDBname.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) +export PGUSER=$(sed -n 's,^.wgDBuser.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) +export PGPASSWORD=$(sed -n 's,^.wgDBpassword.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) +export PGPORT=$(sed -n 's,^.wgDBport.*"\([^"]*\)".*,\1,p' /etc/mediawiki/LocalSettings.php) + +exec pg_dump -b --format directory -f /mediawiki-backup/db diff --git a/ansible/roles/mw-backend/files/bin/mw-make-backup b/ansible/roles/mw-backend/files/bin/mw-make-backup new file mode 100644 index 0000000..18c48e2 --- /dev/null +++ b/ansible/roles/mw-backend/files/bin/mw-make-backup @@ -0,0 +1,5 @@ +#!/bin/bash + +set -euo pipefail + +exec borg create /mediawiki-borg::mediawiki-{now:%Y%m%d-%H%M%S} /mediawiki-backup diff --git a/ansible/roles/mw-backend/tasks/main.yml b/ansible/roles/mw-backend/tasks/main.yml index d1abd8c..497fad2 100644 --- a/ansible/roles/mw-backend/tasks/main.yml +++ b/ansible/roles/mw-backend/tasks/main.yml @@ -4,10 +4,9 @@ - mw-backend - packages block: - - copy: + - file: dest: /etc/apt/apt.conf.d/99force-ipv4 - content: 'Acquire::ForceIPv4 "true";' - notify: update apt cache + state: absent - name: configure debian repositories notify: update apt cache copy: @@ -97,6 +96,38 @@ state: started name: mw-jobqueue.timer +- name: Mediawiki Backup + tags: + - mw-backend + - mediawiki-backup + block: + - name: packages + apt: + name: "{{ item }}" + install_recommends: no + with_items: + - borgbackup + - name: mkdir + with_items: + - /mediawiki-backup + file: + state: directory + path: "{{ item }}" + + - name: borgbackup init + shell: borgbackup init -e none /mediawiki-borg + args: + creates: /mediawiki-borg + + - copy: + src: "{{ item }}" + dest: "/{{ item }}" + mode: a+rx + with_items: + - bin/mw-dump-backup + - bin/mw-dump-db + - bin/mw-make-backup + - name: Semantic MediaWiki tags: - mw-backend diff --git a/ansible/roles/mw-backend/templates/etc/mediawiki/LocalSettings.php.j2 b/ansible/roles/mw-backend/templates/etc/mediawiki/LocalSettings.php.j2 index d494693..9def832 100644 --- a/ansible/roles/mw-backend/templates/etc/mediawiki/LocalSettings.php.j2 +++ b/ansible/roles/mw-backend/templates/etc/mediawiki/LocalSettings.php.j2 @@ -71,6 +71,7 @@ $wgMemCachedServers = []; $wgEnableUploads = true; #$wgUseImageMagick = true; #$wgImageMagickConvertCommand = "/usr/bin/convert"; +$wgFileExtensions[] = 'pdf'; # InstantCommons allows wiki to use images from https://commons.wikimedia.org $wgUseInstantCommons = true; @@ -146,12 +147,12 @@ if ( is_file( "/etc/mediawiki-extensions/extensions.php" ) ) { } # Add a "powered by Debian" footer icon $wgFooterIcons['poweredby']['debian'] = [ - "src" => "/resources/assets/debian/poweredby_debian_1x.png", + "src" => "/w/resources/assets/debian/poweredby_debian_1x.png", "url" => "https://www.debian.org/", "alt" => "Powered by Debian", "srcset" => - "/resources/assets/debian/poweredby_debian_1_5x.png 1.5x, " . - "/resources/assets/debian/poweredby_debian_2x.png 2x", + "/w/resources/assets/debian/poweredby_debian_1_5x.png 1.5x, " . + "/w/resources/assets/debian/poweredby_debian_2x.png 2x", ]; # End Debian specific generated settings # Add more configuration options below. -- cgit v1.2.3