123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- - 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
|