Add dokuwiki role

For an Alpine Linux VM.
This commit is contained in:
Timotej Lazar 2024-01-20 18:38:41 +01:00
parent 4420846817
commit 02f778604c
9 changed files with 246 additions and 1 deletions

View file

@ -0,0 +1,69 @@
- name: Set dokuwiki version
set_fact:
dokuwiki_version: 2023-04-04a
- name: Enable community package repo
lineinfile:
path: /etc/apk/repositories
regexp: '^# *(http.*/v[^/]*/community)'
line: '\1'
backrefs: yes
register: result
- name: Update package cache
package:
update_cache: true
when: result.changed
- name: Set up nginx
import_tasks: nginx.yml
- name: Set up PHP
import_tasks: php.yml
- name: Install packages
package:
name: php-openssl,php-session,php-xml
- name: Get current dokuwiki version if any
lineinfile:
path: /srv/http/doku.fri.uni-lj.si/VERSION
search_string: '{{ dokuwiki_version }}'
state: absent
check_mode: true
changed_when: false
register: current_version
- name: Install or upgrade dokuwiki
when: 'current_version.found|default(0) == 0'
block:
- name: Download dokuwiki tarball
get_url:
url: 'https://download.dokuwiki.org/src/dokuwiki/dokuwiki-{{ dokuwiki_version }}.tgz'
dest: /var/tmp/
- name: Unpack tarball
command: 'tar xvf dokuwiki-{{ dokuwiki_version }}.tgz'
args:
chdir: /var/tmp
- name: Copy dokuwiki files
copy:
dest: /srv/http/doku.fri.uni-lj.si/
src: '/var/tmp/dokuwiki-{{ dokuwiki_version }}/'
remote_src: true
owner: nginx
group: nginx
- name: Copy user style overrides
copy:
dest: /srv/http/doku.fri.uni-lj.si/conf/
src: userstyle.css
owner: nginx
group: nginx
- name: Create nginx site
template:
dest: /etc/nginx/http.d/doku.fri.uni-lj.si.conf
src: doku.fri.uni-lj.si.conf.j2
notify: reload nginx

View file

@ -0,0 +1,42 @@
- name: Enable community package repo
lineinfile:
path: /etc/apk/repositories
regexp: '^# *(http.*/v[^/]*/community)'
line: '\1'
backrefs: yes
- name: Install packages
package:
name: certbot,nginx
- name: Create HTTP server directories
file:
path: /srv/http/.well-known
recurse: true
state: directory
owner: nginx
group: nginx
- name: Set up default HTTP server
copy:
dest: /etc/nginx/http.d
src: default.conf
- name: Enable nginx service
service:
name: nginx
enabled: true
state: started
- name: Get LE certificate
command:
cmd: certbot certonly --non-interactive --agree-tos --register-unsafely-without-email --webroot --webroot-path /srv/http -d doku.fri.uni-lj.si
creates: '/etc/letsencrypt/renewal/doku.fri.uni-lj.si.conf'
- name: Enable certbot renewal
cron:
name: "certbot renew"
job: "certbot renew --quiet"
user: root
hour: "2,14"
minute: "18"

View file

@ -0,0 +1,45 @@
- name: Install packages
package:
name: acl,php,php-fpm
- name: Find PHP package
command: apk info -e php
register: php_package
changed_when: false
- name: Set PHP version
set_fact:
php_version: "{{ php_package.stdout | regex_search('[0-9.]+') }}"
- name: Set PHP-FPM settings
lineinfile:
path: '/etc/php{{ php_version }}/php-fpm.d/www.conf'
regexp: '^;?{{ item.key }}\s*='
line: '{{ item.key }} = {{ item.value }}'
loop:
- key: user
value: nginx
- key: group
value: nginx
- key: listen
value: '/run/php-fpm.socket'
- key: listen.acl_users
value: nginx
- key: listen.acl_groups
value: nginx
- name: Set PHP settings
lineinfile:
path: '/etc/php{{ php_version }}/php.ini'
regexp: '^{{ item.key }}\s*='
line: '{{ item.key }} = {{ item.value }}'
loop:
- key: upload_max_filesize
value: 200M
notify: restart php-fpm
- name: Enable php-fpm service
service:
name: 'php-fpm{{ php_version }}'
enabled: true
state: started