mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Merge pull request #888 from holta/sugarizer-1.0
sugarizer-server tweaks arising since Sugarizer 1.0
This commit is contained in:
commit
2873b07595
5 changed files with 144 additions and 116 deletions
|
@ -1,6 +1,7 @@
|
|||
- name: Install mongodb required packages
|
||||
package: name={{ item }}
|
||||
state=present
|
||||
- name: Install MongoDB required packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- mongodb-server
|
||||
- mongodb
|
||||
|
@ -8,50 +9,55 @@
|
|||
tags:
|
||||
- download
|
||||
|
||||
- name: create the data directory for mongodb
|
||||
file: state=directory
|
||||
path={{ item.path }}
|
||||
owner=mongodb
|
||||
- name: Create the data directory for MongoDB
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ item.path }}"
|
||||
owner: mongodb
|
||||
with_items:
|
||||
- { path: '/var/run/mongodb' }
|
||||
- { path: '/library/dbdata/mongodb' }
|
||||
- { path: '/var/log/mongodb' }
|
||||
- { path: '/var/run/mongodb' }
|
||||
- { path: '/library/dbdata/mongodb' }
|
||||
- { path: '/var/log/mongodb' }
|
||||
|
||||
- name: Move required files
|
||||
template: src={{ item.src }}
|
||||
dest={{ item.dest }}
|
||||
owner=root
|
||||
group=root
|
||||
mode=0644
|
||||
- name: Position /etc/mongod.conf and mongodb.service
|
||||
template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
with_items:
|
||||
- { src: 'mongodb.service' , dest: '/etc/systemd/system/' }
|
||||
- { src: 'mongod.conf' , dest: '/etc/mongod.conf'}
|
||||
- { src: 'mongodb.service' , dest: '/etc/systemd/system/' }
|
||||
- { src: 'mongod.conf' , dest: '/etc/mongod.conf'}
|
||||
|
||||
- name: enable services
|
||||
service: name={{ item.name }}
|
||||
enabled=yes
|
||||
state=restarted
|
||||
- name: Restart service if enabled
|
||||
service:
|
||||
name: "{{ item.name }}"
|
||||
enabled: yes
|
||||
state: restarted
|
||||
with_items:
|
||||
- { name: mongodb }
|
||||
- { name: mongodb }
|
||||
when: mongodb_enabled
|
||||
|
||||
- name: disable services
|
||||
service: name={{ item.name }}
|
||||
enabled=no
|
||||
state=stopped
|
||||
- name: Stop service if not enabled
|
||||
service:
|
||||
name: "{{ item.name }}"
|
||||
enabled: no
|
||||
state: stopped
|
||||
with_items:
|
||||
- { name: mongodb }
|
||||
- { name: mongodb }
|
||||
when: not mongodb_enabled
|
||||
|
||||
- name: add mongodb to service list
|
||||
ini_file: dest="{{ service_filelist }}"
|
||||
section=mongodb
|
||||
option="{{ item.option }}"
|
||||
value="{{ item.value }}"
|
||||
- name: Add 'mongodb' to list of services at /etc/iiab/iiab.ini
|
||||
ini_file:
|
||||
dest: "{{ service_filelist }}"
|
||||
section: mongodb
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ item.value }}"
|
||||
with_items:
|
||||
- option: name
|
||||
value: MongoDB
|
||||
- option: description
|
||||
value: '"MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling."'
|
||||
- option: enabled
|
||||
value: "{{ mongodb_enabled }}"
|
||||
- option: name
|
||||
value: MongoDB
|
||||
- option: description
|
||||
value: '"MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling."'
|
||||
- option: enabled
|
||||
value: "{{ mongodb_enabled }}"
|
||||
|
|
|
@ -6,8 +6,7 @@ After=syslog.target network.target
|
|||
Type=simple
|
||||
User=mongodb
|
||||
Group=mongodb
|
||||
ExecStart=/usr/bin/mongod -f /etc/mongod.conf
|
||||
ExecStart=/usr/bin/mongod -f /etc/mongod.conf
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
sugarizer_install: True
|
||||
sugarizer_enabled: False
|
||||
sugarizer_location: /opt/iiab
|
||||
sugarizer_version: 'sugarizer-1.0'
|
||||
sugarizer_server_version: 'sugarizer-server-1.0'
|
||||
npm_exists: False
|
||||
|
||||
sugarizer_location: "{{ iiab_base }}" # /opt/iiab
|
||||
|
||||
sugarizer_version: sugarizer-1.0
|
||||
sugarizer_git_version: v1.0.1
|
||||
# PLEASE HELP MONITOR https://github.com/llaske/sugarizer/releases FOR
|
||||
# STABLE/OFFICIAL RELEASES!
|
||||
|
||||
sugarizer_server_version: sugarizer-server-1.0
|
||||
sugarizer_server_git_version: master
|
||||
# CLONING SUGARIZER-SERVER'S MASTER BRANCH IS NOT A LONG-TERM SOLUTION,
|
||||
# SO LET'S MONITOR https://github.com/llaske/sugarizer-server/releases
|
||||
# FOR A MORE STABLE/OFFICIAL RELEASE DURING MID-2018!
|
||||
|
||||
node_modules_exists: False
|
||||
|
|
|
@ -1,63 +1,74 @@
|
|||
- name: Wipe any previous sugarizer installation
|
||||
# 0. CLEAN UP PRIOR VERSIONS OF SUGARIZER (NEEDS WORK!)
|
||||
|
||||
- name: Wipe /library/www/html/sugarizer* if sugarizer-1.0
|
||||
shell: "rm -rf {{ doc_root }}/sugarizer*"
|
||||
when: sugarizer_version == "sugarizer-1.0"
|
||||
|
||||
- name: Download latest stable Sugarizer from location we control
|
||||
get_url:
|
||||
url: "{{ iiab_download_url }}/{{ sugarizer_version }}.tar.gz"
|
||||
dest: "{{ downloads_dir }}/{{ sugarizer_version }}.tar.gz"
|
||||
timeout: "{{ download_timeout }}"
|
||||
# 1. DOWNLOAD /opt/iiab/sugarizer
|
||||
|
||||
- name: Clone llaske/sugarizer ({{ sugarizer_git_version }}) from GitHub to /opt/iiab
|
||||
git:
|
||||
repo: https://github.com/llaske/sugarizer
|
||||
dest: "{{ sugarizer_location }}/{{ sugarizer_version }}"
|
||||
version: "{{ sugarizer_git_version }}"
|
||||
force: yes
|
||||
when: internet_available
|
||||
|
||||
- name: Untar to {{ sugarizer_version }}
|
||||
unarchive:
|
||||
src: "{{ downloads_dir }}/{{ sugarizer_version }}.tar.gz"
|
||||
dest: "{{ sugarizer_location }}"
|
||||
creates: "{{ sugarizer_location }}/{{ sugarizer_version }}/index.html"
|
||||
# command: tar xzf {{ downloads_dir }}/{{ sugarizer_version }}.tar.gz -C {{ sugarizer_location }}
|
||||
# creates="{{ sugarizer_location }}/{{ sugarizer_version }}/index.html"
|
||||
|
||||
- name: Download latest stable Server from location we control
|
||||
get_url:
|
||||
url: "{{ iiab_download_url }}/{{ sugarizer_server_version }}.tar.gz"
|
||||
dest: "{{ downloads_dir }}/{{ sugarizer_server_version }}.tar.gz"
|
||||
timeout: "{{ download_timeout }}"
|
||||
when: internet_available
|
||||
|
||||
- name: Untar to /{{ sugarizer_version }}
|
||||
unarchive:
|
||||
src: "{{ downloads_dir }}/{{ sugarizer_version }}.tar.gz"
|
||||
dest: "{{ sugarizer_location }}"
|
||||
creates: "{{ sugarizer_location }}/{{ sugarizer_version }}/index.html"
|
||||
- name: Create symbolic link /library/www/html/sugarizer
|
||||
- name: Create symbolic link /opt/iiab/sugarizer -> /opt/iiab/{{ sugarizer_version }}
|
||||
file:
|
||||
src: "{{ sugarizer_location }}/{{ sugarizer_version }}"
|
||||
dest: "{{ sugarizer_location }}/sugarizer"
|
||||
state: link
|
||||
|
||||
- name: Untar to /library/www/html/{{ sugarizer_server_version }}
|
||||
unarchive:
|
||||
src: "{{ downloads_dir }}/{{ sugarizer_server_version }}.tar.gz"
|
||||
dest: "{{ sugarizer_location }}"
|
||||
creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/index.html"
|
||||
- name: Create symbolic link /library/www/html/sugarizer
|
||||
# 2. DOWNLOAD /opt/iiab/sugarizer-server
|
||||
|
||||
# July 2018: http://download.iiab.io/packages/sugarizer-server-1.0.tar.gz
|
||||
# was flawed, as documented at:
|
||||
# https://github.com/iiab/iiab/pull/814#issuecomment-404211098
|
||||
# Versions of MongoDB, npm (& Node.js ?) matter! Sugarizer 1.0 Context:
|
||||
# https://github.com/iiab/iiab/issues/798
|
||||
# Going forward let's "git clone" IIAB's preferred version, of sugarizer
|
||||
# AND sugarizer-server, as specified in roles/sugarizer/defaults/main.yml
|
||||
|
||||
- name: Clone llaske/sugarizer-server ({{ sugarizer_server_git_version }}) from GitHub to /opt/iiab
|
||||
git:
|
||||
repo: https://github.com/llaske/sugarizer-server
|
||||
dest: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
|
||||
version: "{{ sugarizer_server_git_version }}"
|
||||
force: yes
|
||||
when: internet_available
|
||||
|
||||
- name: Create symbolic link /opt/iiab/sugarizer-server -> /opt/iiab/{ sugarizer_server_version }}
|
||||
file:
|
||||
src: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
|
||||
dest: "{{ sugarizer_location }}/sugarizer-server"
|
||||
state: link
|
||||
|
||||
- name: Set up Node.js 6.x apt sources (debuntu)
|
||||
shell: curl -sL https://deb.nodesource.com/setup_6.x | bash -
|
||||
# 3. INSTALL A GOOD VERSION OF Node.js AND npm
|
||||
|
||||
# Both Raspbian and Debian 9 STILL need this approach as of July 2018,
|
||||
# as documented at https://github.com/iiab/iiab/issues/798#issuecomment-404324530
|
||||
- name: Set up Node.js 8.x apt sources (debuntu but avoid ubuntu-18)
|
||||
shell: curl -sL https://deb.nodesource.com/setup_8.x | bash -
|
||||
when: internet_available and is_debuntu and not is_ubuntu_18
|
||||
|
||||
- name: Install latest Node.js which includes /usr/bin/npm (debuntu)
|
||||
- name: Install latest Node.js which includes /usr/bin/npm (debuntu but avoid ubuntu-18)
|
||||
package:
|
||||
name: nodejs
|
||||
# name: nodejs=8.x
|
||||
state: latest
|
||||
# package: name=nodejs=6.*
|
||||
# state=present
|
||||
# state: present
|
||||
when: internet_available and is_debuntu and not is_ubuntu_18
|
||||
|
||||
- name: Install Node.js and npm (ubuntu-18)
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: latest
|
||||
when: internet_available and is_ubuntu_18
|
||||
with_items:
|
||||
- nodejs
|
||||
- npm
|
||||
|
||||
- name: Install npm (OS's other than debuntu)
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
|
@ -67,26 +78,35 @@
|
|||
- nodejs
|
||||
- npm
|
||||
|
||||
- name: Install npm (ubuntu-18)
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: latest
|
||||
when: internet_available and is_ubuntu_18
|
||||
with_items:
|
||||
- npm
|
||||
- nodejs
|
||||
# 4. RUN "npm install" TO POPULATE ~35MB /opt/iiab/sugarizer-server/node_modules
|
||||
|
||||
# attempting to reinstall npm is broken on Raspbian 9
|
||||
- name: Check for Sugarizer already installed
|
||||
# Re-running "npm install" fails on Raspbian 9 if not other OS's
|
||||
- name: Check for /opt/iiab/{{ sugarizer_server_version }}/node_modules
|
||||
stat:
|
||||
path: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules"
|
||||
register: npm
|
||||
register: nmtest
|
||||
ignore_errors: true
|
||||
|
||||
- name: Set a flag to abort second attempt to install
|
||||
- name: Set a flag to prevent re-running of "npm install"
|
||||
set_fact:
|
||||
npm_exists: True
|
||||
when: npm.stat is defined and npm.stat.exists
|
||||
node_modules_exists: True
|
||||
when: nmtest.stat is defined and nmtest.stat.exists
|
||||
|
||||
- name: Create the express framework for Node.js (OS's other than Fedora 18)
|
||||
shell: npm install
|
||||
args:
|
||||
chdir: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
|
||||
creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules"
|
||||
#creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/server/node_modules"
|
||||
when: not is_F18 and not node_modules_exists
|
||||
|
||||
- name: Create the express framework for Node.js (Fedora 18)
|
||||
shell: npm install
|
||||
args:
|
||||
chdir: "{{ sugarizer_location }}/sugarizer/server"
|
||||
when: is_F18 and not node_modules_exists
|
||||
|
||||
# 5. PLACE CONFIG FILES
|
||||
|
||||
- name: Create systemd files and copy our ini file
|
||||
template:
|
||||
|
@ -96,27 +116,17 @@
|
|||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- { src: 'sugarizer.service.j2' , dest: '/etc/systemd/system/sugarizer.service', mode: '0644' }
|
||||
- { src: 'sugarizer.ini' , dest: '{{ sugarizer_location }}/{{ sugarizer_server_version }}/env/sugarizer.ini', mode: '0644' }
|
||||
- { src: 'sugarizer.conf' , dest: '/etc/apache2/sites-available',mode: '0644' }
|
||||
- { src: 'sugarizer.service.j2', dest: '/etc/systemd/system/sugarizer.service', mode: '0644' }
|
||||
- { src: 'sugarizer.ini', dest: '{{ sugarizer_location }}/{{ sugarizer_server_version }}/env/sugarizer.ini', mode: '0644' }
|
||||
- { src: 'sugarizer.conf', dest: '/etc/apache2/sites-available', mode: '0644' }
|
||||
|
||||
- name: Create the symlink enabling the rewrite
|
||||
file: src=/etc/apache2/sites-available/sugarizer.conf
|
||||
dest=/etc/apache2/sites-enabled/sugarizer.conf
|
||||
state=link
|
||||
- name: Create symlink for short URL http://box/sugarizer
|
||||
file:
|
||||
src: /etc/apache2/sites-available/sugarizer.conf
|
||||
dest: /etc/apache2/sites-enabled/sugarizer.conf
|
||||
state: link
|
||||
|
||||
- name: Create the express framework for Node.js (OS's other than Fedora 18)
|
||||
shell: npm install
|
||||
args:
|
||||
chdir: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
|
||||
creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/server/node_modules"
|
||||
when: not is_F18 and not npm_exists
|
||||
|
||||
- name: Create the express framework for Node.js (Fedora 18)
|
||||
shell: npm install
|
||||
args:
|
||||
chdir: "{{ sugarizer_location }}/sugarizer/server"
|
||||
when: is_F18 and not npm_exists
|
||||
# 6. RESTART/STOP SYSTEMD SERVICE
|
||||
|
||||
- name: Enable services (all OS's)
|
||||
service:
|
||||
|
@ -124,6 +134,7 @@
|
|||
enabled: yes
|
||||
state: restarted
|
||||
with_items:
|
||||
- { name: mongodb }
|
||||
- { name: sugarizer }
|
||||
when: sugarizer_enabled
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ path = ../sugarizer/
|
|||
server = localhost
|
||||
port = 27018
|
||||
name = sugarizer
|
||||
waitdb = 1
|
||||
|
||||
[presence]
|
||||
port = 8039
|
||||
|
|
Loading…
Add table
Reference in a new issue