From 2feefdb5f1a66d35e844904f2a1ac0effdeb0cef Mon Sep 17 00:00:00 2001 From: vincent Date: Wed, 17 Apr 2019 13:37:19 +0200 Subject: [PATCH] create tt-rss role --- defaults/main.yml | 21 ++++ handlers/main.yml | 2 + meta/main.yml | 4 + tasks/main.yml | 53 +++++++++ templates/config.php.j2 | 165 +++++++++++++++++++++++++++++ templates/fail2ban/tt-rss.local.j2 | 7 ++ 6 files changed, 252 insertions(+) create mode 100644 templates/config.php.j2 create mode 100644 templates/fail2ban/tt-rss.local.j2 diff --git a/defaults/main.yml b/defaults/main.yml index e69de29..fc55b45 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -0,0 +1,21 @@ +--- +# defaults file for tt-rss +# Database user +ttrss_db_user: ttrss +# Database password, please change when using the role +ttrss_db_password: ttrss +# Database name +ttrss_db_name: ttrss + +# Path to the folder, where Tiny Tiny RSS will be installed +ttrss_install_path: "/usr/share/nginx/html/tt-rss" +# URL PATH of the Tiny Tiny RSS installation, change only when you know what you do +ttrss_url_path: "http://{{ ansible_default_ipv4.address }}/{{ ttrss_install_path | basename }}/" +# Enable gzip out to improve wire performance, This requires PHP Zlib extension on the server +# Set to True or False +ttrss_enable_gzip: true +# Sets log destination for Tiny Tiny RSS +# syslog - logs to system log +# sql - logs to database, can be seen in Preferences -> System +# '' - uses PHP logging, usually the http server error log +ttrss_log_destination: "syslog" \ No newline at end of file diff --git a/handlers/main.yml b/handlers/main.yml index e69de29..fcd2f38 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +- name: Restart tt-rss daemon + service: name=tt-rss state=restarted \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml index e69de29..05d6d34 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -0,0 +1,4 @@ +dependencies: + - nginx + - php + - mariadb \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index e69de29..e1db1d8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -0,0 +1,53 @@ + +- name: install tt-rss + become: yes + pacman: + name: tt-rss + state: present + + +- name: "Ensure database is present" + become: yes + mysql_db: + name: "{{ ttrss_db_name }}" + collation: utf8_general_ci + encoding: utf8 + target: /usr/share/webapps/tt-rss/schema/ttrss_schema_mysql.sql + state: import + +- name: "Ensure db user is present" + become: yes + mysql_user: + name: "{{ ttrss_db_user }}" + host: localhost + password: "{{ ttrss_db_password }}" + priv: "{{ ttrss_db_name }}.*:ALL" + state: present + + +- name: link tt-rss folder to WWW + become: yes + file: + src: /usr/share/webapps/tt-rss + dest: "{{ttrss_install_path}}" + state: link + +- name: Ensure config.php is present + template: + src: config.php.j2 + dest: /etc/webapps/tt-rss/config.php + become: yes + +- name: copy failtoban config + template: + src: fail2ban/tt-rss.local.j2 + dest: /etc/fail2ban/jail.d/tt-rss.local + notify: restart fail2ban + become: yes + +- name: enable daemon + service: + name: tt-rss # required. Name of the service. + enabled: true # not required. Whether the service should start on boot. B(At least one of state and enabled are required.) + state: started # not required. choices: reloaded;restarted;started;stopped. C(started)/C(stopped) are idempotent actions that will not run commands unless necessary. C(restarted) will always bounce the service. C(reloaded) will always reload. B(At least one of state and enabled are required.) Note that reloaded will start the service if it is not already started, even if your chosen init system wouldn't normally. + become: yes diff --git a/templates/config.php.j2 b/templates/config.php.j2 new file mode 100644 index 0000000..5e659b4 --- /dev/null +++ b/templates/config.php.j2 @@ -0,0 +1,165 @@ + System), syslog - logs to system log. + // Setting this to blank uses PHP logging (usually to http server + // error.log). + define('CONFIG_VERSION', 26); + // Expected config version. Please update this option in config.php + // if necessary (after migrating all new options from this file). + // vim:ft=php \ No newline at end of file diff --git a/templates/fail2ban/tt-rss.local.j2 b/templates/fail2ban/tt-rss.local.j2 new file mode 100644 index 0000000..4af3c1c --- /dev/null +++ b/templates/fail2ban/tt-rss.local.j2 @@ -0,0 +1,7 @@ +[tt-rss] +enabled = true +port = http,https +filter = tt-rss +logpath = {{ nginx_error_log.split(" ")[0] }} +findtime = 3600 +maxretry = 5