- name: set nginx_cfg
  set_fact:
    nginx_cfg: "{{ nginx_default_config | d({}) | combine(nginx_config | d({}), recursive=true) }}"


- name: set container mount dirs
  set_fact:
    container_config_mount: /etc/nginx/conf
    container_logs_mount: /var/log/nginx


- name: copy geoip db
  copy:
    src: dbip-country-lite.mmdb
    dest: "{{ (conf_dir, 'geoip.mmdb') | path_join }}"


- name: download mime types
  get_url:
    url: https://raw.githubusercontent.com/nginx/nginx/master/conf/mime.types
    dest: "{{ (conf_dir, 'mime.types') | path_join }}"


- name: template nginx config
  template:
    src: nginx.j2
    dest: "{{ (conf_dir, 'nginx.conf') | path_join }}"
    lstrip_blocks: yes
    force: yes
