- name: Install selfoss dependencies apt: name: "{{ packages }}" state: present vars: packages: - php - php-pgsql - php-gd - curl - unzip tags: - dependencies - name: Create Selfoss temp directory file: path=/root/selfoss state=directory - name: Download Selfoss-{{ selfoss_version }} get_url: url=https://github.com/SSilence/selfoss/releases/download/{{ selfoss_version }}/selfoss-{{ selfoss_version }}.zip dest=/root/selfoss/selfoss-{{ selfoss_version }}.zip - name: Create Selfoss unpack directory file: path=/root/selfoss/selfoss-{{ selfoss_version }} state=directory - name: Extract Selfoss archive unarchive: copy: no src: /root/selfoss/selfoss-{{ selfoss_version }}.zip dest: /root/selfoss/selfoss-{{ selfoss_version }}/ creates: /root/selfoss-{{ selfoss_version }}/index.php - name: Back-Up old Selfoss data shell: cp -r /var/www/selfoss/data /root/selfoss/data_bak || true - name: Delete old Selfoss document root file: path=/var/www/selfoss state=absent - name: Copy Selfoss source to document root shell: cp -r /root/selfoss/selfoss-{{ selfoss_version }} /var/www/selfoss - name: Delete empty Selfoss data file: path=/var/www/selfoss/data state=absent - name: Restore old Selfoss data shell: cp -r /root/selfoss/data_bak /var/www/selfoss/data || cp -r /root/selfoss/selfoss-{{ selfoss_version }}/data /var/www/selfoss/data - name: Delete old Selfoss data file: path=/root/selfoss/data_bak state=absent - name: Set selfoss ownership action: file owner=www-data group=www-data path=/var/www/selfoss recurse=yes state=directory - name: Set selfoss permission action: file path=/var/www/selfoss/{{ item }} mode=0775 with_items: - data/cache - data/favicons - data/fulltextrss - data/logs - data/sqlite - data/thumbnails - public - name: Create database user for selfoss postgresql_user: login_host=localhost login_user={{ db_admin_username }} login_password="{{ db_admin_password }}" name={{ selfoss_db_username }} password="{{ selfoss_db_password }}" state=present - name: Create database for selfoss postgresql_db: login_host=localhost login_user={{ db_admin_username }} login_password="{{ db_admin_password }}" name={{ selfoss_db_database }} state=present owner={{ selfoss_db_username }} - name: Install selfoss config.ini template: src=var_www_selfoss_config.ini.j2 dest=/var/www/selfoss/config.ini owner=root group=www-data mode=0640 - name: Enable Apache rewrite module command: a2enmod rewrite creates=/etc/apache2/mods-enabled/rewrite.load notify: restart apache - name: Enable Apache headers module command: a2enmod headers creates=/etc/apache2/mods-enabled/headers.load notify: restart apache - name: Enable Apache expires module command: a2enmod expires creates=/etc/apache2/mods-enabled/expires.load notify: restart apache - name: Create the Apache sites config files template: src=etc_apache2_sites-available_selfoss.j2 dest=/etc/apache2/sites-available/selfoss_{{ item.name }}.conf owner=root group=root with_items: "{{ virtual_domains }}" - name: Enable Apache sites (creates new sites-enabled symlinks) command: a2ensite selfoss_{{ item }}.conf creates=/etc/apache2/sites-enabled/selfoss_{{ item }}.conf notify: restart apache with_items: "{{ virtual_domains | json_query('[*].name') }}" - name: Install selfoss cronjob cron: name="selfoss" user="www-data" minute="*/5" job="curl --silent --show-error -k 'https://{{ selfoss_domain }}/update' > /dev/null" - name: Configure selfoss logrotate copy: src=etc_logrotate_selfoss dest=/etc/logrotate.d/selfoss owner=root group=root mode=0644