saltstack-formulas / salt-formula

Yes, Salt can Salt itself!
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
197 stars 423 forks source link

[BUG] file_tree not parsed correctly under ext_pillar #491

Closed lmf-mx closed 1 year ago

lmf-mx commented 3 years ago

Your setup

Formula commit hash / release tag

v1.7.0

Versions reports (master & minion)

Salt Version:
           Salt: 3001.3

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.7.3
      docker-py: Not Installed
          gitdb: 2.0.6
      gitpython: 3.0.7
         Jinja2: 2.10.1
        libgit2: 0.28.3
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: Not Installed
   pycryptodome: 3.6.1
         pygit2: 1.0.3
         Python: 3.8.5 (default, Jul 28 2020, 12:59:40)
   python-gnupg: 0.4.5
         PyYAML: 5.3.1
          PyZMQ: 18.1.1
          smmap: 2.0.5
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.2

System Versions:
           dist: ubuntu 20.04 focal
         locale: utf-8
        machine: x86_64
        release: 5.4.0-56-generic
         system: Linux
        version: Ubuntu 20.04 focal

Pillar / config used

<saltmaster.sls>
...
    ext_pillar:
      - git: 
        - master ssh://<a_valid_git_pillar_repo>.git
      - file_tree:
          root_dir: '/srv/pillar_files'
          follow_dir_links: False
          keep_newline: True
...

Bug details

Describe the bug

The ext_pillar rendering logic doesn't render the file_tree configuration successfully.

              /etc/salt/master.d/f_defaults.conf:
                  ----------
                  diff:
                      --- 
                      +++ 
                      @@ -910,13 +910,10 @@
                       ext_pillar:
                         - git:
                           - master ssh://git@<a_valid_git_pillar_repo>.git
                      -# Error in rendering file_tree, please read https://docs.saltstack.com/en/latest/topics/development/external_pillars.html#configuration
                      -    
                      -  - root_dir: /srv/pillar_files
                      -# Error in rendering follow_dir_links, please read https://docs.saltstack.com/en/latest/topics/development/external_pillars.html#configuration
                      -    
                      -# Error in rendering keep_newline, please read https://docs.saltstack.com/en/latest/topics/development/external_pillars.html#configuration
                      -    
                      +  - file_tree:
                      +    - root_dir
                      +    - follow_dir_links
                      +    - keep_newline
  docs.saltstack.com/en/latest/topics/development/external_pillars.html#configuration

Steps to reproduce the bug

Include a file_tree config under ext_pillar. (See above) Apply the salt state.

Expected behaviour

A correct output utilizing file_tree would be

ext_pillar:
  - git:
    - master ssh://<a_valid_git_pillar_repo>.git
  - file_tree:
      root_dir: '/srv/pillar_files'
      follow_dir_links: False
      keep_newline: True

Attempts to fix the bug

It appears the last elif section in the jinja template is or is close to what would render the correct output, but the file_tree section is caught by the previous elif.

Additional context

It behave the same regardless of platform or version.

lmf-mx commented 1 year ago

Revisited on 3006.1 and works properly