~nka/ansible-role-rssbridge

c80534bd5bcae3d9dbc0cd0eb6b7414ad63e968b — Nicolas KAROLAK 2 months ago master v1.0.0
init
4 files changed, 150 insertions(+), 0 deletions(-)

A defaults/main.yml
A handlers/main.yml
A meta/main.yml
A tasks/main.yml
A  => defaults/main.yml +45 -0
@@ 1,45 @@
---

rssbr_apache_mods:
  - 'remoteip'
rssbr_apache_remoteip: |
  RemoteIPHeader X-Real-IP
  {% for proxy in rssbr_trusted_proxies %}
  RemoteIPTrustedProxy {{ proxy }}
  {% endfor %}
rssbr_apache_vhost: |
  <VirtualHost *:80>
    DocumentRoot {{ rssbr_app_path }}
    ServerName {{ rssbr_domain }}

    <Directory {{ rssbr_app_path }}>
      AllowOverride All
    </Directory>
  </VirtualHost>
rssbr_app_name: 'rssbridge'
rssbr_app_path: '/var/www/{{ rssbr_app_name }}'
rssbr_bridges:
  - 'Facebook'
  - 'GoogleSearch'
  - 'Instagram'
  - 'Pinterest'
  - 'Twitter'
  - 'Wikipedia'
  - 'Youtube'
rssbr_domain: 'rssbr.example.net'
rssbr_packages:
  - 'apache2'
  - 'libapache2-mod-php'
  - 'php'
  - 'php-xml'
  - 'php-mbstring'
  - 'php-sqlite3'
  - 'php-curl'
  - 'php-json'
rssbr_settings:
  - section: 'cache'
    option: 'type'
    value: '"sqlite"'
rssbr_trusted_proxies: []
rssbr_url: 'https://github.com/RSS-Bridge/rss-bridge.git'
rssbr_version: '2020-02-26'

A  => handlers/main.yml +6 -0
@@ 1,6 @@
---

- name: 'restart apache'
  systemd:
    name: 'apache2'
    state: 'restarted'

A  => meta/main.yml +14 -0
@@ 1,14 @@
---

galaxy_info:
  author: Nicolas Karolak
  description: Install and configure a RSS-Bridge server with Apache2
  galaxy_tags: []
  license: WTFPL
  min_ansible_version: 2.9
  platforms:
    - name: 'Debian'
      versions:
        - 'buster'

dependencies: []

A  => tasks/main.yml +85 -0
@@ 1,85 @@
---

- name: 'install packages'
  notify: 'restart apache'
  apt:
    force_apt_get: true
    install_recommends: false
    name: '{{ rssbr_packages }}'

# APPLICATION

- name: 'clone application repository'
  git:
    repo: '{{ rssbr_url }}'
    version: '{{ rssbr_version }}'
    dest: '{{ rssbr_app_path }}'

- name: 'fix data permissions'
  file:
    path: '{{ rssbr_app_path }}/cache'
    owner: 'www-data'
    recurse: true
    state: 'directory'

- name: 'create configuration file'
  lineinfile:
    create: true
    insertbefore: 'BOF'
    line: '; <?php exit; ?>'
    path: '{{ rssbr_app_path }}/config.ini.php'

- name: 'configure settings'
  loop: '{{ rssbr_settings }}'
  ini_file:
    option: '{{ item.option }}'
    path: '{{ rssbr_app_path }}/config.ini.php'
    section: '{{ item.section }}'
    value: '{{ item.value }}'

- name: 'configure bridges list'
  copy:
    content: "{{ rssbr_bridges | join('\n') }}"
    dest: '{{ rssbr_app_path }}/whitelist.txt'

# SYSTEM CONFIGURATION

- name: 'remove default vhost'
  notify: 'restart apache'
  file:
    path: '/etc/apache2/sites-enabled/000-default.conf'
    state: 'absent'

- name: 'enable required apache modules'
  notify: 'restart apache'
  loop: '{{ rssbr_apache_mods }}'
  apache2_module:
    name: '{{ item }}'

- meta: 'flush_handlers'

- name: 'configure vhost'
  notify: 'restart apache'
  copy:
    dest: '/etc/apache2/sites-available/{{ rssbr_app_name }}.conf'
    content: '{{ rssbr_apache_vhost }}'

- name: 'enable vhost'
  notify: 'restart apache'
  command:
    cmd: 'a2ensite {{ rssbr_app_name }}.conf'
    creates: '/etc/apache2/sites-enabled/{{ rssbr_app_name }}.conf'

- name: 'configure remoteip'
  when: 'rssbr_trusted_proxies | length > 0'
  notify: 'restart apache'
  copy:
    dest: '/etc/apache2/conf-available/remoteip.conf'
    content: '{{ rssbr_apache_remoteip }}'

- name: 'enable remoteip'
  when: 'rssbr_trusted_proxies | length > 0'
  notify: 'restart apache'
  command:
    cmd: 'a2enconf remoteip.conf'
    creates: '/etc/apache2/conf-enabled/remoteip.conf'