1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Conflicts resolved (against master)

This commit is contained in:
root 2020-02-04 18:50:13 -05:00
commit b15b7933a5
10 changed files with 118 additions and 88 deletions

View file

@ -38,3 +38,5 @@ kiwix_library_xml: "{{ iiab_zim_path }}/library.xml"
# - NEW WAY: cd /opt/iiab/iiab; ./runrole --reinstall kiwix # - NEW WAY: cd /opt/iiab/iiab; ./runrole --reinstall kiwix
# - OLD WAY: rm /opt/iiab/kiwix/bin/kiwix-serve; cd /opt/iiab/iiab; ./runrole kiwix # - OLD WAY: rm /opt/iiab/kiwix/bin/kiwix-serve; cd /opt/iiab/iiab; ./runrole kiwix
kiwix_force_install: False kiwix_force_install: False
kiwix_nginx_timeout: 600
kiwix_threads: 4

View file

@ -1,3 +1,12 @@
location /kiwix { location /kiwix {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_connect_timeout {{ kiwix_nginx_timeout }};
proxy_send_timeout {{ kiwix_nginx_timeout }};
proxy_read_timeout {{ kiwix_nginx_timeout }};
send_timeout {{ kiwix_nginx_timeout }};
proxy_pass http://127.0.0.1:3000; proxy_pass http://127.0.0.1:3000;
} }

View file

@ -4,7 +4,7 @@ After=syslog.target network.target local-fs.target
[Service] [Service]
Type=forking Type=forking
ExecStart={{ iiab_base }}/kiwix/bin/kiwix-serve --daemon --port {{ kiwix_port }} --nolibrarybutton --library {{ kiwix_library_xml }} --urlRootLocation={{ kiwix_url }} ExecStart={{ iiab_base }}/kiwix/bin/kiwix-serve --daemon --port {{ kiwix_port }} --nolibrarybutton --library {{ kiwix_library_xml }} --urlRootLocation={{ kiwix_url }} --threads {{ kiwix_threads }}
TimeoutStartSec=180 TimeoutStartSec=180
Restart=on-abort Restart=on-abort
RestartSec=5s RestartSec=5s

View file

@ -29,4 +29,4 @@ mediawiki_abs_path: "{{ mediawiki_install_path }}/mediawiki-{{ mediawiki_version
mediawiki_url: /wiki mediawiki_url: /wiki
mediawiki_url2: /mediawiki mediawiki_url2: /mediawiki
mediawiki_full_url: "http://{{ iiab_hostname }}.{{ iiab_domain }}{{ mediawiki_url }}" # http://box.lan/wiki mediawiki_full_url: "http://{{ iiab_hostname }}.{{ iiab_domain }}{{ mediawiki_url }}" # http://box.lan/wiki
mediawiki_symlink: w # can also be mwlink. NO slashes as they are suppplied as needed in the code mediawiki_symlink: w # Can also be mwlink. NO slashes as they are supplied as needed in the code

View file

@ -0,0 +1,12 @@
- name: Enable http://box{{ mediawiki_url }} via Apache # http://box/wiki
command: a2ensite mediawiki.conf
when: mediawiki_enabled | bool
- name: Disable http://box{{ mediawiki_url }} via Apache # http://box/wiki
command: a2dissite mediawiki.conf
when: not mediawiki_enabled
- name: Restart '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -1,62 +0,0 @@
# Apache
- name: Enable http://box{{ mediawiki_url }} via Apache # i.e. http://box/wiki
command: a2ensite mediawiki.conf
when: apache_install and mediawiki_enabled
- name: Disable http://box{{ mediawiki_url }} via Apache
command: a2dissite mediawiki.conf
when: apache_install and not mediawiki_enabled
- name: Restart Apache systemd service ({{ apache_service }})
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted
when: apache_enabled | bool
# NGINX
- name: Enable http://box{{ mediawiki_url }} & http://box{{ mediawiki_url2 }} via NGINX, by installing {{ nginx_conf_dir }}/mediawiki-nginx.conf from template
template:
src: mediawiki-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/mediawiki-nginx.conf"
when: nginx_install and mediawiki_enabled
- name: Disable http://box{{ mediawiki_url }} & http://box{{ mediawiki_url2 }} via NGINX, by removing {{ nginx_conf_dir }}/mediawiki-nginx.conf
file:
path: "{{ nginx_conf_dir }}/mediawiki-nginx.conf"
state: absent
when: nginx_install and not mediawiki_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted
when: nginx_enabled | bool
- name: Add 'mediawiki' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
section: mediawiki
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: MediaWiki
- option: description
value: '"MediaWiki is a blog and web site management application, from the people who create Wikipedia."'
- option: mediawiki_src
value: "{{ mediawiki_src }}"
- option: mediawiki_abs_path
value: "{{ mediawiki_abs_path }}"
- option: mediawiki_db_name
value: "{{ mediawiki_db_name }}"
- option: mediawiki_db_user
value: "{{ mediawiki_db_user }}"
- option: mediawiki_url
value: "{{ mediawiki_url }}"
- option: mediawiki_full_url
value: "{{ mediawiki_full_url }}"
- option: mediawiki_enabled
value: "{{ mediawiki_enabled }}"

