From 5e82eb85edc36fb978588fceb8e622d76d727afa Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 23 Mar 2015 18:32:29 +0100 Subject: Add a bit more code for deploying mediawiki --- roles/mediawiki/defaults/main.yml | 4 + roles/mediawiki/tasks/main.yml | 23 ++-- roles/mediawiki/templates/LocalSettings.php | 175 ++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+), 9 deletions(-) create mode 100644 roles/mediawiki/templates/LocalSettings.php diff --git a/roles/mediawiki/defaults/main.yml b/roles/mediawiki/defaults/main.yml index 7772db3..05a85f2 100644 --- a/roles/mediawiki/defaults/main.yml +++ b/roles/mediawiki/defaults/main.yml @@ -1,3 +1,7 @@ --- cache_dir: /var/tmp/ version: 1.24.0 +wiki_name: The_unconfigured_wiki +contact: root@localhost +wiki_db_name: mediawiki +wiki_db_user: wikiuser diff --git a/roles/mediawiki/tasks/main.yml b/roles/mediawiki/tasks/main.yml index 2f52933..2a9f1da 100644 --- a/roles/mediawiki/tasks/main.yml +++ b/roles/mediawiki/tasks/main.yml @@ -6,6 +6,9 @@ - php-gd - php-xml +- set_fact: wiki_secret_key="{{ lookup('password', 'passwords/mediawiki/wiki_secret_key length=60') }}" +- set_fact: wiki_db_password="{{ lookup('password', 'passwords/mediawiki/wiki_db_password length=12') }}" + - get_url: dest={{ cache_dir }}/{{ item }} url=https://releases.wikimedia.org/mediawiki/{{ version | regex_replace('^(\d+)\.(\d+).*$', '\\1.\\2') }}/{{ item }} with_items: - mediawiki-{{ version }}.tar.gz @@ -14,18 +17,20 @@ # TODO verify the signature when downloaded -- file: state=directory name=/var/www/mediawiki{{ item }} +- set_fact: wiki_dir=/var/www/mediawiki/ + +- file: state=directory name={{ wiki_dir }}{{ item.path }} owner={{ item.owner }} with_items: - - / - - /cache + - { path: "/", owner: "root" } + - { path: "/cache", owner: "apache" } + - { path: "/images", owner: "apache" } -- command: creates=/var/www/mediawiki/mediawiki-{{ version }} tar -x --owner=root --group=root -f {{ cache_dir }}/mediawiki-{{ version }}.tar.gz -C /var/www/mediawiki/ +- set_fact: image_dir={{ wiki_dir }}/images +- set_fact: code_dir={{ wiki_dir }}/mediawiki-{{ version }} -# TODO selinux path ? -- file: path=/var/www/mediawiki/mediawiki-{{ version }}/cache owner=apache state=directory +- command: creates={{ code_dir }} tar -x --owner=root --group=root -f {{ cache_dir }}/mediawiki-{{ version }}.tar.gz -C {{ wiki_dir }} + +- template: src=LocalSettings.php dest={{ code_dir }}/LocalSettings.php - template: src=wiki.conf dest=/etc/httpd/conf.d/www.theopensourceway.org.conf.d/wiki.conf notify: restart httpd - -# upload dir, SELinux -- file: state=directory path=/var/www/mediawiki_upload owner=apache diff --git a/roles/mediawiki/templates/LocalSettings.php b/roles/mediawiki/templates/LocalSettings.php new file mode 100644 index 0000000..7a4fbd1 --- /dev/null +++ b/roles/mediawiki/templates/LocalSettings.php @@ -0,0 +1,175 @@ +