jdauphant / ansible-role-nginx

Ansible role to install and manage nginx configuration
655 stars 302 forks source link

Missing mime.types file plus /etc/mime.types idea #240

Closed tcrowe closed 4 years ago

tcrowe commented 5 years ago

nginx -v nginx version: nginx/1.14.2

Linux, Debian buster


After running this role nginx could not start. It was missing /etc/nginx/mime.types. 🤔

I searched around the system for it finding /etc/mime.types but this approach didn't work because it's a different format than what nginx uses. In the end I get_url from nginx's repo.

- name: check nginx mime.types exists
  stat:
    path: "/etc/nginx/mime.types"
  register: nginx_mime_types_file

# 🚫doesn't work
# - name: create nginx mime.types from /etc/mime.types
#   shell: |
#     echo 'types {' > /etc/nginx/mime.types
#     cat /etc/mime.types >> /etc/nginx/mime.types
#     echo '}' >> /etc/nginx/mime.types
#   when: nginx_mime_types_file.stat.exists == False

# ✅works
- name: replace missing mime.types
  get_url:
    url: https://raw.githubusercontent.com/nginx/nginx/master/conf/mime.types
    dest: /etc/nginx/mime.types
  when: nginx_mime_types_file.stat.exists == False

If you think this is helpful I can create a PR. I'm not sure why the file was missing though. Have you guys seen this?

Thank you, -TC

tcrowe commented 5 years ago

mime.types included here: https://github.com/jdauphant/ansible-role-nginx/blob/55b3e789b0a9783b8db9ca5c93a81336ff70759f/templates/nginx.conf.j2#L29

jdauphant commented 5 years ago

Good idea for the PR :+1: Use {{ nginx_conf_dir }}| instead of /etc/nginx in that case ;)