Import the old role.

This commit is contained in:
Andrea Dell'Amico 2020-06-22 12:31:47 +02:00
parent 38fb69db6d
commit 461b64bcf0
7 changed files with 234 additions and 69 deletions

View File

@ -1,31 +1,63 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
A role that installs MediaWiki
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
The most important variables are listed below:
``` yaml
mw_install_from_package: False
# Distribution packages are always obsolete
mw_install_from_tar: True
mw_version: 1.33
mw_minor_minor: 0
mw_download_url: http://releases.wikimedia.org/mediawiki/{{ mw_version }}/mediawiki-{{ mw_version }}.{{ mw_minor_minor }}.tar.gz
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"'
php_version: '{{ mw_php_version }}'
mw_php_additional_packages:
- 'php{{ php_version }}-mbstring'
- 'php{{ php_version }}-xmlrpc'
- 'php{{ php_version }}-soap'
- 'php{{ php_version }}-gd'
- 'php{{ php_version }}-xml'
- 'php{{ php_version }}-intl'
- 'php{{ php_version }}-mysql'
- 'php{{ php_version }}-cli'
- 'php{{ php_version }}-zip'
- 'php{{ php_version }}-curl'
- php-apcu
- php-wikidiff2
- imagemagick
- php-imagick
phpfpm_pools: '{{ mw_phpfpm_pool }}'
```
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
* nginx
* mysql
* php-fpm
* memcached
License
-------
@ -35,4 +67,4 @@ EUPL-1.2
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Andrea Dell'Amico, <andrea.dellamico@isti.cnr.it>

View File

@ -1,2 +1,74 @@
---
# defaults file for ansible-role-template
#
# This playbook depends on the php-fpm, mysql role and nginx
#
mw_install_from_package: False
# Distribution packages are always obsolete
mw_install_from_tar: True
mw_version: 1.33
mw_minor_minor: 0
mw_download_url: http://releases.wikimedia.org/mediawiki/{{ mw_version }}/mediawiki-{{ mw_version }}.{{ mw_minor_minor }}.tar.gz
mw_download_dir: /srv/mediawiki
mw_install_dir: /var/www/html
mw_conf_dir: /etc/mediawiki
mw_servername: '{{ ansible_fqdn }}'
mw_db_host: localhost
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'
mysql_db_data: '{{ mw_mysql_db_data }}'
mw_id: 'wiki'
mw_uri: '/wiki'
mw_http_port: 80
mw_https_port: 443
http_port: '{{ mw_http_port }}'
https_port: '{{ mw_https_port }}'
php_version: '{{ mw_php_version }}'
mw_php_additional_packages:
- 'php{{ php_version }}-mbstring'
- 'php{{ php_version }}-xmlrpc'
- 'php{{ php_version }}-soap'
- 'php{{ php_version }}-gd'
- 'php{{ php_version }}-xml'
- 'php{{ php_version }}-intl'
- 'php{{ php_version }}-mysql'
- 'php{{ php_version }}-cli'
- 'php{{ php_version }}-zip'
- 'php{{ php_version }}-curl'
- php-apcu
- php-wikidiff2
- imagemagick
- php-imagick
phpfpm_pools: '{{ mw_phpfpm_pool }}'
# This choice is not recommended. The package has a poor list of dependencies. We do not want to deal with those
mw_package:
- mediawiki

View File

@ -1,61 +1,42 @@
galaxy_info:
author: your name
description: your description
author: Andrea Dell'Amico
description: Systems Architect
company: ISTI-CNR
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: EUPL-1.2
license: EUPL 1.2+
min_ansible_version: 2.8
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
platforms:
- name: Ubuntu
versions:
- bionic
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
galaxy_tags:
- mediawiki
dependencies:
- src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-mysql.git
version: master
name: mysql
state: latest
when: mw_local_mysql
- src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-php-fpm.git
version: master
name: php-fpm
state: latest
- src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-memcached.git
version: master
name: memcached
state: latest
when: mw_local_memcached
- src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-nginx.git
version: master
name: nginx
state: latest
when: mw_local_nginx

View File

@ -1,2 +1,69 @@
---
# tasks file for ansible-role-template
- name: Install the wordpress php prerequisites
apt: name={{ mw_php_additional_packages }} state=present cache_valid_time=1800
tags: mediawiki
- name: Ensure that the download and install dirs exist
file: path={{ item }} state=directory
with_items:
- '{{ mw_download_dir }}'
- '{{ mw_install_dir }}'
tags: mediawiki
- name: Download the mediawiki tar file
get_url: url={{ mw_download_url }} dest={{ mw_download_dir }}
when:
- not mw_install_from_package
- mw_install_from_tar
tags: mediawiki
- name: Unpack the mediawiki tar file
unarchive: copy=no src={{ mw_download_dir }}/mediawiki-{{ mw_version }}.{{ mw_minor_minor }}.tar.gz dest={{ mw_download_dir }}
args:
creates: '{{ mw_download_dir }}/mediawiki-{{ mw_version }}.{{ mw_minor_minor }}/INSTALL'
when: mw_install_from_tar
tags: mediawiki
- name: Move the mediawiki files to the right place
command: cp -a {{ mw_download_dir }}/mediawiki-{{ mw_version }}.{{ mw_minor_minor }} {{ mw_doc_root }}
args:
creates: '{{ mw_doc_root }}/index.php'
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 }}'
tags: mediawiki
- 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
template: src=mw_db_passwd.j2 dest=/tmp/mw_db_passwd owner=root group=root mode=0400
- name: Create a file with the admin password
template: 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 }}

View File

@ -1,2 +1,13 @@
---
# vars file for ansible-role-template
php_from_ppa: True
mw_php_version: 7.2
phpfpm_default_pool_name: '{{ mw_system_user }}'
phpfpm_default_user: '{{ mw_system_user }}'
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_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 }}' }