Closed morsik closed 8 years ago
this is because, the yaml parsing isn't ordered,, we need some saltstack yaml guru to look at this, I don't have the interal saltstack knowledge to solve this...
@aboe76: I saw that people sometimes use list in formulas instead of dict when order is important. For example:
uwsgi:
emperor:
config:
- autoload: 'true'
- master: 'true'
- vacuum: 'true'
- workers: 2
- log-date: 'true'
- emperor: /etc/uwsgi.d
- memory-report: 1
- thunder-lock: 1
- socker: 0.0.0.0:0
- emperor-stats: /tmp/emperor-stats.sock
- emperor-nofollow: 1
- emperor-procname: uwsgi emperor
- procname-master: uwsgi emperor master
- if-not-reload: ''
- exec-as-user: 'fuse-zip -r /var/www/app001.zip /app'
- endif: ''
Of course you need to be backward compatible with dict (to prevent destroying old configs).
Another approach (above mixed with current dict):
uwsgi:
emperor:
config:
# this doesn't need to be in any order
- autoload: 'true'
master: 'true'
vacuum: 'true'
workers: 2
log-date: 'true'
# then put emperor entry
- emperor: /etc/uwsgi.d
# some emperor things
- memory-report: 1
thunder-lock: 1
socket: 0.0.0.0:0
emperor-stats: /tmp/emperor-stats.sock
emperor-nofollow: 1
emperor-procname: uwsgi emperor
procname-master: uwsgi emperor master
# this must be in order!
- if-not-reload: ''
- exec-as-user: 'fuse-zip -r /var/www/app001.zip /app'
- endif: ''
Would result in such config (written by hand). Sections inside would be sorted alphabetically, but outside, they could be rendered in list order.
[uwsgi]
autoload = true
log-date = true
master = true
no-orphans = true
vacuum = true
workers = 2
emperor = /etc/uwsgi.d
emperor-nofollow = 1
emperor-procname = uwsgi emperor
emperor-stats = /tmp/emperor-stats.sock
socket = 0.0.0.0:0
memory-report = 1
procname-master = uwsgi emperor master
thunder-lock = 1
if-not-reload =
exec-as-user = fuse-zip -r /var/www/app001.zip /app
endif =
@morsik can you close this issue?
@lgunsch: thanks!
uWSGI offers to do if directives inside configuration files. They are parse one-by-line, but I don't see it's possible to do with this formula right now.
Example (from http://uwsgi-docs.readthedocs.org/en/latest/tutorials/ReliableFuse.html):
Writing in pillar below code will result in rehashed/sorted keys inside, and will break that if:
Output in
/etc/uwsgi.ini
:This is really wrong.
endif
beforeif
.exec-as-user
broken.