You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
344 lines
12 KiB
344 lines
12 KiB
---
|
|
|
|
- name: Set default install mode to none
|
|
set_fact: dokuwiki_install_mode="none"
|
|
|
|
- name: Install dependencies
|
|
yum:
|
|
name:
|
|
- acl
|
|
|
|
- name: Create PHP user acount
|
|
user:
|
|
name: "{{ dokuwiki_php_user }}"
|
|
comment: "PHP FPM for dokuwiki {{ dokuwiki_id }}"
|
|
system: yes
|
|
shell: /sbin/nologin
|
|
|
|
- name: Check if dokuwiki is already installed
|
|
stat: path={{ dokuwiki_root_dir }}/meta/ansible_version
|
|
register: dokuwiki_version_file
|
|
changed_when: False
|
|
|
|
- name: Check dokuwiki version
|
|
command: cat {{ dokuwiki_root_dir }}/meta/ansible_version
|
|
register: dokuwiki_current_version
|
|
changed_when: False
|
|
when: dokuwiki_version_file.stat.exists
|
|
|
|
- name: Set installation process to install
|
|
set_fact: dokuwiki_install_mode='install'
|
|
when: not dokuwiki_version_file.stat.exists
|
|
|
|
- name: Set installation process to upgrade
|
|
set_fact: dokuwiki_install_mode='upgrade'
|
|
when:
|
|
- dokuwiki_version_file.stat.exists
|
|
- dokuwiki_current_version.stdout != dokuwiki_version
|
|
- dokuwiki_manage_upgrade
|
|
|
|
- name: Create archive dir
|
|
file: path={{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }} state=directory mode=700
|
|
when: dokuwiki_install_mode == 'upgrade'
|
|
|
|
- name: Prepare dokuwiki upgrade
|
|
synchronize:
|
|
src: "{{ dokuwiki_root_dir }}/web"
|
|
dest: "{{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }}/"
|
|
recursive: True
|
|
delete: True
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
when: dokuwiki_install_mode == 'upgrade'
|
|
|
|
- name: Create directory structure
|
|
file: path={{ item.dir }} state=directory owner={{ item.owner | default(omit) }} group={{ item.groupe | default(omit) }} mode={{ item.mode | default(omit) }}
|
|
with_items:
|
|
- dir: "{{ dokuwiki_root_dir }}"
|
|
- dir: "{{ dokuwiki_root_dir }}/web"
|
|
- dir: "{{ dokuwiki_root_dir }}/tmp"
|
|
owner: "{{ dokuwiki_php_user }}"
|
|
mode: 700
|
|
- dir: "{{ dokuwiki_root_dir }}/cache"
|
|
owner: "{{ dokuwiki_php_user }}"
|
|
mode: 700
|
|
- dir: "{{ dokuwiki_root_dir }}/sessions"
|
|
owner: "{{ dokuwiki_php_user }}"
|
|
mode: 700
|
|
- dir: "{{ dokuwiki_root_dir }}/data"
|
|
- dir: "{{ dokuwiki_root_dir }}/meta"
|
|
mode: 700
|
|
- dir: "{{ dokuwiki_root_dir }}/web/conf/tpl"
|
|
group: "{{ dokuwiki_php_user }}"
|
|
mode: 770
|
|
|
|
- name: Download Dokuwiki
|
|
get_url:
|
|
url: "{{ dokuwiki_archive_url }}"
|
|
dest: "{{ dokuwiki_root_dir }}/tmp/"
|
|
checksum: "sha1:{{ dokuwiki_archive_sha1 }}"
|
|
when: dokuwiki_install_mode != 'none'
|
|
|
|
- name: Extract dokuwiki archive
|
|
unarchive:
|
|
src: "{{ dokuwiki_root_dir }}/tmp/dokuwiki-{{ dokuwiki_version }}.tgz"
|
|
dest: "{{ dokuwiki_root_dir }}/tmp/"
|
|
remote_src: yes
|
|
when: dokuwiki_install_mode != 'none'
|
|
|
|
- name: Move the content of dokuwiki to the correct top directory
|
|
synchronize:
|
|
src: "{{ dokuwiki_root_dir }}/tmp/dokuwiki-{{ dokuwiki_version }}/"
|
|
dest: "{{ dokuwiki_root_dir }}/web/"
|
|
recursive: True
|
|
delete: True
|
|
rsync_opts:
|
|
- '--exclude=data/'
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
when: dokuwiki_install_mode != 'none'
|
|
|
|
- name: Populate the data dir
|
|
synchronize:
|
|
src: "{{ dokuwiki_root_dir }}/tmp/dokuwiki-{{ dokuwiki_version }}/data/"
|
|
dest: "{{ dokuwiki_root_dir }}/data/"
|
|
recursive: True
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
when: dokuwiki_install_mode != 'none'
|
|
|
|
- name: Check existing conf to restore
|
|
stat: path={{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }}/web/{{ item }}
|
|
with_items:
|
|
- conf/local.php
|
|
- conf/acl.auth.php
|
|
- conf/users.auth.php
|
|
- conf/plugins.local.php
|
|
- conf/tpl/
|
|
register: dokuwiki_conf_to_restore
|
|
|
|
- name: Restore Configuration
|
|
synchronize:
|
|
src: "{{ item.stat.path }}"
|
|
dest: "{{ dokuwiki_root_dir }}/web/{{ item.item }}"
|
|
recursive: True
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
with_items: "{{ dokuwiki_conf_to_restore.results }}"
|
|
when:
|
|
- dokuwiki_install_mode == 'upgrade'
|
|
- item.stat.exists
|
|
|
|
- name: List previously installed plugins
|
|
shell: find {{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }}/web/lib/plugins -maxdepth 1 -mindepth 1 -type d -exec basename "{}" \;
|
|
register: dokuwiki_current_plugins
|
|
when:
|
|
- dokuwiki_install_mode == 'upgrade'
|
|
- not dokuwiki_remove_unmanaged_plugins
|
|
|
|
- name: Restore unmanaged previous plugins
|
|
synchronize:
|
|
src: "{{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }}/web/lib/plugins/{{ item }}"
|
|
dest: "{{ dokuwiki_root_dir }}/web/lib/plugins/"
|
|
recursive: True
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
with_items: "{{ dokuwiki_current_plugins.stdout_lines }}"
|
|
when:
|
|
- dokuwiki_install_mode == 'upgrade'
|
|
- not dokuwiki_remove_unmanaged_plugins
|
|
|
|
- name: List previously installed templates
|
|
shell: find {{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }}/web/lib/tpl -maxdepth 1 -mindepth 1 -type d -exec basename "{}" \;
|
|
register: dokuwiki_current_tpl
|
|
when:
|
|
- dokuwiki_install_mode == 'upgrade'
|
|
- not dokuwiki_remove_unmanaged_tpl
|
|
|
|
- name: Restore unmanaged previous templates
|
|
synchronize:
|
|
src: "{{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }}/web/lib/tpl/{{ item }}"
|
|
dest: "{{ dokuwiki_root_dir }}/web/lib/tpl/"
|
|
recursive: True
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
with_items: "{{ dokuwiki_current_tpl.stdout_lines }}"
|
|
when:
|
|
- dokuwiki_install_mode == 'upgrade'
|
|
- not dokuwiki_remove_unmanaged_tpl
|
|
|
|
- name: Write dokuwiki version
|
|
copy: content={{ dokuwiki_version }} dest={{ dokuwiki_root_dir }}/meta/ansible_version
|
|
when: dokuwiki_install_mode != 'none'
|
|
|
|
- name: Compress previous version
|
|
command: tar cJf {{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }}.txz ./
|
|
environment:
|
|
XZ_OPT: -T0
|
|
args:
|
|
chdir: "{{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }}"
|
|
when: dokuwiki_install_mode == 'upgrade'
|
|
|
|
- name: Remove archive directory
|
|
file: path={{ dokuwiki_root_dir }}/archives/{{ dokuwiki_current_version.stdout }} state=absent
|
|
when: dokuwiki_install_mode == 'upgrade'
|
|
|
|
- name: Build a list of installed plugins
|
|
shell: find {{ dokuwiki_root_dir }}/web/lib/plugins -maxdepth 1 -mindepth 1 -type d -exec basename "{}" \;
|
|
register: dokuwiki_installed_plugins
|
|
changed_when: False
|
|
|
|
- name: Install authhttpldap plugin
|
|
copy: src=authhttpldap dest={{ dokuwiki_root_dir }}/web/lib/plugins
|
|
|
|
- name: Download plugins
|
|
get_url:
|
|
url: "{{ dokuwiki_plugins[item].url }}"
|
|
dest: "{{ dokuwiki_root_dir }}/tmp/"
|
|
when:
|
|
- item not in dokuwiki_installed_plugins.stdout_lines
|
|
- dokuwiki_plugins[item] is defined
|
|
- dokuwiki_plugins[item].type | default('plugin') == 'plugin'
|
|
with_items: "{{ dokuwiki_plugins_to_install }}"
|
|
|
|
- name: Extract plugins
|
|
unarchive:
|
|
src: "{{ dokuwiki_root_dir }}/tmp/{{ dokuwiki_plugins[item].archive_name }}"
|
|
dest: "{{ dokuwiki_root_dir }}/tmp"
|
|
remote_src: yes
|
|
when:
|
|
- item not in dokuwiki_installed_plugins.stdout_lines
|
|
- dokuwiki_plugins[item] is defined
|
|
- dokuwiki_plugins[item].type | default('plugin') == 'plugin'
|
|
with_items: "{{ dokuwiki_plugins_to_install }}"
|
|
|
|
- name: Move plugins to the final dir
|
|
synchronize:
|
|
src: "{{ dokuwiki_root_dir }}/tmp/{{ dokuwiki_plugins[item].archive_dir | default(dokuwiki_plugins[item].archive_name | splitext | first) }}/"
|
|
dest: "{{ dokuwiki_root_dir }}/web/lib/plugins/{{ item }}"
|
|
recursive: True
|
|
delete: True
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
when:
|
|
- item not in dokuwiki_installed_plugins.stdout_lines
|
|
- dokuwiki_plugins[item] is defined
|
|
- dokuwiki_plugins[item].type | default('plugin') == 'plugin'
|
|
with_items: "{{ dokuwiki_plugins_to_install }}"
|
|
|
|
- name: Remove unmanaged plugins
|
|
file: path={{ dokuwiki_root_dir }}/web/lib/plugins/{{ item }} state=absent
|
|
with_items: "{{ dokuwiki_installed_plugins.stdout_lines }}"
|
|
when:
|
|
- item not in dokuwiki_plugins_to_install
|
|
- item not in dokuwiki_core_plugins
|
|
- dokuwiki_remove_unmanaged_plugins
|
|
|
|
- name: Build a list of installed templates
|
|
shell: find {{ dokuwiki_root_dir }}/web/lib/tpl -maxdepth 1 -mindepth 1 -type d -exec basename "{}" \;
|
|
register: dokuwiki_installed_tpl
|
|
changed_when: False
|
|
|
|
- name: Download templates
|
|
get_url:
|
|
url: "{{ dokuwiki_plugins[item].url }}"
|
|
dest: "{{ dokuwiki_root_dir }}/tmp/"
|
|
when:
|
|
- dokuwiki_plugins[item] is defined
|
|
- dokuwiki_plugins[item].type | default('plugin') == 'tpl'
|
|
- item not in dokuwiki_installed_tpl.stdout_lines | difference(['dokuwiki'])
|
|
with_items: "{{ dokuwiki_tpl_to_install }}"
|
|
|
|
- name: Extract templates
|
|
unarchive:
|
|
src: "{{ dokuwiki_root_dir }}/tmp/{{ dokuwiki_plugins[item].archive_name }}"
|
|
dest: "{{ dokuwiki_root_dir }}/tmp"
|
|
remote_src: yes
|
|
when:
|
|
- dokuwiki_plugins[item] is defined
|
|
- dokuwiki_plugins[item].type | default('plugin') == 'tpl'
|
|
- item not in dokuwiki_installed_tpl.stdout_lines | difference(['dokuwiki'])
|
|
with_items: "{{ dokuwiki_tpl_to_install }}"
|
|
|
|
- name: Move templates to the final dir
|
|
synchronize:
|
|
src: "{{ dokuwiki_root_dir }}/tmp/{{ dokuwiki_plugins[item].archive_dir | default(dokuwiki_plugins[item].archive_name | splitext | first) }}/"
|
|
dest: "{{ dokuwiki_root_dir }}/web/lib/tpl/{{ item }}"
|
|
recursive: True
|
|
delete: True
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
when:
|
|
- dokuwiki_plugins[item] is defined
|
|
- dokuwiki_plugins[item].type | default('plugin') == 'tpl'
|
|
- item not in dokuwiki_installed_tpl.stdout_lines | difference(['dokuwiki'])
|
|
with_items: "{{ dokuwiki_tpl_to_install }}"
|
|
|
|
- name: Remove unmanaged tpl
|
|
file: path={{ dokuwiki_root_dir }}/web/lib/tpl/{{ item }} state=absent
|
|
with_items: "{{ dokuwiki_installed_plugins.stdout_lines }}"
|
|
when:
|
|
- item not in dokuwiki_tpl_to_install
|
|
- item != 'dokuwiki'
|
|
- dokuwiki_remove_unmanaged_tpl
|
|
|
|
- name: Remove temp files
|
|
file: path={{ dokuwiki_root_dir }}/tmp/{{ item }} state=absent
|
|
with_items:
|
|
- dokuwiki-{{ dokuwiki_version }}
|
|
- dokuwiki-{{ dokuwiki_version }}.tgz
|
|
|
|
- name: Remove plugins archives
|
|
file: path={{ dokuwiki_root_dir }}/tmp/{{ dokuwiki_plugins[item].archive_name }} state=absent
|
|
when: dokuwiki_plugins[item] is defined
|
|
with_items: "{{ dokuwiki_plugins_to_install + dokuwiki_tpl_to_install }}"
|
|
|
|
- name: Remove plugins temp files
|
|
file: path={{ dokuwiki_root_dir }}/tmp/{{ dokuwiki_plugins[item].archive_dir | default(dokuwiki_plugins[item].archive_name | splitext | first) }} state=absent
|
|
when: dokuwiki_plugins[item] is defined
|
|
with_items: "{{ dokuwiki_plugins_to_install + dokuwiki_tpl_to_install }}"
|
|
|
|
- name: Deploy permission script
|
|
template: src=perms.sh.j2 dest={{ dokuwiki_root_dir }}/perms.sh mode=755
|
|
|
|
- name: Deploy httpd configuration
|
|
template: src=httpd.conf.j2 dest=/etc/httpd/ansible_conf.d/10-dokuwiki_{{ dokuwiki_id }}.conf
|
|
notify: reload httpd
|
|
|
|
- name: Deploy php configuration
|
|
template: src=php.conf.j2 dest={{ httpd_php_versions[dokuwiki_php_version].conf_path }}/php-fpm.d/dokuwiki_{{ dokuwiki_id }}.conf
|
|
notify: restart php-fpm
|
|
|
|
- name: Remove PHP config from other versions
|
|
file: path={{ httpd_php_versions[item].conf_path }}/php-fpm.d/dokuwiki_{{ dokuwiki_id }}.conf state=absent
|
|
with_items: "{{ httpd_php_versions.keys() | list | difference([ dokuwiki_php_version ]) }}"
|
|
notify: restart php-fpm
|
|
|
|
- name: Remove PHP config (using a custom pool)
|
|
file: path={{ httpd_php_versions[item].conf_path }}/php-fpm.d/dokuwiki_{{ dokuwiki_id }}.conf state=absent
|
|
with_items: "{{ httpd_php_versions.keys() | list }}"
|
|
when: dokuwiki_php_fpm_pool is defined
|
|
notify: restart php-fpm
|
|
|
|
- name: Deploy dokuwiki configuration
|
|
template: src={{ item }}.j2 dest={{ dokuwiki_root_dir }}/web/conf/{{ item }} owner=root group={{ dokuwiki_php_user }} mode=660
|
|
with_items:
|
|
- local.protected.php
|
|
- plugins.protected.php
|
|
|
|
- name: Check if local.php exists
|
|
stat: path={{ dokuwiki_root_dir }}/web/conf/local.php
|
|
register: dokuwiki_local_php
|
|
|
|
- name: Set default values
|
|
template: src=local.php.j2 dest={{ dokuwiki_root_dir }}/web/conf/local.php
|
|
when: not dokuwiki_local_php.stat.exists
|
|
|
|
- name: Deploy htaccess
|
|
template: src=htaccess.j2 dest={{ dokuwiki_root_dir }}/web/.htaccess
|
|
|
|
- name: Set correct SElinux context
|
|
sefcontext:
|
|
target: "{{ dokuwiki_root_dir }}(/.*)?"
|
|
setype: httpd_sys_content_t
|
|
state: present
|
|
when: ansible_selinux.status == 'enabled'
|
|
|
|
- name: Set optimal permissions
|
|
command: "{{ dokuwiki_root_dir }}/perms.sh"
|
|
changed_when: False
|
|
|
|
- include: filebeat.yml
|
|
...
|
|
|