-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Overview
https://github.com/nginx/ansible-role-nginx-config/blob/main/templates/http/modules.j2#L181-L207 uses log
as the variable name to iterate over, but this rewrites the log
dict variable that it is evaluating. This makes multiple conditional statements unable to function.
Basic example in Python 3, reproducing the problem:
>>> log = { 'access':[1,2,3], 'error':[4,5,6] }
>>> for log in log['access']:
... print(log)
...
1
2
3
When I look for the second key in the dict, its missing:
>>> print(log['error'])
Traceback (most recent call last):
File "<python-input-24>", line 1, in <module>
print(log['error'])
~~~^^^^^^^^^
TypeError: 'int' object is not subscriptable
Instead, its the last value in the loop I just called.
3
Expected Behavior
Rename the loop variable to anything but log
(mylog
? i
?) so that declarations like:
log:
access:
- path: "/var/log/nginx/access.log"
error:
- path: "/var/log/nginx/error.log"
...will not throw an error
Steps to Reproduce the Bug
Try setting nginx_config_http_template
to this:
- template_file: http/default.conf.j2
deployment_location: "/etc/nginx/conf.d/{{ ansible_fqdn }}.conf"
backup: false
config:
servers:
- access:
allow: [127.0.0.0/8]
deny: all
autoindex:
enable: true
core:
index:
- index.html
- index.htm
listen:
- address: "{{ ansible_default_ipv4.address }}"
port: 80
default_server: true
root: "/mydir"
server_name: "{{ ansible_fqdn }}"
locations:
- location: "/pub"
access:
allow: [127.0.0.0/8]
deny: all
autoindex:
enable: true
core:
root: "/share/otherdir"
log:
access:
- path: "/var/log/nginx/access.log"
error:
- path: "/var/log/nginx/error.log"
Environment Details
- Target deployment platforms: local cluster
- Target OSs: AlmaLinux 9
- Host OS (where you are running Ansible from): AlmaLinux 9
- Version of the NGINX Ansible role (or specific commit): 2df2160
- Version of Ansible: ansible core 2.16.14
- How is Ansible being managed: Foreman 3.15.0
- Version of Jinja2 (if you are using any templating capability): 3.1.6
Additional Context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working