templates - Saltstack load pillar in a for loop -


i developing automatic proftd installation whit salt, wont ftp users template cant work pillar, initialized pillar whit users data , call loop, don't pillar user data in loop.

when make salt-call pillar.get ftpusers in minion, response is:

local:

this pillar ftpusers.sls:

ftp-server.ftpusers:   user:     - user: user     - passhash: j2k3hk134123l1234ljh!"·$ser     - uuid: 1001     - guid: 1001     - home: /srv/ftp/user     - shel: /bin/false 

and loop:

{% users in pillar.get('ftpusers', {}).items() %}    /srv/herma-ftp/.ftpusers:     file.managed:       - user: root       - group: root       - mode: 444       - contents:'{{ user }}:{{ args['passhash'] }}:{{args['uuid'] }}:{{ args['guid'] }}::{{ args['home'] }}:{{ args['shel'] }}'       - require:         - file: /srv/herma-ftp    /srv/herma-ftp/{{user}}:     file.directory:       - user: nobody       - group: nobody       - dir_mode: 775       - makedirs: true       - require:         - file: /srv/herma-ftp       - watch:         - file: /srv/herma-ftp     module.run:       - name: file.set_selinux_context       - path: {{ args['home']}}       - type: public_content_t       - unless:         - stat -c %c {{ args['home'] }} |grep -q public_content_t  {% endfor %} 

when make in minion

salt-call -l debug state.sls herma-ftp-server saltenv=my-enviroment test=true 

don't expect because don't can pillar data.

your loop should like:

{% user, args in pillar.get('ftpusers', {}).items() %} 

also, contents argument file.managed doesn't support templating. need move /srv/herma-ftp/.ftpusers state outside of loop, , make loop inside file template. final layout of state should like:

/srv/herma-ftp/.ftpusers   file.managed:     source: salt://ftpserver/dot.ftpusers     template: jinja     ...     ...  {% user, args in pillar.get('ftpusers', {}).items() %}  /srv/herma-ftp/{{user}}:   file.managed:     ...  {% endfor %} 

and ftpserver/dot.ftpusers like:

{% user, args in pillar.get('ftpusers', {}).items() %} {{ user }}:{{ args['passhash'] }}:{{args['uuid'] }}:{{ args['guid'] }}::{{ args['home'] }}:{{ args['shel'] }} {% endfor %} 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

delphi - Indy UDP Read Contents of Adata -