library/roles/opencpu: Manage options customization.

This commit is contained in:
Andrea Dell'Amico 2016-08-04 17:50:37 +02:00
parent e901c3e214
commit 83720dab17
4 changed files with 42 additions and 1 deletions

View File

@ -2,6 +2,7 @@
# https://www.opencpu.org/download.html
# It installs a local apache instance
opencpu_install: True
opencpu_enabled: True
opencpu_version: 1.5
opencpu_repo: 'ppa:opencpu/opencpu-{{ opencpu_version }}'
opencpu_pkg_state: latest
@ -11,3 +12,6 @@ opencpu_pkgs:
opencpu_proxy_port: 8004
opencpu_context: /ocpu
opencpu_options:
- { name: 'timelimit.get', value: '900' }
- { name: 'timelimit.post', value: '900' }

View File

@ -0,0 +1,4 @@
---
- name: restart opencpu
service: name=opencpu state=restarted
when: opencpu_enabled

View File

@ -5,8 +5,33 @@
apt_repository: repo={{ opencpu_repo }} update_cache=yes
- name: Install the opencpu package
apt: pkg={{ item }} state={{ opencpu_pkg_state }}
apt: pkg={{ item }} state={{ opencpu_pkg_state }} update_cache=yes cache_valid_time=3600
with_items: '{{ opencpu_pkgs }}'
- name: Install a custom opencpu configuration
template: src=custom-opencpu.conf.j2 dest=/etc/opencpu/server.conf.d/custom.conf owner=opencpu group=opencpu mode=0644
notify: restart opencpu
- name: Ensure that the opencpu service is enabled and running
service: name=opencpu state=started enabled=yes
when: opencpu_enabled
- name: Ensure that the opencpu service is disabled and stopped
service: name=opencpu state=stopped enabled=no
when: not opencpu_enabled
tags: opencpu
when: opencpu_install
- block:
- name: Remove the opencpu repository
apt_repository: repo={{ opencpu_repo }} state=absent
- name: Remove the opencpu package
apt: pkg={{ item }} state=absent
with_items: '{{ opencpu_pkgs }}'
tags: opencpu
when: not opencpu_install

View File

@ -0,0 +1,8 @@
{
{% for opt in opencpu_options %}
"{{ opt.name }}": {{ opt.value }}{% if not loop.last %},{% endif %}
{% endfor %}
}