๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
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.
ansible-playbooks/roles/wikijs/tasks/main.yml

136 lines
2.7 KiB

2 years ago
- name: set wiki_cfg
set_fact:
wiki_cfg: "{{ wiki_default_config | d({}) | combine(wiki_config | d({}), recursive=true) }}"
- name: install nodejs
include_tasks: tasks/install_packages.yml
vars:
package:
- nodejs
- name: create user and group
include_tasks: tasks/create_user.yml
vars:
user:
name: "{{ wiki_user }}"
group: "{{ wiki_group }}"
dir: "{{ wiki_dir }}"
notify: restart wikijs
- name: create wiki dir structure
file:
path: "{{ item }}"
state: directory
owner: "{{ wiki_user }}"
group: "{{ wiki_group }}"
loop:
- "{{ wiki_dir }}"
- name: get latest asset of wikijs
include_tasks: get_lastversion.yml
vars:
package:
name: Requarks/wiki
location: github
assets: true
asset_filter: 'wiki-js.tar.gz$'
file: "{{ wiki_dir }}/last_version"
extract: "{{ wiki_dir }}"
user: "{{ wiki_user }}"
group: "{{ wiki_group }}"
notify: restart wikijs
- name: template config
template:
src: config.j2
dest: "{{ wiki_dir }}/config.yml"
force: yes
mode: 0400
owner: "{{ wiki_user }}"
group: "{{ wiki_group }}"
notify: restart wikijs
- name: template init script
template:
src: init.j2
dest: /etc/init.d/wikijs
force: yes
mode: "+x"
notify: restart wikijs
- block:
- name: change ico favicon
copy:
src: favicon_wiki.ico
dest: "{{ wiki_dir }}/assets/favicon.ico"
mode: 0444
owner: "{{ wiki_user }}"
group: "{{ wiki_group }}"
- name: change png favicons
copy:
src: favicon_wiki.png
dest: "{{ wiki_dir }}/assets/favicons/{{ item }}"
mode: 0444
owner: "{{ wiki_user }}"
group: "{{ wiki_group }}"
loop:
- android-chrome-192x192.png
- android-chrome-256x256.png
- apple-touch-icon.png
- favicon-16x16.png
- favicon-32x32.png
- mstile-150x150.png
when: wiki_custom_icons | d(false) == true
- name: enable trgm extension
include_role:
name: postgres
apply:
delegate_to: "{{ database_hostname }}"
vars:
function: run_query
query:
database: "{{ database_name }}"
text: "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
- name: install and configure nginx
include_role:
name: nginx
vars:
nginx:
servers:
- conf: nginx_server
certs: "{{ host_tls }}"
- name: flush handlers
meta: flush_handlers
- name: add directories to backup plan
include_role:
name: backup
vars:
function: add
backup_items:
- "{{ wiki_dir }}"
- name: enable and start wikijs
service:
name: wikijs
enabled: yes
state: started