Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring nginx.conf with default values fails with nginx_config_main_template_enable set to true #147

Closed
luminouw opened this issue Jun 17, 2021 · 4 comments · Fixed by #148
Assignees
Labels
bug Something isn't working
Milestone

Comments

@luminouw
Copy link

luminouw commented Jun 17, 2021

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
@alessfg alessfg added the bug Something isn't working label Jun 17, 2021
@alessfg alessfg added this to To do in NGINX Configuration via automation Jun 17, 2021
@alessfg alessfg added this to the 0.4.0 milestone Jun 17, 2021
@alessfg alessfg self-assigned this Jun 17, 2021
@alessfg
Copy link
Collaborator

alessfg commented Jun 17, 2021

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 😄

@luminouw
Copy link
Author

Perfect, keeping an eye on this then : )

NGINX Configuration automation moved this from To do to Done Jun 21, 2021
@alessfg
Copy link
Collaborator

alessfg commented Jun 21, 2021

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

@luminouw
Copy link
Author

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 : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

2 participants