View file

@ -8,43 +8,43 @@
- name: Download {{ mediawiki_download_base_url }}/{{ mediawiki_src }} to {{ downloads_dir }} - name: Download {{ mediawiki_download_base_url }}/{{ mediawiki_src }} to {{ downloads_dir }}
get_url: get_url:
url: "{{ mediawiki_download_base_url }}/{{ mediawiki_src }}" url: "{{ mediawiki_download_base_url }}/{{ mediawiki_src }}"
dest: "{{ downloads_dir }}" dest: "{{ downloads_dir }}" # /opt/iiab/downloads
timeout: "{{ download_timeout }}" timeout: "{{ download_timeout }}"
#force: yes #force: yes
#backup: yes #backup: yes
when: internet_available | bool when: internet_available | bool
- name: Unpack it to permanent location {{ mediawiki_abs_path }} - name: Unarchive (unpack) it to permanent location {{ mediawiki_abs_path }} ({{ apache_user }}:{{ apache_user }}, u+rw,g+r,o+r)
unarchive: unarchive:
src: "{{ downloads_dir }}/{{ mediawiki_src }}" src: "{{ downloads_dir }}/{{ mediawiki_src }}"
dest: "{{ mediawiki_install_path }}" dest: "{{ mediawiki_install_path }}" # /library
owner: "{{ apache_user }}" owner: "{{ apache_user }}"
group: "{{ apache_user }}" group: "{{ apache_user }}"
mode: u+rw,g+r,o+r # '0755' forced executable bits on files mode: u+rw,g+r,o+r # '0755' forced executable bits on files
keep_newer: yes keep_newer: yes
- name: Create symlink {{ doc_root }}/{{ mediawiki_symlink }} -> {{ mediawiki_abs_path }} - name: Symlink {{ doc_root }}/{{ mediawiki_symlink }} -> {{ mediawiki_abs_path }}
file: file:
src: "{{ mediawiki_abs_path }}" src: "{{ mediawiki_abs_path }}" # /library/mediawiki-1.XY.Z
path: "{{ doc_root }}/{{ mediawiki_symlink }}" path: "{{ doc_root }}/{{ mediawiki_symlink }}" # /library/www/html/w
state: link state: link
- name: Start MySQL systemd service ({{ mysql_service }}) so we can create db - name: Start MySQL systemd service ({{ mysql_service }}) so we can create db
systemd: systemd:
state: started
name: "{{ mysql_service }}" name: "{{ mysql_service }}"
state: started
- name: Create MySQL database {{ mediawiki_db_name }} - name: Create MySQL database {{ mediawiki_db_name }}
mysql_db: mysql_db:
name: "{{ mediawiki_db_name }}" name: "{{ mediawiki_db_name }}" # iiab_mediawiki
state: present #state: present
- name: Create MySQL database user {{ mediawiki_db_user }} with password, and permissions to above db - name: Create MySQL database user {{ mediawiki_db_user }} with password, and permissions to above db
mysql_user: mysql_user:
name: "{{ mediawiki_db_user }}" name: "{{ mediawiki_db_user }}" # iiab_mediawiki_user
password: "{{ mediawiki_db_user_password }}" password: "{{ mediawiki_db_user_password }}"
priv: "{{ mediawiki_db_name }}.*:ALL,GRANT" priv: "{{ mediawiki_db_name }}.*:ALL,GRANT"
state: present #state: present
- name: Configure MediaWiki, if {{ mediawiki_abs_path }}/LocalSettings.php doesn't exist - name: Configure MediaWiki, if {{ mediawiki_abs_path }}/LocalSettings.php doesn't exist
shell: > shell: >
@ -61,29 +61,29 @@
"{{ mediawiki_site_name }}" "{{ mediawiki_site_name }}"
"{{ mediawiki_admin_user }}" "{{ mediawiki_admin_user }}"
args: args:
chdir: "{{ mediawiki_abs_path }}" chdir: "{{ mediawiki_abs_path }}" # /library/mediawiki-1.XY.Z
creates: "{{ mediawiki_abs_path }}/LocalSettings.php" creates: "{{ mediawiki_abs_path }}/LocalSettings.php"
- name: Configure wgArticlePath variable in {{ mediawiki_abs_path }}/LocalSettings.php - name: Configure wgArticlePath variable in {{ mediawiki_abs_path }}/LocalSettings.php
lineinfile: lineinfile:
dest: "{{ mediawiki_abs_path }}/LocalSettings.php" path: "{{ mediawiki_abs_path }}/LocalSettings.php" # /library/mediawiki-1.XY.Z
line: '$wgArticlePath = "/wiki/$1";' line: '$wgArticlePath = "/wiki/$1";'
- name: Configure $wgUsePathInfo variable in {{ mediawiki_abs_path }}/LocalSettings.php - name: Configure $wgUsePathInfo variable in {{ mediawiki_abs_path }}/LocalSettings.php
lineinfile: lineinfile:
dest: "{{ mediawiki_abs_path }}/LocalSettings.php" path: "{{ mediawiki_abs_path }}/LocalSettings.php" # /library/mediawiki-1.XY.Z
line: '$wgUsePathInfo = true;' line: '$wgUsePathInfo = true;'
- name: Configure $wgServer variable in {{ mediawiki_abs_path }}/LocalSettings.php - name: Configure $wgServer variable in {{ mediawiki_abs_path }}/LocalSettings.php
lineinfile: lineinfile:
dest: "{{ mediawiki_abs_path }}/LocalSettings.php" path: "{{ mediawiki_abs_path }}/LocalSettings.php" # /library/mediawiki-1.XY.Z
regexp: '^\$wgServer =' regexp: '^\$wgServer ='
line: '$wgServer = "//" . $_SERVER["HTTP_HOST"];' line: '$wgServer = "//" . $_SERVER["HTTP_HOST"];'
- name: Install /etc/{{ apache_conf_dir }}/mediawiki.conf from template, for http://box{{ mediawiki_url }} via Apache - name: Install /etc/{{ apache_conf_dir }}/mediawiki.conf from template, for http://box{{ mediawiki_url }} via Apache
template: template:
src: mediawiki.conf.j2 src: mediawiki.conf.j2
dest: "/etc/{{ apache_conf_dir }}/mediawiki.conf" dest: "/etc/{{ apache_conf_dir }}/mediawiki.conf" # apache2/sites-available on debuntu
# RECORD MediaWiki AS INSTALLED # RECORD MediaWiki AS INSTALLED

