inital commit
This commit is contained in:
commit
6d24a78929
107
.drone.jsonnet
Normal file
107
.drone.jsonnet
Normal file
@ -0,0 +1,107 @@
|
||||
local AnsibleVersions(version="latest", package="ansible") = {
|
||||
name: "ansible-" + version,
|
||||
image: "python:3.7",
|
||||
pull: "always",
|
||||
environment: {
|
||||
PY_COLORS: 1
|
||||
},
|
||||
commands: [
|
||||
"pip install " + package + " ansible-later~=0.2.0 -qq",
|
||||
"git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy",
|
||||
"ansible-later -c ~/policy/config.yml"
|
||||
],
|
||||
depends_on: [
|
||||
"clone",
|
||||
],
|
||||
};
|
||||
|
||||
local PipelineLinting = {
|
||||
kind: "pipeline",
|
||||
name: "linting",
|
||||
platform: {
|
||||
os: "linux",
|
||||
arch: "amd64",
|
||||
},
|
||||
steps: [
|
||||
AnsibleVersions(version="latest", package="ansible"),
|
||||
AnsibleVersions(version="master", package="git+https://github.com/ansible/ansible.git@devel"),
|
||||
],
|
||||
trigger: {
|
||||
ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineDeployment = {
|
||||
kind: "pipeline",
|
||||
name: "deployment",
|
||||
platform: {
|
||||
os: "linux",
|
||||
arch: "amd64",
|
||||
},
|
||||
workspace: {
|
||||
base: "/drone/src",
|
||||
path: "xoxys.freshrss"
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: "molecule",
|
||||
image: "xoxys/molecule:do-linux-amd64",
|
||||
pull: "always",
|
||||
environment: {
|
||||
DO_API_KEY: { "from_secret": "do_api_key" },
|
||||
USER: "root",
|
||||
MOLECULE_CUSTOM_MODULES_REPO: "https://gitea.rknet.org/ansible/custom_modules",
|
||||
MOLECULE_CUSTOM_FILTERS_REPO: "https://gitea.rknet.org/ansible/custom_filters",
|
||||
PY_COLORS: 1
|
||||
},
|
||||
commands: [
|
||||
"/bin/bash /docker-entrypoint.sh",
|
||||
"molecule test -s default",
|
||||
],
|
||||
},
|
||||
],
|
||||
depends_on: [
|
||||
"linting",
|
||||
],
|
||||
trigger: {
|
||||
ref: ["refs/heads/master", "refs/tags/**"],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineNotifications = {
|
||||
kind: "pipeline",
|
||||
name: "notifications",
|
||||
platform: {
|
||||
os: "linux",
|
||||
arch: "amd64",
|
||||
},
|
||||
clone: {
|
||||
disable: true,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: "matrix",
|
||||
image: "plugins/matrix",
|
||||
settings: {
|
||||
homeserver: "https://matrix.rknet.org",
|
||||
roomid: "MtidqQXWWAtQcByBhH:rknet.org",
|
||||
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}",
|
||||
username: { "from_secret": "matrix_username" },
|
||||
password: { "from_secret": "matrix_password" },
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: [
|
||||
"deployment",
|
||||
],
|
||||
trigger: {
|
||||
status: [ "success", "failure" ],
|
||||
ref: ["refs/heads/master", "refs/tags/**"],
|
||||
},
|
||||
};
|
||||
|
||||
[
|
||||
PipelineLinting,
|
||||
PipelineDeployment,
|
||||
PipelineNotifications,
|
||||
]
|
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# ---> Ansible
|
||||
*.retry
|
||||
filter/plugins/
|
||||
library
|
||||
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
8
LICENSE
Normal file
8
LICENSE
Normal file
@ -0,0 +1,8 @@
|
||||
MIT License
|
||||
Copyright (c) 2019 xoxys <mail@geeklabor.de>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
106
defaults/main.yml
Normal file
106
defaults/main.yml
Normal file
@ -0,0 +1,106 @@
|
||||
---
|
||||
freshrss_version: latest
|
||||
freshrss_service_directory: /var/lib/docker/services/freshrss
|
||||
freshrss_url: http://localhost
|
||||
|
||||
freshrss_container_name: freshrss
|
||||
freshrss_image: "xoxys/freshrss:{{ freshrss_version }}"
|
||||
freshrss_restart_policy: on-failure
|
||||
freshrss_exposed_port: 61000
|
||||
freshrss_exposed_ip: 127.0.0.1
|
||||
freshrss_extra_hosts: []
|
||||
# freshrss_memory_limit: 512m # defaults to not set
|
||||
# freshrss_memory_reservation: 256m # defaults to not set
|
||||
# freshrss_cpu_shares: 1024 # defaults to not set
|
||||
# freshrss_http_proxy: # defaults to not set
|
||||
# freshrss_https_proxy: # defaults to not set
|
||||
# freshrss_no_proxy: # defaults to not set
|
||||
|
||||
freshrss_cap_add: []
|
||||
freshrss_cap_drop: []
|
||||
freshrss_security_opt: []
|
||||
# freshrss_pids_limit: # defaults to not set
|
||||
|
||||
freshrss_healthcheck:
|
||||
test: '["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost"]'
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
freshrss_environment: "production"
|
||||
freshrss_default_user: "admin"
|
||||
freshrss_default_password: "freshrss"
|
||||
# Salt is used to make crypto more unique.
|
||||
# Can be generated with e.g. cat /proc/sys/kernel/random/uuid | sha1sum | awk '{print $1}'
|
||||
# freshrss_salt: # defaults to not set
|
||||
# Specify address of the freshrss instance,
|
||||
# used when building absolute urls, e.g. for websub.
|
||||
freshrss_base_url: "http://localhost/"
|
||||
freshrss_language: "en"
|
||||
freshrss_title: "freshrss"
|
||||
# freshrss_meta_description: # defaults to not set
|
||||
freshrss_allow_anonymous: "false"
|
||||
freshrss_allow_anonymous_refresh: "false"
|
||||
freshrss_auth_type: "form"
|
||||
freshrss_api_enabled: "false"
|
||||
freshrss_unsafe_autologin_enabled: "false"
|
||||
freshrss_simplepie_syslog_enabled: "true"
|
||||
freshrss_pubsubhubbub_enabled: "false"
|
||||
freshrss_allow_robots: "false"
|
||||
freshrss_allow_referrer: "false"
|
||||
freshrss_limits_cookie_duration: "2592000"
|
||||
freshrss_limits_cache_duration: "800"
|
||||
freshrss_limits_timeout: "15"
|
||||
freshrss_limits_max_inactivity: "10800"
|
||||
freshrss_limits_max_feeds: "16384"
|
||||
freshrss_limits_max_categories: "16384"
|
||||
freshrss_limits_max_registrations: "1"
|
||||
# freshrss_curlopt_ssl_verifyhost: # defaults to not set
|
||||
# freshrss_curlopt_ssl_verifypeer: # defaults to not set
|
||||
# freshrss_curlopt_proxytype: # defaults to not set
|
||||
# freshrss_curlopt_proxy: # defaults to not set
|
||||
# freshrss_curlopt_proxyport: # defaults to not set
|
||||
# freshrss_curlopt_proxyauth: # defaults to not set
|
||||
# freshrss_curlopt_proxyuserpwd: # defaults to not set
|
||||
## comma-seperated string, extensions must be installed!
|
||||
freshrss_extensions_enabled: "Tumblr-GDPR"
|
||||
|
||||
freshrss_postgres_ssl_mode: disable
|
||||
freshrss_postgres_ssl_rootcert: /etc/ssl/certs/ca-certificates.crt
|
||||
freshrss_postgres_server: "{{ inventory_hostname }}"
|
||||
freshrss_postgres_port: 5432
|
||||
freshrss_postgres_superuser: postgres
|
||||
freshrss_postgres_password: postgres
|
||||
|
||||
freshrss_postgres_db:
|
||||
name: freshrss
|
||||
lc_collate: en_US.UTF-8
|
||||
lc_ctype: en_US.UTF-8'
|
||||
encoding: UTF-8
|
||||
template: template0
|
||||
login_user: "{{ freshrss_postgres_superuser }}"
|
||||
login_password: "{{ freshrss_postgres_password }}"
|
||||
# login_unix_socket: # defaults to not set
|
||||
port: "{{ freshrss_postgres_port }}"
|
||||
# owner: # defaults to not set
|
||||
state: present
|
||||
|
||||
freshrss_postgres_user:
|
||||
name: pgfreshrss
|
||||
password: freshrss
|
||||
encrypted: 'yes'
|
||||
# priv: # defaults to not set
|
||||
# role_attr_flags: # defaults to not set
|
||||
db: "{{ freshrss_postgres_db.name }}"
|
||||
login_user: "{{ freshrss_postgres_superuser }}"
|
||||
login_password: "{{ freshrss_postgres_password }}"
|
||||
# login_unix_socket: # defaults to not set
|
||||
port: "{{ freshrss_postgres_port }}"
|
||||
state: present
|
||||
|
||||
freshrss_iptables_enabled: False
|
||||
freshrss_open_ports:
|
||||
- name: allow_freshrss_web
|
||||
rules: |
|
||||
-A INPUT -m state --state NEW -p tcp --dport {{ freshrss_exposed_port }} -j ACCEPT
|
||||
state: present
|
9
handlers/main.yml
Normal file
9
handlers/main.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Restart container
|
||||
systemd:
|
||||
state: restarted
|
||||
daemon_reload: yes
|
||||
name: freshrss
|
||||
listen: __freshrss_restart
|
||||
become: True
|
||||
become_user: root
|
16
meta/main.yml
Normal file
16
meta/main.yml
Normal file
@ -0,0 +1,16 @@
|
||||
# Standards: 0.1
|
||||
---
|
||||
galaxy_info:
|
||||
author: xoxys
|
||||
description: Setup FreshRSS server
|
||||
license: MIT
|
||||
min_ansible_version: 2.4
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
galaxy_tags:
|
||||
- rss
|
||||
- news
|
||||
- freshrss
|
||||
dependencies:
|
87
molecule/default/create.yml
Normal file
87
molecule/default/create.yml
Normal file
@ -0,0 +1,87 @@
|
||||
---
|
||||
- name: Create
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
no_log: "{{ molecule_no_log }}"
|
||||
vars:
|
||||
ssh_user: root
|
||||
ssh_port: 22
|
||||
|
||||
keypair_name: molecule_key
|
||||
keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
|
||||
tasks:
|
||||
- name: Create local keypair
|
||||
user:
|
||||
name: "{{ lookup('env', 'USER') }}"
|
||||
generate_ssh_key: true
|
||||
ssh_key_file: "{{ keypair_path }}"
|
||||
register: local_keypair
|
||||
|
||||
- name: Create remote keypair
|
||||
digital_ocean_sshkey:
|
||||
name: "{{ keypair_name }}"
|
||||
ssh_pub_key: "{{ local_keypair.ssh_public_key }}"
|
||||
state: present
|
||||
register: remote_keypair
|
||||
|
||||
- name: Create molecule instance(s)
|
||||
digital_ocean_droplet:
|
||||
name: "{{ item.name }}"
|
||||
unique_name: true
|
||||
region: "{{ item.region_id }}"
|
||||
image: "{{ item.image_id }}"
|
||||
size: "{{ item.size_id }}"
|
||||
ssh_keys: "{{ remote_keypair.data.ssh_key.id }}"
|
||||
wait: true
|
||||
wait_timeout: 300
|
||||
state: present
|
||||
register: server
|
||||
loop: "{{ molecule_yml.platforms }}"
|
||||
async: 7200
|
||||
poll: 0
|
||||
|
||||
- name: Wait for instance(s) creation to complete
|
||||
async_status:
|
||||
jid: "{{ item.ansible_job_id }}"
|
||||
register: digitalocean_jobs
|
||||
until: digitalocean_jobs.finished
|
||||
retries: 300
|
||||
loop: "{{ server.results }}"
|
||||
|
||||
# Mandatory configuration for Molecule to function.
|
||||
|
||||
- name: Populate instance config dict
|
||||
set_fact:
|
||||
instance_conf_dict: {
|
||||
'instance': "{{ item.data.droplet.name }}",
|
||||
'address': "{{ item.data.ip_address }}",
|
||||
'user': "{{ ssh_user }}",
|
||||
'port': "{{ ssh_port }}",
|
||||
'identity_file': "{{ keypair_path }}",
|
||||
'droplet_id': "{{ item.data.droplet.id }}",
|
||||
'ssh_key_id': "{{ remote_keypair.data.ssh_key.id }}",
|
||||
}
|
||||
loop: "{{ digitalocean_jobs.results }}"
|
||||
register: instance_config_dict
|
||||
when: server.changed | bool
|
||||
|
||||
- name: Convert instance config dict to a list
|
||||
set_fact:
|
||||
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
|
||||
when: server.changed | bool
|
||||
|
||||
- name: Dump instance config
|
||||
copy:
|
||||
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
when: server.changed | bool
|
||||
|
||||
- name: Wait for SSH
|
||||
wait_for:
|
||||
port: "{{ ssh_port }}"
|
||||
host: "{{ item.address }}"
|
||||
search_regex: SSH
|
||||
delay: 10
|
||||
timeout: 320
|
||||
loop: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
54
molecule/default/destroy.yml
Normal file
54
molecule/default/destroy.yml
Normal file
@ -0,0 +1,54 @@
|
||||
---
|
||||
- name: Destroy
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
no_log: "{{ molecule_no_log }}"
|
||||
tasks:
|
||||
- block:
|
||||
- name: Populate instance config
|
||||
set_fact:
|
||||
instance_conf: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}"
|
||||
skip_instances: false
|
||||
rescue:
|
||||
- name: Populate instance config when file missing
|
||||
set_fact:
|
||||
instance_conf: {}
|
||||
skip_instances: true
|
||||
|
||||
- name: Destroy molecule instance(s)
|
||||
digital_ocean_droplet:
|
||||
name: "{{ item.instance }}"
|
||||
id: "{{ item.droplet_id }}"
|
||||
state: absent
|
||||
register: server
|
||||
loop: "{{ instance_conf | flatten(levels=1) }}"
|
||||
when: not skip_instances
|
||||
async: 7200
|
||||
poll: 0
|
||||
|
||||
- name: Wait for instance(s) deletion to complete
|
||||
async_status:
|
||||
jid: "{{ item.ansible_job_id }}"
|
||||
register: digitalocean_jobs
|
||||
until: digitalocean_jobs.finished
|
||||
retries: 300
|
||||
loop: "{{ server.results }}"
|
||||
|
||||
- name: Delete remote keypair
|
||||
digital_ocean_sshkey:
|
||||
fingerprint: "{{ item.ssh_key_id }}"
|
||||
state: absent
|
||||
loop: "{{ instance_conf | flatten(levels=1) }}"
|
||||
|
||||
# Mandatory configuration for Molecule to function.
|
||||
|
||||
- name: Populate instance config
|
||||
set_fact:
|
||||
instance_conf: {}
|
||||
|
||||
- name: Dump instance config
|
||||
copy:
|
||||
content: "{{ instance_conf | molecule_to_yaml | molecule_header }}"
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
when: server.changed | bool
|
22
molecule/default/molecule.yml
Normal file
22
molecule/default/molecule.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: digitalocean
|
||||
platforms:
|
||||
- name: centos7-freshrss
|
||||
region_id: fra1
|
||||
image_id: centos-7-x64
|
||||
size_id: s-1vcpu-1gb
|
||||
lint:
|
||||
name: yamllint
|
||||
enabled: False
|
||||
provisioner:
|
||||
name: ansible
|
||||
lint:
|
||||
name: ansible-lint
|
||||
enabled: False
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
5
molecule/default/playbook.yml
Normal file
5
molecule/default/playbook.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: xoxys.freshrss
|
9
molecule/default/prepare.yml
Normal file
9
molecule/default/prepare.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Install python for Ansible
|
||||
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
|
||||
become: true
|
||||
changed_when: false
|
9
molecule/default/requirements.yml
Normal file
9
molecule/default/requirements.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- src: https://gitea.rknet.org/ansible/xoxys.docker-engine.git
|
||||
name: xoxys.docker-engine
|
||||
scm: git
|
||||
version: master
|
||||
- src: https://gitea.rknet.org/ansible/xoxys.postgres.git
|
||||
name: xoxys.postgres
|
||||
scm: git
|
||||
version: master
|
11
molecule/default/tests/test_default.py
Normal file
11
molecule/default/tests/test_default.py
Normal file
@ -0,0 +1,11 @@
|
||||
import os
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
||||
|
3
molecule/pytest.ini
Normal file
3
molecule/pytest.ini
Normal file
@ -0,0 +1,3 @@
|
||||
[pytest]
|
||||
filterwarnings =
|
||||
ignore::DeprecationWarning
|
4
tasks/main.yml
Normal file
4
tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
- include_tasks: prepare.yml
|
||||
- include_tasks: setup.yml
|
||||
- include_tasks: post.yml
|
10
tasks/post.yml
Normal file
10
tasks/post.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
- block:
|
||||
- name: Ensure freshrss service is up and running
|
||||
systemd:
|
||||
state: started
|
||||
daemon_reload: yes
|
||||
enabled: yes
|
||||
name: freshrss
|
||||
become: True
|
||||
become_user: root
|
44
tasks/prepare.yml
Normal file
44
tasks/prepare.yml
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
- name: Ensure service directory exists
|
||||
file:
|
||||
path: "{{ freshrss_service_directory }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
become: True
|
||||
become_user: root
|
||||
|
||||
- block:
|
||||
- name: Setup postgres db '{{ freshrss_postgres_db.name }}'
|
||||
postgresql_db:
|
||||
name: "{{ freshrss_postgres_db.name }}"
|
||||
lc_collate: "{{ freshrss_postgres_db.lc_collate | default('en_US.UTF-8') }}"
|
||||
lc_ctype: "{{ freshrss_postgres_db.lc_ctype | default('en_US.UTF-8') }}"
|
||||
encoding: "{{ freshrss_postgres_db.encoding | default('UTF-8') }}"
|
||||
template: "{{ freshrss_postgres_db.template | default('template0') }}"
|
||||
login_host: "{{ freshrss_postgres_db.login_host | default('localhost') }}"
|
||||
login_password: "{{ freshrss_postgres_db.login_password | default(omit) }}"
|
||||
login_user: "{{ freshrss_postgres_db.login_user | default(omit) }}"
|
||||
login_unix_socket: "{{ freshrss_postgres_db.login_unix_socket | default(omit) }}"
|
||||
port: "{{ freshrss_postgres_db.port | default(omit) }}"
|
||||
owner: "{{ freshrss_postgres_db.owner | default(omit) }}"
|
||||
state: "{{ freshrss_postgres_db.state | default('present') }}"
|
||||
no_log: "{{ False if freshrss_ansible_debug | default(False) else True }}"
|
||||
when: freshrss_postgres_db is defined
|
||||
|
||||
- name: Setup postgres user '{{ freshrss_postgres_user.name }}'
|
||||
postgresql_user:
|
||||
name: "{{ freshrss_postgres_user.name }}"
|
||||
password: "{{ 'md5' + (freshrss_postgres_user.password + freshrss_postgres_user.name) | hash('md5') }}"
|
||||
encrypted: "{{ freshrss_postgres_user.encrypted | default('yes') }}"
|
||||
priv: "{{ freshrss_postgres_user.priv | default(omit) }}"
|
||||
role_attr_flags: "{{ freshrss_postgres_user.role_attr_flags | default(omit) }}"
|
||||
db: "{{ freshrss_postgres_user.db | default(omit) }}"
|
||||
login_host: "{{ freshrss_postgres_user.login_host | default('localhost') }}"
|
||||
login_password: "{{ freshrss_postgres_user.login_password | default(omit) }}"
|
||||
login_user: "{{ freshrss_postgres_user.login_user | default(omit) }}"
|
||||
login_unix_socket: "{{ freshrss_postgres_user.login_unix_socket | default(omit) }}"
|
||||
port: "{{ freshrss_postgres_user.port | default(omit) }}"
|
||||
state: "{{ freshrss_postgres_user.state | default('present') }}"
|
||||
no_log: "{{ False if freshrss_ansible_debug | default(False) else True }}"
|
||||
when: freshrss_postgres_user is defined
|
||||
delegate_to: "{{ freshrss_postgres_server }}"
|
32
tasks/setup.yml
Normal file
32
tasks/setup.yml
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
- block:
|
||||
- name: Deploy compose file to '{{ freshrss_service_directory }}'
|
||||
template:
|
||||
src: "services/freshrss-compose.yml.j2"
|
||||
dest: "{{ freshrss_service_directory }}/docker-compose.yml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
validate: /bin/docker-compose -f %s config -q
|
||||
notify: __freshrss_restart
|
||||
|
||||
- name: Create systemd unit files
|
||||
template:
|
||||
src: "etc/systemd/system/freshrss.service.j2"
|
||||
dest: "/etc/systemd/system/freshrss.service"
|
||||
mode: 0644
|
||||
notify: __freshrss_restart
|
||||
|
||||
- name: Open ports in iptables
|
||||
iptables_raw:
|
||||
name: "{{ item.name }}"
|
||||
rules: "{{ item.rules }}"
|
||||
state: "{{ item.state }}"
|
||||
weight: "{{ item.weight | default(omit) }}"
|
||||
table: "{{ item.table | default(omit) }}"
|
||||
loop: "{{ freshrss_open_ports }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
when: freshrss_iptables_enabled | bool
|
||||
become: True
|
||||
become_user: root
|
22
templates/etc/systemd/system/ttrss.service.j2
Normal file
22
templates/etc/systemd/system/ttrss.service.j2
Normal file
@ -0,0 +1,22 @@
|
||||
#jinja2:lstrip_blocks: True
|
||||
{{ ansible_managed | comment }}
|
||||
[Unit]
|
||||
Description=TT-RSS news feed reader
|
||||
Requires=docker.service network-online.target
|
||||
After=docker.service network-online.target
|
||||
|
||||
[Service]
|
||||
WorkingDirectory={{ freshrss_service_directory }}
|
||||
Type=simple
|
||||
TimeoutStartSec=15min
|
||||
Restart={{ freshrss_restart_policy }}
|
||||
|
||||
ExecStartPre=/bin/docker-compose pull --quiet --ignore-pull-failures
|
||||
ExecStart=/usr/bin/docker-compose up --remove-orphans
|
||||
|
||||
ExecStop=/usr/bin/docker-compose down --remove-orphans
|
||||
|
||||
ExecReload=/usr/bin/docker-compose pull --quiet --ignore-pull-failures
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
117
templates/services/ttrss-compose.yml.j2
Normal file
117
templates/services/ttrss-compose.yml.j2
Normal file
@ -0,0 +1,117 @@
|
||||
#jinja2:lstrip_blocks: True
|
||||
{{ ansible_managed | comment }}
|
||||
version: '2.1'
|
||||
|
||||
services:
|
||||
freshrss:
|
||||
container_name: {{ freshrss_container_name }}
|
||||
image: {{ freshrss_image }}
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- {{ freshrss_exposed_ip + ':' if freshrss_exposed_ip is defined else '' }}{{ freshrss_exposed_port }}:8080
|
||||
volumes:
|
||||
- extensions:/var/www/app/extensions
|
||||
- data:/var/www/app/data
|
||||
{% if freshrss_extra_hosts | default([]) %}
|
||||
extra_hosts:
|
||||
{% for host in freshrss_extra_hosts %}
|
||||
- {{ '"' + host + '"' }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
environment:
|
||||
- FRESHRSS_ENVIRONMENT="production"
|
||||
{% if freshrss_salt is defined and freshrss_salt %}
|
||||
- FRESHRSS_SALT={{ freshrss_salt }}
|
||||
{% endif %}
|
||||
- FRESHRSS_BASE_URL={{ freshrss_url }}
|
||||
- FRESHRSS_LANGUAGE={{ freshrss_language }}
|
||||
- FRESHRSS_TITLE={{ freshrss_title }}
|
||||
{% if freshrss_meta_description is defined and freshrss_meta_description %}
|
||||
- FRESHRSS_META_DESCRIPTION={{ freshrss_meta_description }}
|
||||
{% endif %}
|
||||
- FRESHRSS_DEFAULT_USER={{ freshrss_default_user }}
|
||||
- FRESHRSS_DEFAULT_PASSWORD={{ freshrss_default_password }}
|
||||
- FRESHRSS_ALLOW_ANONYMOUS="{{ freshrss_allow_anonymous }}
|
||||
- FRESHRSS_ALLOW_ANONYMOUS_REFRESH={{ freshrss_allow_anonymous_refresh }}
|
||||
- FRESHRSS_AUTH_TYPE={{ freshrss_auth_type }}
|
||||
- FRESHRSS_API_ENABLED={{ freshrss_api_enabled }}
|
||||
- FRESHRSS_UNSAFE_AUTOLOGIN_ENABLED={{ freshrss_unsafe_autologin_enabled }}
|
||||
- FRESHRSS_SIMPLEPIE_SYSLOG_ENABLED={{ freshrss_simplepie_syslog_enabled }}
|
||||
- FRESHRSS_PUBSUBHUBBUB_ENABLED={{ freshrss_pubsubhubbub_enabled }}
|
||||
- FRESHRSS_ALLOW_ROBOTS={{ freshrss_allow_robots }}
|
||||
- FRESHRSS_ALLOW_REFERRER={{ freshrss_allow_referrer }}
|
||||
- FRESHRSS_LIMITS_COOKIE_DURATION={{ freshrss_limits_cookie_duration }}
|
||||
- FRESHRSS_LIMITS_CACHE_DURATION={{ freshrss_limits_cache_duration }}
|
||||
- FRESHRSS_LIMITS_TIMEOUT={{ freshrss_limits_timeout }}
|
||||
- FRESHRSS_LIMITS_MAX_INACTIVITY={{ freshrss_limits_max_inactivity }}
|
||||
- FRESHRSS_LIMITS_MAX_FEEDS={{ freshrss_limits_max_feeds }}
|
||||
- FRESHRSS_LIMITS_MAX_CATEGORIES={{ freshrss_limits_max_categories }}
|
||||
- FRESHRSS_LIMITS_MAX_REGISTRATIONS={{ freshrss_limits_max_registrations }}
|
||||
{% if freshrss_curlopt_ssl_verifyhost is defined and freshrss_curlopt_ssl_verifyhost %}
|
||||
- FRESHRSS_CURLOPT_SSL_VERIFYHOST={{ freshrss_curlopt_ssl_verifyhost }}
|
||||
{% endif %}
|
||||
{% if freshrss_curlopt_ssl_verifypeer is defined and freshrss_curlopt_ssl_verifypeer %}
|
||||
- FRESHRSS_CURLOPT_SSL_VERIFYPEER={{ freshrss_curlopt_ssl_verifypeer }}
|
||||
{% endif %}
|
||||
{% if freshrss_curlopt_proxytype is defined and freshrss_curlopt_proxytype %}
|
||||
- FRESHRSS_CURLOPT_PROXYTYPE={{ freshrss_curlopt_proxytype }}
|
||||
{% endif %}
|
||||
{% if freshrss_curlopt_proxy is defined and freshrss_curlopt_proxy %}
|
||||
- FRESHRSS_CURLOPT_PROXY={{ freshrss_curlopt_proxy }}
|
||||
{% endif %}
|
||||
{% if freshrss_curlopt_proxyport is defined and freshrss_curlopt_proxyport %}
|
||||
- FRESHRSS_CURLOPT_PROXYPORT={{ freshrss_curlopt_proxyport }}
|
||||
{% endif %}
|
||||
{% if freshrss_curlopt_proxyauth is defined and freshrss_curlopt_proxyauth %}
|
||||
- FRESHRSS_CURLOPT_PROXYAUTH={{ freshrss_curlopt_proxyauth }}
|
||||
{% endif %}
|
||||
{% if freshrss_curlopt_proxyuserpwd is defined and freshrss_curlopt_proxyuserpwd %}
|
||||
- FRESHRSS_CURLOPT_PROXYUSERPWD={{ freshrss_curlopt_proxyuserpwd }}
|
||||
{% endif %}
|
||||
- FRESHRSS_DB_TYPE="pgsql"
|
||||
- FRESHRSS_DB_HOST={{ freshrss_postgres_server }}:{{ freshrss_postgres_port }};sslmode={{ freshrss_postgres_ssl_mode }};sslrootcert={{ freshrss_postgres_ssl_rootcert }}
|
||||
- FRESHRSS_DB_USER={{ freshrss_postgres_user.name }}
|
||||
- FRESHRSS_DB_PASSWORD={{ freshrss_postgres_user.password }}
|
||||
- FRESHRSS_DB_BASE={{ freshrss_postgres_db.name }}
|
||||
- FRESHRSS_DB_PREFIX="freshrss_"
|
||||
- FRESHRSS_EXTENSIONS_ENABLED={{ freshrss_extensions_enabled | join(',') }}
|
||||
{% if freshrss_memory_limit is defined %}
|
||||
mem_limit: {{ freshrss_memory_limit }}
|
||||
{% endif %}
|
||||
{% if freshrss_memory_reservation is defined %}
|
||||
mem_reservation: {{ freshrss_memory_reservation }}
|
||||
{% endif %}
|
||||
{% if freshrss_cpu_shares is defined %}
|
||||
cpu_shares: {{ freshrss_cpu_shares }}
|
||||
{% endif %}
|
||||
{% if not freshrss_cap_add | length == 0 %}
|
||||
cap_add:
|
||||
{% for item in freshrss_cap_add %}
|
||||
- {{ item }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if not freshrss_cap_drop | length == 0 %}
|
||||
cap_drop:
|
||||
{% for item in freshrss_cap_drop %}
|
||||
- {{ item }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if not freshrss_security_opt | length == 0 %}
|
||||
security_opt:
|
||||
{% for item in freshrss_security_opt %}
|
||||
- {{ item }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
healthcheck:
|
||||
{% for key, value in freshrss_healthcheck.items() %}
|
||||
{{ key }}: {{ value }}
|
||||
{% endfor %}
|
||||
{% if freshrss_pids_limit is defined %}
|
||||
pids_limit: {{ freshrss_pids_limit }}
|
||||
{% endif %}
|
||||
|
||||
volumes:
|
||||
extensions:
|
||||
driver: local
|
||||
data:
|
||||
driver: local
|
Loading…
Reference in New Issue
Block a user