library/roles/ghn-gcore/ghn-gcore-maintenance: role that manages a cron job that restarts the gcore service.

library/roles/ghn-gcore/ghn-gcoreboot: Now the start/stop scripts are added into the users's home.
This commit is contained in:
Andrea Dell'Amico 2016-12-14 15:16:24 +01:00
parent 228f85bc88
commit efa1b35719
6 changed files with 97 additions and 19 deletions

View File

@ -0,0 +1,6 @@
---
gcore_maintenance_restart_cron: False
gcore_maintenance_cron_users:
- { user: '{{ d4science_user }}', weekday: "0,2,4", job: "echo '`date`' >/home/{{ d4science_user }}/gcore_service_restart.log ; /home/{{ d4science_user }}/stopContainer.sh >>/home/{{ d4science_user }}/gcore_service_restart.log 2>&1 ; sleep 30 ; /home/{{ d4science_user }}/startContainer.sh >>/home/{{ d4science_user }}/gcore_service_restart.log 2>&1" }

View File

@ -0,0 +1,33 @@
---
- block:
- name: Install a cron job that restarts the registry gCore service
cron: name="Restart the {{ item.user }} gCore service"
minute="{{ item.minute | default(0) }}"
hour="{{ item.hour | default(3) }}"
weekday="{{ item.weekday | default('*') }}"
day="{{ item.day | default('*') }}"
user="{{ item.user }}"
job="{{ item.job }}"
disabled="{{ item.disabled | default(False) }}"
with_items: '{{ gcore_maintenance_cron_users }}'
when:
- gcoreboot_enabled is defined and gcoreboot_enabled
- gcore_maintenance_restart_cron
tags: [ 'gcoreboot', 'gcore_cron' ]
- block:
- name: Remove the cron job that restarts the registry gCore service
cron: name="Restart the {{ item.user }} gCore service"
minute="{{ item.minute | default(0) }}"
hour="{{ item.hour | default(3) }}"
weekday="{{ item.weekday | default('*') }}"
day="{{ item.day | default('*') }}"
user="{{ item.user }}"
job="{{ item.job }}"
disabled="{{ item.disabled | default(False) }}"
state=absent
with_items: '{{ gcore_maintenance_cron_users }}'
when: not gcore_maintenance_restart_cron
tags: [ 'gcoreboot', 'gcore_cron' ]

View File

@ -0,0 +1,5 @@
---
gcoreboot_install: False
gcoreboot_enabled: False
gcoreboot_startcontainer: startContainer.sh
gcoreboot_stopcontainer: stopContainer.sh

View File

@ -0,0 +1,8 @@
#!/bin/bash
cd $HOME
if [ -f .gcorerc ] ; then
. .gcorerc
gcore-start-container
fi

View File

@ -0,0 +1,9 @@
#!/bin/bash
cd $HOME
if [ -f .gcorerc ] ; then
. .gcorerc
gcore-stop-container
fi

View File

@ -1,23 +1,40 @@
---
# Install the gcore boot script
- name: Install the gcore boot script
template: src=gcore.j2 dest=/etc/init.d/{{ item }} owner=root group=root mode=0755
with_items: 'gcore'
when:
- gcoreboot_install
- block:
- name: Install the gcore boot script
template: src=gcore.j2 dest=/etc/init.d/{{ item }} owner=root group=root mode=0755
with_items: 'gcore'
- name: Install the start script inside the users home directory
copy: src={{ gcoreboot_startcontainer }} dest=/home/{{ item }}/{{ gcoreboot_startcontainer }} owner={{ item }} group={{ item }} mode=0755
with_items: '{{ gcore_users }}'
- name: Install the stop script inside the users home directory
copy: src={{ gcoreboot_stopcontainer }} dest=/home/{{ item }}/{{ gcoreboot_stopcontainer }} owner={{ item }} group={{ item }} mode=0755
with_items: '{{ gcore_users }}'
- name: Enable the gcore boot script
file: src=/etc/init.d/{{ item.path }} dest=/etc/{{ item.dest }} state=link
with_items:
- { path: 'gcore', dest: 'rc2.d/S95gcore' }
- { path: 'gcore', dest: 'rc3.d/S95gcore' }
- { path: 'gcore', dest: 'rc0.d/K25gcore' }
- { path: 'gcore', dest: 'rc1.d/K25gcore' }
when: gcoreboot_install
tags: [ 'gcoreboot' ]
- name: Enable the gcore boot script
file:
src=/etc/init.d/{{ item.path }}
dest=/etc/{{ item.dest }}
state=link
with_items:
- { path: 'gcore', dest: 'rc2.d/S95gcore' }
- { path: 'gcore', dest: 'rc3.d/S95gcore' }
- { path: 'gcore', dest: 'rc0.d/K25gcore.d' }
- { path: 'gcore', dest: 'rc1.d/K25gcore' }
when:
- gcoreboot_install
tags: [ 'gcoreboot' ]
- block:
- name: Remove the gcore boot script
file: dest=/etc/init.d/{{ item }} state=absent
with_items: 'gcore'
- name: disable the gcore boot script
file: dest=/etc/{{ item.dest }} state=absent
with_items:
- { path: 'gcore', dest: 'rc2.d/S95gcore' }
- { path: 'gcore', dest: 'rc3.d/S95gcore' }
- { path: 'gcore', dest: 'rc0.d/K25gcore' }
- { path: 'gcore', dest: 'rc1.d/K25gcore' }
when: not gcoreboot_install
tags: [ 'gcoreboot' ]