View file

@ -1,7 +1,60 @@
- name: Install MediaWiki {{ mediawiki_version }} # "How do i fail a task in Ansible if the variable contains a boolean value?
include_tasks: install.yml # I want to perform input validation for Ansible playbooks"
when: mediawiki_install and not mediawiki_installed is defined # https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
- name: Enable MediaWiki # We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
include_tasks: enable.yml # to re-check whether vars are defined here. As Ansible vars cannot be unset:
when: mediawiki_install or mediawiki_installed is defined # https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: Assert that "mediawiki_install is sameas true" (boolean not string etc)
assert:
that: mediawiki_install is sameas true
fail_msg: "PLEASE SET 'mediawiki_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Assert that "mediawiki_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: mediawiki_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'mediawiki_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Install MediaWiki {{ mediawiki_version }} if 'mediawiki_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: mediawiki_installed is undefined
- name: Enable/Disable/Restart Apache if primary
include_tasks: apache.yml
when: not nginx_enabled
- name: Enable/Disable/Restart NGINX if primary
include_tasks: nginx.yml
when: nginx_enabled | bool
- name: Add 'mediawiki' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: mediawiki
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: MediaWiki
- option: description
value: '"MediaWiki is a blog and web site management application, from the people who create Wikipedia."'
- option: mediawiki_src
value: "{{ mediawiki_src }}"
- option: mediawiki_abs_path
value: "{{ mediawiki_abs_path }}"
- option: mediawiki_db_name
value: "{{ mediawiki_db_name }}"
- option: mediawiki_db_user
value: "{{ mediawiki_db_user }}"
- option: mediawiki_url
value: "{{ mediawiki_url }}"
- option: mediawiki_full_url
value: "{{ mediawiki_full_url }}"
- option: mediawiki_enabled
value: "{{ mediawiki_enabled }}"

View file

@ -0,0 +1,16 @@
- name: Enable http://box{{ mediawiki_url }} & http://box{{ mediawiki_url2 }} via NGINX, by installing {{ nginx_conf_dir }}/mediawiki-nginx.conf from template # http://box/wiki & http://box/mediawiki
template:
src: mediawiki-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/mediawiki-nginx.conf" # /etc/nginx.conf.d
when: mediawiki_enabled | bool
- name: Disable http://box{{ mediawiki_url }} & http://box{{ mediawiki_url2 }} via NGINX, by removing {{ nginx_conf_dir }}/mediawiki-nginx.conf # http://box/wiki & http://box/mediawiki
file:
path: "{{ nginx_conf_dir }}/mediawiki-nginx.conf" # /etc/nginx.conf.d
state: absent
when: not mediawiki_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted

View file

@ -51,7 +51,7 @@
value: Node.js value: Node.js
- option: description - option: description
value: '"Node.js is a JavaScript runtime environment built on Chrome''s V8 JavaScript engine, that executes JavaScript code outside of a browser."' value: '"Node.js is a JavaScript runtime environment built on Chrome''s V8 JavaScript engine, that executes JavaScript code outside of a browser."'
- option: install - option: nodejs_install
value: "{{ nodejs_install }}" value: "{{ nodejs_install }}"
- option: enabled - option: nodejs_enabled
value: "{{ nodejs_enabled }}" value: "{{ nodejs_enabled }}"