summaryrefslogtreecommitdiffstats
path: root/tasks/main.yml
blob: 9a97014d919a32ab0eb4f982856416bfc12b55db (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
---
# tasks file for MicroJoe.ttrss


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

- name: Install dependencies
  apt:
    name: "{{ item }}"
    state: present
  with_items:
    - python-psycopg2
    - postgresql
    - php-pgsql
    - php-curl

- 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 }}"
  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.0/fpm/pool.d/ttrss.conf
  notify: restart php-fpm

- name: Verify php-fpm configuration
  command: php-fpm7.0 --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