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

Merge pull request #304 from jvonau/sugar

Install nodejs correctly
This commit is contained in:
A Holt 2017-10-14 09:06:17 -04:00 committed by GitHub
commit f7ca2fe9a8
2 changed files with 44 additions and 35 deletions

View file

@ -2,42 +2,52 @@
get_url: url={{ iiab_download_url }}/{{ sugarizer_version }}.tar.gz get_url: url={{ iiab_download_url }}/{{ sugarizer_version }}.tar.gz
dest={{ downloads_dir }}/{{ sugarizer_version }}.tar.gz dest={{ downloads_dir }}/{{ sugarizer_version }}.tar.gz
#fixme
- name: Untar it to target location - name: Untar it to target location
command: tar xzf {{ downloads_dir }}/{{ sugarizer_version }}.tar.gz -C {{ sugarizer_location }} command: tar xzf {{ downloads_dir }}/{{ sugarizer_version }}.tar.gz -C {{ sugarizer_location }}
creates="{{ sugarizer_location }}/{{ sugarizer_version }}/index.html"
- name: Create a symbolic link from generic url to version specific location - name: Create a symbolic link from generic url to version specific location
file: dest={{ sugarizer_location }}/sugarizer file: dest={{ sugarizer_location }}/sugarizer
src={{ sugarizer_location }}/{{ sugarizer_version }} src={{ sugarizer_location }}/{{ sugarizer_version }}
state=link state=link
- name: Install sugarizer required packages - name: Install sugarizer required packages - is_debuntu
package: name=nodejs package: name={{ item }}
state=present state=present
# - npm with_items:
when: internet_available - node-gyp
when: internet_available and is_debuntu
- name: Install npm non debian - name: Install npm non is_debuntu
package: name=npm package: name={{ item }}
state=present state=present
when: internet_available and not is_debian with_items:
- nodejs
- npm
when: internet_available and not is_debuntu
# attempting to reinstall npn is broken on raspbian 9 # attempting to reinstall npn is broken on raspbian 9
- name: check for npm already installed - name: check for sugarizer already installed
stat: path={{ sugarizer_location }}/sugarizer/server/node_modules stat: path={{ sugarizer_location }}/sugarizer/server/node_modules
register: npm register: npm
- name: set a flag to abort second attempt to install - name: set a flag to abort second attempt to install
set_fact: set_fact:
npm_exists: True npm_exists: True
when: npm.stat.exists is defined and npm.stat.exists when: npm.stat.exists is defined and npm.stat.exists
- name: Install npm on debian -- set up apt sources - name: Set up apt sources on is_debuntu
shell: curl -sL https://deb.nodesource.com/setup_6.x | bash - shell: curl -sL https://deb.nodesource.com/setup_6.x | bash -
when: internet_available and is_debian and not npm_exists when: internet_available and is_debuntu
- name: Actually get it installed - name: Actually get it installed on is_debuntu
command: apt-get install -y npm package: name={{ item }}
when: internet_available and is_debian and not npm_exists state=present
with_items:
- nodejs
- npm
when: internet_available and is_debuntu
- name: Create systemd files and copy our ini file - name: Create systemd files and copy our ini file
template: src={{ item.src }} template: src={{ item.src }}
@ -46,7 +56,7 @@
group=root group=root
mode=0644 mode=0644
with_items: with_items:
# - { src: 'sugarizer.service.j2' , dest: '/etc/systemd/system/sugarizer.service'} - { src: 'sugarizer.service.j2' , dest: '/etc/systemd/system/sugarizer.service'}
- { src: 'sugarizer.ini' , dest: '{{ sugarizer_location }}/sugarizer/server' } - { src: 'sugarizer.ini' , dest: '{{ sugarizer_location }}/sugarizer/server' }
# - { src: 'sugarizer.conf' , dest: '/etc/apache2/sites-available' } # - { src: 'sugarizer.conf' , dest: '/etc/apache2/sites-available' }
@ -55,35 +65,34 @@
# dest=/etc/apache2/sites-enabled/sugarizer.conf # dest=/etc/apache2/sites-enabled/sugarizer.conf
# state=link # state=link
- name: Create the express framework for node.js - name: Create the express framework for node.js - ALL less F18
shell: npm install shell: npm install
args: args:
chdir: "{{ sugarizer_location }}/sugarizer/server" chdir: "{{ sugarizer_location }}/sugarizer/server"
creates: "{{ sugarizer_location }}/sugarizer/server/node_modules" creates: "{{ sugarizer_location }}/sugarizer/server/node_modules"
when: not is_F18 when: not is_F18 and not npm_exists
- name: Create the express framework for node.js - name: Create the express framework for node.js - F18
shell: npm install shell: npm install
args: args:
chdir: "{{ sugarizer_location }}/sugarizer/server" chdir: "{{ sugarizer_location }}/sugarizer/server"
when: is_F18 when: is_F18 and not npm_exists
#- name: enable services - name: enable services - All
# service: name={{ item.name }} service: name={{ item.name }}
# enabled=yes enabled=yes
# state=restarted state=restarted
# with_items: with_items:
# - { name: sugarizer } - { name: sugarizer }
# when: sugarizer_enabled when: sugarizer_enabled
- name: disable services - All
#- name: disable services service: name={{ item.name }}
# service: name={{ item.name }} enabled=no
# enabled=no state=stopped
# state=stopped with_items:
# with_items: - { name: sugarizer }
# - { name: sugarizer } when: not sugarizer_enabled
# when: not sugarizer_enabled
- name: add sugarizer to service list - name: add sugarizer to service list
ini_file: dest='{{ service_filelist }}' ini_file: dest='{{ service_filelist }}'

View file

@ -6,7 +6,7 @@ Requires=After=mongodb.service # Requires the mongodb service to run first
WorkingDirectory={{ sugarizer_location }}/sugarizer/server/ WorkingDirectory={{ sugarizer_location }}/sugarizer/server/
ExecStart=/usr/bin/node sugarizer.js ExecStart=/usr/bin/node sugarizer.js
Restart=always Restart=always
RestartSec=10 # Restart service after 10 seconds if node service crashes #RestartSec=10 # Restart service after 10 seconds if node service crashes
StandardOutput=syslog # Output to syslog StandardOutput=syslog # Output to syslog
StandardError=syslog # Output to syslog StandardError=syslog # Output to syslog
SyslogIdentifier=sugarizer SyslogIdentifier=sugarizer