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

Merge pull request #97 from iiab/master

sync from iiab/iiab
This commit is contained in:
A Holt 2018-07-11 23:27:14 -04:00 committed by GitHub
commit 0f9848a378
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 146 additions and 118 deletions

View file

@ -1,6 +1,7 @@
- name: Install mongodb required packages - name: Install MongoDB required packages
package: name={{ item }} package:
state=present name: "{{ item }}"
state: present
with_items: with_items:
- mongodb-server - mongodb-server
- mongodb - mongodb
@ -8,50 +9,55 @@
tags: tags:
- download - download
- name: create the data directory for mongodb - name: Create the data directory for MongoDB
file: state=directory file:
path={{ item.path }} state: directory
owner=mongodb path: "{{ item.path }}"
owner: mongodb
with_items: with_items:
- { path: '/var/run/mongodb' } - { path: '/var/run/mongodb' }
- { path: '/library/dbdata/mongodb' } - { path: '/library/dbdata/mongodb' }
- { path: '/var/log/mongodb' } - { path: '/var/log/mongodb' }
- name: Move required files - name: Position /etc/mongod.conf and mongodb.service
template: src={{ item.src }} template:
dest={{ item.dest }} src: "{{ item.src }}"
owner=root dest: "{{ item.dest }}"
group=root owner: root
mode=0644 group: root
mode: 0644
with_items: with_items:
- { src: 'mongodb.service' , dest: '/etc/systemd/system/' } - { src: 'mongodb.service' , dest: '/etc/systemd/system/' }
- { src: 'mongod.conf' , dest: '/etc/mongod.conf'} - { src: 'mongod.conf' , dest: '/etc/mongod.conf'}
- name: enable services - name: Restart service if enabled
service: name={{ item.name }} service:
enabled=yes name: "{{ item.name }}"
state=restarted enabled: yes
state: restarted
with_items: with_items:
- { name: mongodb } - { name: mongodb }
when: mongodb_enabled when: mongodb_enabled
- name: disable services - name: Stop service if not enabled
service: name={{ item.name }} service:
enabled=no name: "{{ item.name }}"
state=stopped enabled: no
state: stopped
with_items: with_items:
- { name: mongodb } - { name: mongodb }
when: not mongodb_enabled when: not mongodb_enabled
- name: add mongodb to service list - name: Add 'mongodb' to list of services at /etc/iiab/iiab.ini
ini_file: dest="{{ service_filelist }}" ini_file:
section=mongodb dest: "{{ service_filelist }}"
option="{{ item.option }}" section: mongodb
value="{{ item.value }}" option: "{{ item.option }}"
value: "{{ item.value }}"
with_items: with_items:
- option: name - option: name
value: MongoDB value: MongoDB
- option: description - option: description
value: '"MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling."' value: '"MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling."'
- option: enabled - option: enabled
value: "{{ mongodb_enabled }}" value: "{{ mongodb_enabled }}"

View file

@ -6,8 +6,7 @@ After=syslog.target network.target
Type=simple Type=simple
User=mongodb User=mongodb
Group=mongodb Group=mongodb
ExecStart=/usr/bin/mongod -f /etc/mongod.conf ExecStart=/usr/bin/mongod -f /etc/mongod.conf
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,6 +1,17 @@
sugarizer_install: True sugarizer_install: True
sugarizer_enabled: False sugarizer_enabled: False
sugarizer_location: /opt/iiab
sugarizer_version: 'sugarizer-1.0' sugarizer_location: "{{ iiab_base }}" # /opt/iiab
sugarizer_server_version: 'sugarizer-server-1.0'
npm_exists: False 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

View file

