--- - name: Create the CKAN user user: name={{ ckan_shell_user }} home={{ ckan_libdir }} createhome=no shell=/usr/sbin/nologin system=yes - name: Download the CKAN distribution get_url: url='{{ ckan_package_url }}' dest=/srv/{{ ckan_deb_file }} force=yes tags: [ 'ckan', 'ckan_pkg' ] - name: Install the CKAN deb package apt: deb=/srv/{{ ckan_deb_file }} register: ckan_install tags: [ 'ckan', 'ckan_pkg' ] - name: Fix the python version in the CKAN virtualenv unarchive: src: 'https://ftp.d4science.org/ubuntu-misc-binaries/ckan-default-python-2.7.14.tar.gz' dest: '{{ ckan_libdir }}' remote_src: yes creates: '{{ ckan_virtenv }}/bin/get-pip.py' tags: [ 'ckan', 'ckan_pkg', 'ckan_python_pkg' ] - name: Fix the python version in the CKAN virtualenv unarchive: src: 'https://ftp.d4science.org/ubuntu-misc-binaries/python-2.7.14-usrlocal.tar.gz' dest: '/' remote_src: yes creates: '/usr/local/lib/python2.7/ConfigParser.py' tags: [ 'ckan', 'ckan_pkg', 'ckan_python_pkg' ] - name: Configure the CKAN production configuration file excluding 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 }}' notify: Restart CKAN tags: [ 'ckan', 'ckan_ini' ] - name: Install the apache.wsgi template: src=apache.wsgi.j2 dest={{ ckan_confdir }}/apache.wsgi notify: Restart CKAN tags: [ 'ckan', 'apache', 'ckan_pkg' ] - name: Create the base directory for the CKAN file storage file: dest: '{{ ckan_file_storage_dir }}' state: directory owner: '{{ apache_user }}' group: '{{ ckan_shell_user }}' mode: '2770' tags: [ 'ckan' ] - name: Fix the CKAN harvesting storage permissions file: dest={{ ckan_file_harvesting_dir }} state=directory owner={{ apache_user }} group={{ ckan_shell_user }} mode='2770' recurse=yes tags: [ 'ckan' ] - name: authorization file for the psql command, if the database is on a remote server template: src=pgpass.j2 dest=/root/.pgpass owner=root mode=0600 when: psql_db_host != 'localhost' tags: [ 'pg_backup', 'postgresql', 'postgres' ] - name: Initialize the CKAN database shell: ckan db init && touch {{ ckan_libdir }}/.ckan_db_initialized args: creates: '{{ ckan_libdir }}/.ckan_db_initialized' when: ckan_init_db_and_solr tags: [ 'ckan' ] - name: Initialize the CKAN datastore database shell: ckan datastore set-permissions | psql --set ON_ERROR_STOP=1 -h {{ psql_db_host }} -U {{ ckan_db_user }} -w {{ ckan_datastore_db_name }} && touch {{ ckan_libdir }}/.ckan_datastore_db_initialized args: creates: '{{ ckan_libdir }}/.ckan_datastore_db_initialized' when: ckan_init_db_and_solr tags: [ 'ckan' ] - name: Create the pip cache directory with the right permissions file: dest={{ ckan_libdir }}/.cache owner={{ ckan_shell_user }} group={{ ckan_shell_user }} state=directory tags: [ 'ckan', 'ckan_user' ] - name: Assign the CKAN virtenv dir to the ckan user file: dest={{ ckan_virtenv }} recurse=yes owner={{ ckan_shell_user }} group={{ ckan_shell_user }} tags: [ 'ckan', 'ckan_user', 'ckan_permissions' ] - name: Create a log directory for the jobs run by the ckan user file: dest={{ ckan_logdir }} state=directory owner={{ ckan_shell_user }} group={{ ckan_shell_user }} tags: [ 'ckan', 'ckan_user' ] - name: Job that clears the havesting history block: - name: Install a script that find the source ids and cleans up the history for each of them template: src=clear_harvesting_history.sh.j2 dest=/usr/local/bin/ckan_clear_harvesting_history owner=root group=ckan mode='0750' - name: Cron job that clears the harvesting history cron: cron_file: 'clear_ckan_harvesting_history' disabled: no job: "/usr/local/bin/ckan_clear_harvesting_history > /var/log/ckan/clear-harvesting-history.log 2>&1" special_time: "{{ ckan_clear_harvesting_freq }}" user: '{{ ckan_shell_user }}' name: Clear the CKAN harvesting history state: present when: ckan_clear_harvesting_enabled tags: [ 'ckan', 'ckan_d4s', 'ckan_clear_harvesting' ] - name: Job that clears the havesting history block: - name: Remove the script that clears the harvesting history file: dest=/usr/local/bin/ckan_clear_harvesting_history state=absent - name: Remove the cron job that clears the harvesting history cron: cron_file: 'clear_ckan_harvesting_history' disabled: no job: "/usr/local/bin/ckan_clear_harvesting_history > /var/log/ckan/clear-harvesting-history.log 2>&1" special_time: "{{ ckan_clear_harvesting_freq }}" user: '{{ ckan_shell_user }}' name: Clear the CKAN harvesting history state: absent when: not ckan_clear_harvesting_enabled tags: [ 'ckan', 'ckan_d4s', 'ckan_clear_harvesting' ]