Ansible-role-nginx-config: Configuring nginx.conf with default values fails with nginx_config_main_template_enable set to true

Created on 17 Jun 2021  ·  4Comments  ·  Source: nginxinc/ansible-role-nginx-config

Describe the bug

I am trying to override juste one setting (server_names_hash_bucket_size) in the default main template.
Comments in the file state "# Defaults are the values found in a fresh NGINX installation." so I thought enabling nginx_config_main_template_enable and just overriding the right subkey would do the trick as it would keep the others values.

This didn't work, so I commented out my modification about the custom setting and tried to apply the role with only nginx_config_main_template_enable set to true but it fails as well.

Using the role with nginx_config_main_template_enable set to true fails with default role values.

To reproduce

Steps to reproduce the behavior:

  1. Deploy NGINX Config role using playbook.yml
- name: NGINX
  hosts: nginx
  debugger: on_failed
  become: true

  pre_tasks:
  - name: Enabling nginx_config_main_template
    set_fact:
      nginx_config_main_template_enable: true
  roles:
  - role: nginxinc.nginx
  - role: nginxinc.nginx-config
  1. Output error is (with -vvv option for verbosity)
TASK [nginxinc.nginx-config : Dynamically generate NGINX main configuration file] ***********************************************************************************************************
task path: /home/xxx/ansible/yyy/roles/nginxinc.nginx-config/tasks/config/template-config.yml:37
fatal: [nginx_0]: FAILED! => {
    "changed": false,
    "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'dest'"
}

I don't have any more info on which 'dict object' it fails on, as the task Dynamically generate NGINX main configuration file has fallback default values for the dest file (/etc/nginx/nginx.conf) and thus shouldn't fail.

Expected behavior

Comments say "# Defaults are the values found in a fresh NGINX installation." so it should create a standard nginx.conf file with default values.

Your environment:

  • main
  • Version of Ansible: ansible 2.9.17
  • Version of Jinja2: 2.11.2
  • Target deployment platform: Debian Buster
bug

All 4 comments

Found the bug, and as is tradition, found a few other bugs while at it. One of them being that the # Defaults are the values found in a fresh NGINX installation comment no longer holds true. I'm hoping to have a PR ready asap. The defaults statement might still not be entirely true after the fix, but it should be closer than what it is now 😄

Perfect, keeping an eye on this then : )

148 should have fixed this issue. Check it out and lmk! 😄

Hello, the PR seems to fix the issue indeed (just had to make sure to update the user to www-data as it's the default www user on Debian and the nginx user didn't exist on my system). Thanks for the quick fix : )

Was this page helpful?
0 / 5 - 0 ratings