[英]In Ansible, how can I combine a default dictionary in a role with a dictionary passed to that role as an argument?
As a solution by example, consider role nginx-reverse-proxy
: 作为示例解决方案,请考虑角色
nginx-reverse-proxy
:
nginx-reverse-proxy/defaults/main.yml : nginx-反向代理/默认值/ main.yml :
default_nginx:
application_context: /{{ application_name }}-{{ application_component_name }}
reverse_proxy:
port: 8080
nginx-reverse-proxy/templates/reverse-proxy.conf : nginx-reverse-proxy / templates / reverse-proxy.conf :
{% set combined_nginx = default_nginx | combine(nginx, recursive=true) -%}
location {{ combined_nginx.application_context }} {
proxy_pass http://localhost:{{ combined_nginx.reverse_proxy.port }};
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
my-nginx-reverse-proxy-meta/main.yml : my-nginx-反向代理-meta / main.yml :
dependencies:
- selfcertification-service
- role: nginx-reverse-proxy
nginx: { reverse_proxy: { port: 8095 } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.