diff --git a/opencpu/defaults/main.yml b/opencpu/defaults/main.yml index 9d44bce..04afad6 100644 --- a/opencpu/defaults/main.yml +++ b/opencpu/defaults/main.yml @@ -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' } diff --git a/opencpu/handlers/main.yml b/opencpu/handlers/main.yml new file mode 100644 index 0000000..529043b --- /dev/null +++ b/opencpu/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: restart opencpu + service: name=opencpu state=restarted + when: opencpu_enabled diff --git a/opencpu/tasks/main.yml b/opencpu/tasks/main.yml index ab8b91e..c9b35ac 100644 --- a/opencpu/tasks/main.yml +++ b/opencpu/tasks/main.yml @@ -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 diff --git a/opencpu/templates/custom-opencpu.conf.j2 b/opencpu/templates/custom-opencpu.conf.j2 new file mode 100644 index 0000000..c31702e --- /dev/null +++ b/opencpu/templates/custom-opencpu.conf.j2 @@ -0,0 +1,8 @@ +{ + +{% for opt in opencpu_options %} + "{{ opt.name }}": {{ opt.value }}{% if not loop.last %},{% endif %} + +{% endfor %} + +}