saltstack-formulas / iscsi-formula

Manage iSCSI Target and Initiator via SaltStack (FreeBSD & GNU/Linux)
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
8 stars 7 forks source link

[BUG] open-iscsi config generation : wrong quote usage #40

Open sylvainfaivre opened 2 years ago

sylvainfaivre commented 2 years ago

Your setup

Formula commit hash / release tag

ab279d6f064067a1cfa3a6e0f50c003c708d3bd6

Versions reports (master & minion)

Salt Version:
          Salt: 3004

Dependency Versions:
          cffi: Not Installed
      cherrypy: 3.5.0
      dateutil: 2.5.3
     docker-py: Not Installed
         gitdb: 2.0.0
     gitpython: 2.1.1
        Jinja2: 2.9.4
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 2.6.1
  pycryptodome: 3.6.1
        pygit2: Not Installed
        Python: 3.5.3 (default, Apr  5 2021, 09:00:41)
  python-gnupg: Not Installed
        PyYAML: 3.12
         PyZMQ: 17.1.2
         smmap: 2.0.1
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.2.1

System Versions:
          dist: debian 9 stretch
        locale: UTF-8
       machine: x86_64
       release: 4.9.0-16-amd64
        system: Linux
       version: Debian GNU/Linux 9 stretch

Pillar / config used

See below


Bug details

Describe the bug

When using quotes in pillars, the formula generates config without quotes.

For example :

iscsi:
  config:
    data:
      open-iscsi:
        node.session.timeo.replacement_timeout: '86400'

Results in :

node.session.timeo.replacement_timeout = 86400

in the config file.

The opposite is true : pillar without quotes results in config file with quotes, which makes the config fail.

This is annoying, as the formula's pillar.examples contains lines with unquoted numeric values, so these result in a config file with quotes around these values, with breaks the config.

I am not proposing a PR to fix this, as I don't understand the logic in iscsi/initiator/config/files/default/open-iscsi.tmpl :

{{ shift }}{{ key }} = {{ value ~ '\n' if value is string else '"' ~ value ~ '"\n' }}

Steps to reproduce the bug

Expected behaviour

Attempts to fix the bug

Quoting all values in the pillars fixes this, for example :

node.session.timeo.replacement_timeout: '120'

is OK, but :

node.session.timeo.replacement_timeout: 120

(as seen in pillar.example) is wrong.

Additional context