From 6a57323aa71b4e1d2442ce07affa21971b9f3263 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 11 Apr 2019 19:07:25 +0200 Subject: [PATCH] Fixes to the ckan roles, mostly related to the use of the 'become' directive. --- ckan/ckan/tasks/ckan-memcache.yml | 4 +--- ckan/ckan/tasks/ckan-plugins.yml | 11 ++++------- ckan/ckan/tasks/ckan.yml | 4 ++++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ckan/ckan/tasks/ckan-memcache.yml b/ckan/ckan/tasks/ckan-memcache.yml index 44f467c..6afe2c9 100644 --- a/ckan/ckan/tasks/ckan-memcache.yml +++ b/ckan/ckan/tasks/ckan-memcache.yml @@ -9,7 +9,7 @@ tags: [ 'ckan', 'ckan_sessions', 'ckan_memcache' ] - block: - - name: Install the memcache library + - name: Install the memcache library deb package apt: pkg=libmemcached10 state=present update_cache=yes cache_valid_time=1800 - name: Configure CKAN so that it uses memcache for its sessions @@ -27,7 +27,6 @@ file: dest=/tmp/{{ ckan_site_id }}/sessions state=absent ignore_errors: True - become: False when: ckan_memcache_sessions is defined and ckan_memcache_sessions tags: [ 'ckan', 'ckan_sessions', 'ckan_memcache' ] @@ -40,7 +39,6 @@ - Restart fetch and gather consumers tags: [ 'ckan', 'ckan_ini', 'ckan_plugins', 'ckan_sessions', 'ckan_memcache' ] - become: False when: - ckan_memcache_sessions is defined - not ckan_memcache_sessions diff --git a/ckan/ckan/tasks/ckan-plugins.yml b/ckan/ckan/tasks/ckan-plugins.yml index 80aaa69..9864c40 100644 --- a/ckan/ckan/tasks/ckan-plugins.yml +++ b/ckan/ckan/tasks/ckan-plugins.yml @@ -1,10 +1,8 @@ --- - block: - name: Install some packages dependencies - apt: name={{ item }} state=latest update_cache=yes cache_valid_time=3600 - with_items: '{{ ckan_additional_packages }}' + apt: name={{ ckan_additional_packages }} state=latest update_cache=yes cache_valid_time=3600 - become: False tags: [ 'ckan', 'geonetwork', 'ckan_plugins', 'ckan_pip_deps' ] - block: @@ -14,8 +12,7 @@ tags: [ 'ckan', 'geonetwork', 'ckan_plugins', 'ckan_pip_deps' ] - name: Install some python plugins dependencies inside the CKAN virtualenv - pip: name={{ item }} virtualenv={{ ckan_virtenv }} state=present - with_items: '{{ ckan_pip_dependencies }}' + pip: name={{ ckan_pip_dependencies }} virtualenv={{ ckan_virtenv }} state=present tags: [ 'ckan', 'geonetwork', 'ckan_plugins', 'ckan_pip_deps' ] - name: Download the CKAN ckanext-harvest plugin @@ -57,7 +54,7 @@ tags: [ 'ckan', 'ckan_spatial', 'ckan_plugins' ] - name: Download the CKAN ckanext-geoview plugin - pip: name='{{ ckan_geoview_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True + pip: name='{{ ckan_geoview_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} notify: Restart CKAN when: ckan_geoview tags: [ 'ckan', 'ckan_geoview', 'ckan_plugins' ] @@ -190,7 +187,7 @@ tags: [ 'ckan', 'ckan_profiler', 'ckan_plugins' ] - name: Create the profiler plugin log directory - become: False + become_user: root file: dest=/var/log/ckan-profiler owner=www-data group=www-data state=directory when: ckan_profiler tags: [ 'ckan', 'ckan_profiler', 'ckan_plugins' ] diff --git a/ckan/ckan/tasks/ckan.yml b/ckan/ckan/tasks/ckan.yml index 84ead59..cd72c30 100644 --- a/ckan/ckan/tasks/ckan.yml +++ b/ckan/ckan/tasks/ckan.yml @@ -8,6 +8,10 @@ register: ckan_install tags: ckan +- name: Create the CKAN user + user: name={{ ckan_shell_user }} home={{ ckan_libdir }} createhome=no shell=/usr/sbin/nologin system=yes + tags: ckan + - name: Configure the CKAN production configuration file but the plugins list ini_file: dest={{ ckan_config_file }} section={{ item.section }} option={{ item.option }} value={{ item.value }} state={{ item.state }} backup=yes with_items: '{{ ckan_production_ini_opts }}'