summaryrefslogtreecommitdiffstats
path: root/tasks/main.yml
blob: 11db67ca05c000de7e5a0f49b49c5876c2120c5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
# tasks file for MicroJoe.ttrss

- name: Ensure "{{ ttrss_group }}" group exists
  group:
    name: "{{ ttrss_group }}"

- name: Ensure user exists
  user:
    name: "{{ ttrss_user }}"
    group: "{{ ttrss_group }}"
    home: "{{ ttrss_home }}"

- name: Install dependencies
  apt:
    name:
      - php-curl
      - php-fpm
      - php-intl
      - php-mbstring
      - php-pgsql
      - php-xml
      - postgresql
      - python-psycopg2
    state: present

- name: Create ttrss base directory
  file:
    path: "{{ ttrss_base }}"
    state: directory
    owner: "{{ ttrss_user }}"
    group: "{{ ttrss_group }}"

- name: Clone upstream git repository
  become: yes
  become_user: "{{ ttrss_user }}"
  git:
    repo: "{{ ttrss_repository }}"
    dest: "{{ ttrss_base }}"
    version: "{{ ttrss_version }}"
  register: git_updated

# PostgreSQL commands

- name: Create postgresql user
  become: yes
  become_user: postgres
  postgresql_user:
    name: "{{ ttrss_db_user }}"
    password: "{{ ttrss_db_password }}"

- name: Create postgresql database
  become: yes
  become_user: postgres
  postgresql_db:
    name: "{{ ttrss_db_name }}"
    owner: "{{ ttrss_db_user }}"
    encoding: UTF-8
    template: template0

# TODO: We currently have to remove the config.php file and enter the config
# by hand in order to initialize the SQL database

- name: Install ttrss configuration file
  template:
    src: templates/config.php.j2
    dest: "{{ ttrss_base }}/config.php"
    owner: ttrss
    group: www-data

- name: Install nginx configuration file {{ nginx_filename }}
  template:
    src: templates/nginx.j2
    dest: /etc/nginx/sites-available/{{ nginx_filename }}
    owner: root
    group: root
  notify: restart nginx

- name: Verify nginx configuration
  command: nginx -t
  changed_when: false

# php-fpm

- name: Install php-fpm pool configuration file
  template:
    src: templates/php-fpm.conf
    dest: /etc/php/7.3/fpm/pool.d/ttrss.conf
  notify: restart php-fpm

- name: Verify php-fpm configuration
  command: php-fpm7.3 --test
  changed_when: false

# Install update feed systemd service

- name: Install systemd update service
  template:
    src: templates/ttrss-update.service.j2
    dest: /etc/systemd/system/ttrss-update.service
    mode: 0664

- name: Enable systemd update service
  systemd:
    name: ttrss-update
    state: started
    enabled: yes
    daemon_reload: yes