{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack-formulas/uwsgi-formula/issues/8","labels_url":"https://api.github.com/repos/saltstack-formulas/uwsgi-formula/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/saltstack-formulas/uwsgi-formula/issues/8/comments","events_url":"https://api.github.com/repos/saltstack-formulas/uwsgi-formula/issues/8/events","html_url":"https://github.com/saltstack-formulas/uwsgi-formula/issues/8","id":119589277,"number":8,"title":"Impossible to create \"if\" rules","user":{"login":"morsik","id":783794,"avatar_url":"https://avatars.githubusercontent.com/u/783794?v=3","gravatar_id":"","url":"https://api.github.com/users/morsik","html_url":"https://github.com/morsik","followers_url":"https://api.github.com/users/morsik/followers","following_url":"https://api.github.com/users/morsik/following{/other_user}","gists_url":"https://api.github.com/users/morsik/gists{/gist_id}","starred_url":"https://api.github.com/users/morsik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morsik/subscriptions","organizations_url":"https://api.github.com/users/morsik/orgs","repos_url":"https://api.github.com/users/morsik/repos","events_url":"https://api.github.com/users/morsik/events{/privacy}","received_events_url":"https://api.github.com/users/morsik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-30T21:53:45Z","updated_at":"2015-12-01T10:20:44Z","closed_at":null,"body":"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.\r\n\r\nExample (from http://uwsgi-docs.readthedocs.org/en/latest/tutorials/ReliableFuse.html):\r\n```ini\r\nif-not-reload =\r\n  exec-as-user = fuse-zip -r /var/www/app001.zip /app\r\nendif =\r\n```\r\n\r\nWriting in pillar below code will result in rehashed/sorted keys inside, and will break that if:\r\n```yaml\r\nuwsgi:\r\n  emperor:\r\n    config:\r\n      autoload: 'true'\r\n      master: 'true'\r\n      vacuum: 'true'\r\n      workers: 2\r\n      log-date: 'true'\r\n\r\n      emperor: /etc/uwsgi.d\r\n\r\n      memory-report: 1\r\n      thunder-lock: 1\r\n      socker: 0.0.0.0:0\r\n      emperor-stats: /tmp/emperor-stats.sock\r\n      emperor-nofollow: 1\r\n      emperor-procname: uwsgi emperor\r\n      procname-master: uwsgi emperor master\r\n\r\n      if-not-reload: ''\r\n      exec-as-user: 'fuse-zip -r /var/www/app001.zip /app'\r\n      endif: ''\r\n```\r\n\r\nOutput in `/etc/uwsgi.ini`:\r\n```ini\r\n[uwsgi]\r\n\r\nautoload = true\r\nemperor = /etc/uwsgi.d\r\nemperor-nofollow = 1\r\nemperor-procname = uwsgi emperor\r\nemperor-stats = /tmp/emperor-stats.sock\r\nendif = \r\nexec-as-user = fuse-zip -r /var/www/app001.zip /app\r\ngid = uwsgi\r\nif-not-reload = \r\nlog-date = true\r\nmaster = true\r\nmemory-report = 1\r\nno-orphans = true\r\nprocname-master = uwsgi emperor master\r\nsocker = 0.0.0.0:0\r\nthunder-lock = 1\r\nuid = uwsgi\r\nvacuum = true\r\nworkers = 2\r\n```\r\n\r\nThis is really wrong. `endif` before `if`. `exec-as-user` broken."},"comment":{"url":"https://api.github.com/repos/saltstack-formulas/uwsgi-formula/issues/comments/160926277","html_url":"https://github.com/saltstack-formulas/uwsgi-formula/issues/8#issuecomment-160926277","issue_url":"https://api.github.com/repos/saltstack-formulas/uwsgi-formula/issues/8","id":160926277,"user":{"login":"morsik","id":783794,"avatar_url":"https://avatars.githubusercontent.com/u/783794?v=3","gravatar_id":"","url":"https://api.github.com/users/morsik","html_url":"https://github.com/morsik","followers_url":"https://api.github.com/users/morsik/followers","following_url":"https://api.github.com/users/morsik/following{/other_user}","gists_url":"https://api.github.com/users/morsik/gists{/gist_id}","starred_url":"https://api.github.com/users/morsik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morsik/subscriptions","organizations_url":"https://api.github.com/users/morsik/orgs","repos_url":"https://api.github.com/users/morsik/repos","events_url":"https://api.github.com/users/morsik/events{/privacy}","received_events_url":"https://api.github.com/users/morsik/received_events","type":"User","site_admin":false},"created_at":"2015-12-01T10:20:44Z","updated_at":"2015-12-01T10:20:44Z","body":"@aboe76: I saw that people sometimes use list in formulas instead of dict when order is important.\r\nFor example:\r\n```yaml\r\nuwsgi:\r\n  emperor:\r\n    config:\r\n      - autoload: 'true'\r\n      - master: 'true'\r\n      - vacuum: 'true'\r\n      - workers: 2\r\n      - log-date: 'true'\r\n\r\n      - emperor: /etc/uwsgi.d\r\n\r\n      - memory-report: 1\r\n      - thunder-lock: 1\r\n      - socker: 0.0.0.0:0\r\n      - emperor-stats: /tmp/emperor-stats.sock\r\n      - emperor-nofollow: 1\r\n      - emperor-procname: uwsgi emperor\r\n      - procname-master: uwsgi emperor master\r\n\r\n      - if-not-reload: ''\r\n      - exec-as-user: 'fuse-zip -r /var/www/app001.zip /app'\r\n      - endif: ''\r\n```\r\n\r\nOf course you need to be backward compatible with dict (to prevent destroying old configs).\r\n\r\nAnother approach (above mixed with current dict):\r\n\r\n```yaml\r\nuwsgi:\r\n  emperor:\r\n    config:\r\n      # this doesn't need to be in any order\r\n      - autoload: 'true'\r\n        master: 'true'\r\n        vacuum: 'true'\r\n        workers: 2\r\n        log-date: 'true'\r\n\r\n      # then put emperor entry\r\n      - emperor: /etc/uwsgi.d\r\n\r\n      # some emperor things\r\n      - memory-report: 1\r\n        thunder-lock: 1\r\n        socket: 0.0.0.0:0\r\n        emperor-stats: /tmp/emperor-stats.sock\r\n        emperor-nofollow: 1\r\n        emperor-procname: uwsgi emperor\r\n        procname-master: uwsgi emperor master\r\n\r\n      # this must be in order!\r\n      - if-not-reload: ''\r\n      - exec-as-user: 'fuse-zip -r /var/www/app001.zip /app'\r\n      - endif: ''\r\n```\r\n\r\nWould result in such config (written by hand). Sections inside would be sorted alphabetically, but outside, they could be rendered in list order.\r\n```ini\r\n[uwsgi]\r\n\r\nautoload = true\r\nlog-date = true\r\nmaster = true\r\nno-orphans = true\r\nvacuum = true\r\nworkers = 2\r\n\r\nemperor = /etc/uwsgi.d\r\n\r\nemperor-nofollow = 1\r\nemperor-procname = uwsgi emperor\r\nemperor-stats = /tmp/emperor-stats.sock\r\nsocket = 0.0.0.0:0\r\nmemory-report = 1\r\nprocname-master = uwsgi emperor master\r\nthunder-lock = 1\r\n\r\nif-not-reload = \r\nexec-as-user = fuse-zip -r /var/www/app001.zip /app\r\nendif = \r\n```"}}