Open pavel-z1 opened 4 years ago
@pavel-z1 this is not possible because of how python interprets yaml. Can't find the documentation for this but it has something to do with orderd dicts
some issue on saltstack about this: https://github.com/saltstack/salt/issues/12161
Such behaviour cause issues on practice. This formula can't be used if need to configure map rules with variables, that will be used in limit rules.
For example, I need configure map in http section. I am configure pillar:
---
states:
- nginx
pillars:
nginx:
snippets:
limit_requests_per_domain.conf:
# Exclude IPs from $servername_key variable that used in limit_req_zone
- map $ip_exclude $servername_key:
- 0: '""'
- 1: $servername_firstcheck
server:
config:
http:
include:
- '/etc/nginx/mime.types'
- '/etc/nginx/snippets/limit_requests_per_domain.conf'
limit_req_zone:
- '$limit_ip zone=request_limit:10m rate=100r/s'
- 'limit_req_zone: $servername_key zone=perserver:10m rate=5r/s'
limit_req_log_level: warn
As result I will receive this configuration in nginx.conf:
# cat /etc/nginx/nginx.conf
# Default nginx server configuration
#
# **** DO NOT EDIT THIS FILE ****
#
# This file is managed by Salt.
.........
http {
limit_req_log_level warn;
limit_req_zone $limit_ip zone=request_limit:10m rate=100r/s;
limit_req_zone limit_req_zone: $servername_key zone=perserver:10m rate=5r/s;
include /etc/nginx/mime.types;
include /etc/nginx/snippets/limit_requests_per_domain.conf;
}
With nginx error:
# nginx -t
nginx: [emerg] invalid number of arguments in "limit_req_zone" directive in /etc/nginx/nginx.conf:21
nginx: configuration file /etc/nginx/nginx.conf test failed
Variables $servername_key started to use before being defined in map.
When we configure Nginx configuration file order for parameters is important. When I use Nginx-formula version 2.3.1 I receive different parameters order in my nginx.conf file comparing with Pillar parameters.
For example, Pillar:
Nginx configuration file nginx.conf:
How can be configured nginx formula to get the same parameters order in result files as in Pillar?
Salt version: