---

#
# This is the role for geoip-city-wsgi.
#
# install necessary packages
- name: install python-paste-deploy geolite2-city python2-iso3166 python2-geoip2
  package:
    name:
      - python-paste-deploy
      - geolite2-city
      - python2-iso3166
      - python2-geoip2
    state: present
  when: ansible_distribution_major_version|int < 8 and ansible_distribution == 'RedHat'

- name: install python3-paste-deploy geolite2-city python3-iso3166 python3-geoip2
  package:
    name:
      - python3-paste-deploy
      - geolite2-city
      - python3-iso3166
      - python3-geoip2
    state: present
  when: ansible_distribution_major_version|int >= 8 and ansible_distribution == 'RedHat'


- name: install geoip-city-wsgi.conf file
  copy: >
        src="geoip-city-wsgi.conf"
        dest="/etc/httpd/conf.d/geoip-city-wsgi.conf"
        owner=root
        group=root
        mode=0644
  notify:
  - reload httpd
  tags:
  - geoip_config
  - config
  - geoip-city-wsgi
  - geoip-city-wsgi/app

- name: setup /usr/share/geoip-city-wsgi directory
  file: >
        path=/usr/share/geoip-city-wsgi
        owner=root
        group=root
        mode=0755
        state=directory
  tags:
  - geoip_config
  - config
  - geoip-city-wsgi
  - geoip-city-wsgi/app

- name: install geoip-city.wsgi file
  copy: >
        src="geoip-city.wsgi"
        dest="/usr/share/geoip-city-wsgi/geoip-city.wsgi"
        owner=root
        group=root
        mode=0775
  notify:
  - reload httpd
  tags:
  - geoip_config
  - config
  - geoip-city-wsgi
  - geoip-city-wsgi/app
