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
# https://miniflux.app/docs/installation.html#docker

- name: Set up the Miniflux db
  hosts: lotus-land-story
  become: true
  become_user: postgres
  tasks:

    - name: Create the Miniflux db
      community.postgresql.postgresql_db:
        name: miniflux
      notify: Restart postgres

    - name: Create the Miniflux db user
      community.postgresql.postgresql_user:
        login_db: miniflux
        name: miniflux
        password: "{{ miniflux.db_password }}"
      notify: Restart postgres

    - name: Grant Miniflux access to the db
      community.postgresql.postgresql_pg_hba:
        dest: /etc/postgresql/13/main/pg_hba.conf
        contype: host
        users: miniflux
        source: samenet # TODO Can this be restricted to docker_ip?
        databases: miniflux
        create: true
      notify: Restart postgres

    - name: Install hstore
      community.postgresql.postgresql_ext:
        name: hstore
        login_db: miniflux
      notify: Restart postgres

  handlers:
    - name: Import restarts
      ansible.builtin.import_tasks: restarts.yml
      become: true
      become_user: root

- name: Run Miniflux
  hosts: lotus-land-story
  vars:
    version: "{{ versions.miniflux }}"
  tasks:

    - name: Get docker network
      community.docker.docker_network:
        name: lotus_land_story
      register: docker_network

    - name: Run Miniflux
      community.docker.docker_container:
        restart: true
        name: miniflux
        image: miniflux/miniflux:{{ version }}
        env:
          DATABASE_URL: postgres://miniflux:{{ miniflux.db_password }}@host.docker.internal/miniflux
          RUN_MIGRATIONS: "1"
          CREATE_ADMIN: "1"
          ADMIN_USERNAME: alpha
          ADMIN_PASSWORD: "{{ miniflux.password }}"
          AUTH_PROXY_HEADER: Remote-User
          AUTH_PROXY_USER_CREATION: "0"
          TRUSTED_REVERSE_PROXY_NETWORKS: "{{ docker_network.network.IPAM.Config[0].Subnet }}"
          BASE_URL: https://rss/
          DISABLE_LOCAL_AUTH: "0"
          METRICS_COLLECTOR: "1"
          METRICS_ALLOWED_NETWORKS: "{{ docker_network.network.IPAM.Config[0].Subnet }}"
          LOG_FORMAT: json
          LOG_LEVEL: info
        restart_policy: unless-stopped
        networks:
          - name: lotus_land_story
        etc_hosts:
          host.docker.internal: host-gateway
      no_log: true

  handlers:
    - name: Import restarts
      ansible.builtin.import_tasks: restarts.yml

# vim: ft=yaml.ansible