我试图覆盖默认主模板中的一个设置( server_names_hash_bucket_size
)。
文件状态中的注释“# Defaults 是在新的 NGINX 安装中找到的值。” 所以我认为启用nginx_config_main_template_enable
并覆盖正确的子键就可以了,因为它会保留其他值。
这不起作用,所以我注释掉了我对自定义设置的修改,并尝试应用仅将nginx_config_main_template_enable
设置为true
的角色,但它也失败了。
在nginx_config_main_template_enable
设置为true
情况下使用角色失败,默认角色值。
重现行为的步骤:
- 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
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'"
}
我没有关于它失败的“dict 对象”的更多信息,因为任务Dynamically generate NGINX main configuration file
具有 dest 文件( /etc/nginx/nginx.conf
)的后备默认值,因此不应该失败。
评论说“# Defaults 是在新的 NGINX 安装中找到的值。” 所以它应该使用默认值创建一个标准的nginx.conf
文件。
ansible 2.9.17
2.11.2
Debian Buster
发现了错误,按照传统,在此过程中还发现了其他一些错误。 其中之一是# Defaults are the values found in a fresh NGINX installation
评论不再成立。 我希望尽快准备好PR。 修复后的默认声明可能仍然不完全正确,但它应该比现在更接近 😄
完美,然后密切关注这一点:)
您好,PR 似乎确实解决了这个问题(只需确保将用户更新为 www-data,因为它是 Debian 上的默认 www 用户,而我的系统上不存在 nginx 用户)。 感谢您的快速修复:)