4 changed files with 139 additions and 188 deletions
@ -0,0 +1,23 @@ |
|||||||
|
--- |
||||||
|
- debug: |
||||||
|
var: doku_path |
||||||
|
|
||||||
|
- name: make dokuwiki archive |
||||||
|
community.general.archive: |
||||||
|
dest: "{{ archive }}" |
||||||
|
path: |
||||||
|
- "{{ doku_path }}conf" |
||||||
|
- "{{ doku_path }}data" |
||||||
|
- "{{ doku_path }}lib/plugins" |
||||||
|
|
||||||
|
- name: copy archive to controller |
||||||
|
fetch: |
||||||
|
src: "{{ archive }}" |
||||||
|
dest: "{{ output }}" |
||||||
|
flat: yes |
||||||
|
|
||||||
|
- name: remove remote archive |
||||||
|
file: |
||||||
|
path: "{{ archive }}" |
||||||
|
state: absent |
||||||
|
|
||||||
@ -1,165 +1,100 @@ |
|||||||
--- |
--- |
||||||
# NOTE: https://wiki.alpinelinux.org/wiki/DokuWiki |
# NOTE: https://wiki.alpinelinux.org/wiki/DokuWiki |
||||||
- name: install dokuwiki to container |
|
||||||
hosts: dokuwiki |
- name: test if dokuwiki is already installed |
||||||
tags: containers |
find: |
||||||
|
paths: "{{ doku_dir }}" |
||||||
vars: |
pattern: README |
||||||
lighttpd_user: lighttpd |
register: check_installed |
||||||
lighttpd_group: lighttpd |
|
||||||
docroot: /var/www/localhost/htdocs |
- set_fact: |
||||||
|
install_dokuwiki: "{{ check_installed.matched == 0 }}" |
||||||
doku_url: https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz |
|
||||||
doku_tar: /tmp/dokuwiki-stable.tgz |
- name: install block |
||||||
doku_dir: "{{ docroot }}/dokuwiki" |
when: install_dokuwiki |
||||||
|
vars: {} |
||||||
use_backup: True |
block: |
||||||
doku_backup_archive: ../data/dokuwiki_backup.tgz |
- name: add dokuwiki deny rules to lighttpd.conf |
||||||
backup_guard: ANSIBLE_BACKUP_GUARD |
blockinfile: |
||||||
|
path: /etc/lighttpd/lighttpd.conf |
||||||
tasks: |
block: | |
||||||
|
$HTTP["url"] =~ "^/dokuwiki/(data|conf|bin|inc|vendor)/+." { |
||||||
# TODO: break out lighttpd default config to a separate playlist |
url.access-deny = ("") |
||||||
|
} |
||||||
# |
|
||||||
# lighttpd config |
- name: restart lighttpd |
||||||
# |
service: |
||||||
|
name: lighttpd |
||||||
- name: install packages |
enabled: yes |
||||||
vars: |
state: restarted |
||||||
packages: |
|
||||||
- lighttpd |
- name: download dokuwiki stable |
||||||
- php7-common |
get_url: |
||||||
- php7-session |
url: "{{ doku_url }}" |
||||||
- php7-iconv |
dest: "{{ doku_tar }}" |
||||||
- php7-json |
|
||||||
- php7-gd |
- name: make directory for dokiwiki in docroot |
||||||
- php7-curl |
file: |
||||||
- php7-xml |
path: "{{ doku_dir }}" |
||||||
- php7-mysqli |
state: directory |
||||||
- php7-imap |
owner: "{{ lighttpd_user }}" |
||||||
- php7-cgi |
group: "{{ lighttpd_group }}" |
||||||
- php7-pdo |
|
||||||
- php7-pdo_mysql |
- name: unarchive downloaded file |
||||||
- php7-soap |
unarchive: |
||||||
- php7-xmlrpc |
remote_src: yes |
||||||
- php7-posix |
src: "{{ doku_tar }}" |
||||||
- php7-mcrypt |
dest: /tmp |
||||||
- php7-gettext |
owner: "{{ lighttpd_user }}" |
||||||
- php7-ldap |
group: "{{ lighttpd_group }}" |
||||||
- php7-ctype |
|
||||||
- php7-dom |
- name: find doku temporary directory |
||||||
- fcgi |
find: |
||||||
- tar |
paths: /tmp/ |
||||||
apk: |
file_type: directory |
||||||
name: "{{ packages | join(' ') }}" |
pattern: "dokuwiki-20*" |
||||||
state: present |
use_regex: true |
||||||
|
register: doku_tmp_dir |
||||||
# TODO: replace seperate template with 'line in file' |
|
||||||
#$HTTP["url"] =~ "^/dokuwiki/(data|conf|bin|inc|vendor)/+." { |
- name: copy dokuwiki files to webroot |
||||||
# url.access-deny = ("") |
copy: |
||||||
#} |
remote_src: yes |
||||||
# - name: copy lighttpd.conf |
src: "{{ doku_tmp_dir.files[0].path }}/" |
||||||
# copy: |
dest: "{{ doku_dir }}" |
||||||
# src: ../templates/lighttpd.conf.j2 |
owner: "{{ lighttpd_user }}" |
||||||
# dest: /etc/lighttpd/lighttpd.conf |
group: "{{ lighttpd_group }}" |
||||||
|
|
||||||
- name: ensure lighttpd service is started |
- name: remove archive |
||||||
service: |
file: |
||||||
name: lighttpd |
path: "{{ doku_tar }}" |
||||||
enabled: yes |
state: absent |
||||||
state: started |
|
||||||
|
- name: remove temporary files |
||||||
# |
file: |
||||||
# dokuwiki config |
path: "{{ doku_tmp_dir.files[0].path }}" |
||||||
# |
state: absent |
||||||
|
|
||||||
# TODO: this should be a separate play |
## |
||||||
|
## install backup data |
||||||
- name: test if dokuwiki was already installed |
## |
||||||
find: |
|
||||||
paths: "{{ doku_dir }}" |
- name: test for backup guard |
||||||
pattern: README |
find: |
||||||
register: doku_find_result |
path: "{{ doku_dir }}" |
||||||
when: not use_backup |
pattern: "{{ backup_guard }}" |
||||||
|
register: backup_guard_present |
||||||
- name: download dokuwiki stable |
|
||||||
get_url: |
- name: extract backup archive |
||||||
url: "{{ doku_url }}" |
unarchive: |
||||||
dest: "{{ doku_tar }}" |
src: "{{ doku_backup_archive }}" |
||||||
when: not use_backup and doku_find_result.matched == 0 |
dest: "{{ doku_dir }}" |
||||||
|
owner: "{{ lighttpd_user }}" |
||||||
- name: make directory for dokiwiki in docroot |
group: "{{ lighttpd_group }}" |
||||||
file: |
when: use_backup and backup_guard_present.matched == 0 |
||||||
path: "{{ doku_dir }}" |
|
||||||
state: directory |
- name: add guard file to let ansible know backup is completed |
||||||
owner: "{{ lighttpd_user }}" |
file: |
||||||
group: "{{ lighttpd_group }}" |
path: "{{ doku_dir }}/{{ backup_guard }}" |
||||||
when: not use_backup and doku_find_result.matched == 0 |
state: touch |
||||||
|
when: use_backup and backup_guard_present.matched == 0 |
||||||
- name: unarchive downloaded file |
|
||||||
unarchive: |
|
||||||
remote_src: yes |
|
||||||
src: "{{ doku_tar }}" |
|
||||||
dest: /tmp |
|
||||||
owner: "{{ lighttpd_user }}" |
|
||||||
group: "{{ lighttpd_group }}" |
|
||||||
when: not use_backup and doku_find_result.matched == 0 |
|
||||||
|
|
||||||
- name: find doku temporary directory |
|
||||||
find: |
|
||||||
paths: /tmp/ |
|
||||||
file_type: directory |
|
||||||
pattern: "dokuwiki-20*" |
|
||||||
use_regex: true |
|
||||||
register: doku_tmp_dir |
|
||||||
when: not use_backup |
|
||||||
|
|
||||||
- name: copy dokuwiki files to webroot |
|
||||||
copy: |
|
||||||
remote_src: yes |
|
||||||
src: "{{ doku_tmp_dir.files[0].path }}/" |
|
||||||
dest: "{{ doku_dir }}" |
|
||||||
owner: "{{ lighttpd_user }}" |
|
||||||
group: "{{ lighttpd_group }}" |
|
||||||
when: not use_backup and doku_tmp_dir.matched > 0 |
|
||||||
|
|
||||||
# NOTE: this is only about 3.5MB |
|
||||||
#- name: remove archive |
|
||||||
# file: |
|
||||||
# path: "{{ doku_tar }}" |
|
||||||
# state: absent |
|
||||||
|
|
||||||
- name: remove temporary files |
|
||||||
file: |
|
||||||
path: "{{ doku_tmp_dir.files[0].path }}" |
|
||||||
state: absent |
|
||||||
when: not use_backup and doku_tmp_dir.matched > 0 |
|
||||||
|
|
||||||
# |
|
||||||
# install backup data |
|
||||||
# |
|
||||||
|
|
||||||
- name: test for backup guard |
|
||||||
find: |
|
||||||
path: "{{ doku_dir }}" |
|
||||||
pattern: "{{ backup_guard }}" |
|
||||||
register: backup_guard_present |
|
||||||
|
|
||||||
- name: extract backup archive |
|
||||||
unarchive: |
|
||||||
src: "{{ doku_backup_archive }}" |
|
||||||
dest: "{{ docroot }}" |
|
||||||
owner: "{{ lighttpd_user }}" |
|
||||||
group: "{{ lighttpd_group }}" |
|
||||||
when: use_backup and backup_guard_present.matched == 0 |
|
||||||
|
|
||||||
- name: add guard file to let ansible know backup is completed |
|
||||||
file: |
|
||||||
path: "{{ doku_dir }}/{{ backup_guard }}" |
|
||||||
state: touch |
|
||||||
when: use_backup and backup_guard_present.matched == 0 |
|
||||||
|
|
||||||
# TODO: add play for creating backup data |
|
||||||
# TODO: split up plays and move to separate role |
|
||||||
# TODO: remember to add custom plugins to backup |
|
||||||
|
|||||||
@ -1,30 +1,24 @@ |
|||||||
--- |
--- |
||||||
#- name: include dokuwiki install task |
- name: include dokuwiki install task |
||||||
# include_tasks: dokuwiki.yml |
vars: |
||||||
|
lighttpd_user: lighttpd |
||||||
|
lighttpd_group: lighttpd |
||||||
|
docroot: /var/www/localhost/htdocs |
||||||
|
|
||||||
|
doku_url: https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz |
||||||
|
doku_tar: /tmp/dokuwiki-stable.tgz |
||||||
|
doku_dir: "{{ docroot }}/dokuwiki" |
||||||
|
|
||||||
|
use_backup: True |
||||||
|
doku_backup_archive: data/dokuwiki_backup.tgz |
||||||
|
backup_guard: ANSIBLE_BACKUP_GUARD |
||||||
|
import_tasks: dokuwiki.yml |
||||||
|
|
||||||
- name: backup block |
- name: backup block |
||||||
when: "'backup' in ansible_run_tags" |
include_tasks: backup.yml |
||||||
vars: |
vars: |
||||||
output: /tmp/ |
output: /tmp/ |
||||||
archive: /tmp/dokuwiki_backup.tgz |
archive: /tmp/dokuwiki_backup.tgz |
||||||
doku_path: /var/www/localhost/htdocs/dokuwiki/ |
doku_path: /var/www/localhost/htdocs/dokuwiki/ |
||||||
block: |
when: "'backup' in ansible_run_tags" |
||||||
- name: make dokuwiki archive |
|
||||||
community.general.archive: |
|
||||||
dest: "{{ archive }}" |
|
||||||
path: |
|
||||||
- "{{ doku_path }} + conf" |
|
||||||
- "{{ doku_path }} + data" |
|
||||||
- "{{ doku_path }} + lib/plugins" |
|
||||||
|
|
||||||
- name: copy archive to controller |
|
||||||
fetch: |
|
||||||
src: "{{ archive }}" |
|
||||||
dest: "{{ output }}" |
|
||||||
flat: yes |
|
||||||
|
|
||||||
- name: remove remote archive |
|
||||||
file: |
|
||||||
path: "{{ archive }}" |
|
||||||
state: absent |
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in new issue