@ -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 installing sugarizer-1.0
shell: "rm -rf {{ doc_root }}/sugarizer*" shell: "rm -rf {{ doc_root }}/sugarizer*"
when: sugarizer_version == "sugarizer-1.0" when: sugarizer_version == "sugarizer-1.0"
- name: Download latest stable Sugarizer from location we control # 1. DOWNLOAD /opt/iiab/sugarizer
get_url:
url: "{{ iiab_download_url }}/{{ sugarizer_version }}.tar.gz" - name: Clone llaske/sugarizer ({{ sugarizer_git_version }}) from GitHub to /opt/iiab
dest: "{{ downloads_dir }}/{{ sugarizer_version }}.tar.gz" git:
timeout: "{{ download_timeout }}" repo: https://github.com/llaske/sugarizer
dest: "{{ sugarizer_location }}/{{ sugarizer_version }}"
version: "{{ sugarizer_git_version }}"
force: yes
when: internet_available when: internet_available
- name: Untar to {{ sugarizer_version }} - name: Create symbolic link /opt/iiab/sugarizer -> /opt/iiab/{{ 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
file: file:
src: "{{ sugarizer_location }}/{{ sugarizer_version }}" src: "{{ sugarizer_location }}/{{ sugarizer_version }}"
dest: "{{ sugarizer_location }}/sugarizer" dest: "{{ sugarizer_location }}/sugarizer"
state: link state: link
- name: Untar to /library/www/html/{{ sugarizer_server_version }} # 2. DOWNLOAD /opt/iiab/sugarizer-server
unarchive:
src: "{{ downloads_dir }}/{{ sugarizer_server_version }}.tar.gz" # July 2018: http://download.iiab.io/packages/sugarizer-server-1.0.tar.gz
dest: "{{ sugarizer_location }}" # was flawed, as documented at:
creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/index.html" # https://github.com/iiab/iiab/pull/814#issuecomment-404211098
- name: Create symbolic link /library/www/html/sugarizer # 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 versions, 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: file:
src: "{{ sugarizer_location }}/{{ sugarizer_server_version }}" src: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
dest: "{{ sugarizer_location }}/sugarizer-server" dest: "{{ sugarizer_location }}/sugarizer-server"
state: link state: link
- name: Set up Node.js 6.x apt sources (debuntu) # 3. INSTALL A GOOD VERSION OF Node.js AND npm
shell: curl -sL https://deb.nodesource.com/setup_6.x | bash -
# 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 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: package:
name: nodejs name: nodejs
# name: nodejs=8.x
state: latest state: latest
# package: name=nodejs=6.* # state: present
# state=present
when: internet_available and is_debuntu and not is_ubuntu_18 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) - name: Install npm (OS's other than debuntu)
package: package:
name: "{{ item }}" name: "{{ item }}"
@ -67,28 +78,37 @@
- nodejs - nodejs
- npm - npm
- name: Install npm (ubuntu-18) # 4. RUN "npm install" TO POPULATE ~35MB /opt/iiab/sugarizer-server/node_modules
package:
name: "{{ item }}"
state: latest
when: internet_available and is_ubuntu_18
with_items:
- npm
- nodejs
# attempting to reinstall npm is broken on Raspbian 9 # Re-running "npm install" fails on Raspbian 9 if not other OS's
- name: Check for Sugarizer already installed - name: Check for /opt/iiab/{{ sugarizer_server_version }}/node_modules
stat: stat:
path: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules" path: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules"
register: npm register: nmtest
ignore_errors: true 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: set_fact:
npm_exists: True node_modules_exists: True
when: npm.stat is defined and npm.stat.exists when: nmtest.stat is defined and nmtest.stat.exists
- name: Create systemd files and copy our ini file - 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: Configure sugarizer.service (systemd), sugarizer.conf (Apache) and sugarizer.ini
template: template:
src: "{{ item.src }}" src: "{{ item.src }}"
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
@ -96,27 +116,17 @@
owner: root owner: root
group: root group: root
with_items: with_items:
- { src: 'sugarizer.service.j2' , dest: '/etc/systemd/system/sugarizer.service', 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.ini', dest: '{{ sugarizer_location }}/{{ sugarizer_server_version }}/env/sugarizer.ini', mode: '0644' }
- { src: 'sugarizer.conf' , dest: '/etc/apache2/sites-available',mode: '0644' } - { src: 'sugarizer.conf', dest: '/etc/apache2/sites-available', mode: '0644' }
- name: Create the symlink enabling the rewrite - name: Create symlink for short URL http://box/sugarizer
file: src=/etc/apache2/sites-available/sugarizer.conf file:
dest=/etc/apache2/sites-enabled/sugarizer.conf src: /etc/apache2/sites-available/sugarizer.conf
state=link dest: /etc/apache2/sites-enabled/sugarizer.conf
state: link
- name: Create the express framework for Node.js (OS's other than Fedora 18) # 6. RESTART/STOP SYSTEMD SERVICE
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
- name: Enable services (all OS's) - name: Enable services (all OS's)
service: service:
@ -124,10 +134,11 @@
enabled: yes enabled: yes
state: restarted state: restarted
with_items: with_items:
- { name: mongodb }
- { name: sugarizer } - { name: sugarizer }
when: sugarizer_enabled when: sugarizer_enabled
- name: Disable services (all OS's) - name: Disable service (all OS's)
service: service:
name: "{{ item.name }}" name: "{{ item.name }}"
enabled: no enabled: no

View file

@ -20,6 +20,7 @@ path = ../sugarizer/
server = localhost server = localhost
port = 27018 port = 27018
name = sugarizer name = sugarizer
waitdb = 1
[presence] [presence]
port = 8039 port = 8039