saltstack-formulas/salt-formula

[BUG] master_job_cache renders incorrectly in the saltmaster config (doesn't use get_config{{}})

mdschmitt opened this issue · 0 comments

Your setup

Formula commit hash / release tag

master branch

Versions reports (master & minion)

Salt Version:
Salt: 3005.2

Dependency Versions:
cffi: 1.14.6
cherrypy: unknown
dateutil: 2.8.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.0
libgit2: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.9.8
pygit2: 1.7.1
Python: 3.9.17 (main, Aug 4 2023, 19:59:49)
python-gnupg: 0.4.8
PyYAML: 6.0.1
PyZMQ: 23.2.0
smmap: Not Installed
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4

Salt Extensions:
saltext.prometheus: 2.0.2

System Versions:
dist: amzn 2
locale: utf-8
machine: x86_64
release: 4.14.314-237.533.amzn2.x86_64
system: Linux
version: Amazon Linux 2

Pillar / config used (output from salt-call pillar.get salt on the master):

local:
    ----------
    gitfs:
        ----------
        pygit2:
            ----------
            git:
                ----------
                install_from_package:
                    git
            install_from_source:
                True
            libgit2:
                ----------
                install_from_source:
                    False
            version:
                1.7.1
    libgit2:
        libssh2
    master:
        ----------
        ext_pillar:
            |_
              ----------
              git:
                  |_
                    ----------
                    __env__ git@github.com:example/repo.git:
                        |_
                          ----------
                          name:
                              testing
                        |_
                          ----------
                          root:
                              pillar/testing
            |_
              ----------
              nodegroups:
                  ----------
                  pillar_name:
                      nodegroups
        file_roots:
            ----------
            __env__:
                - /srv/salt
        fileserver_backend:
            - roots
            - gitfs
        git_pillar_base:
            main
        git_pillar_privkey:
            /etc/salt/privkey
        git_pillar_provider:
            pygit2
        git_pillar_pubkey:
            /etc/salt/pubkey
        gitfs_base:
            main
        gitfs_privkey:
            /etc/salt/key
        gitfs_provider:
            pygit2
        gitfs_pubkey:
            /etc/salt/key.pub
        gitfs_remotes:
            |_
              ----------
              https://github.com/saltstack-formulas/chrony-formula.git:
                  |_
                    ----------
                    root:
                        chrony
                  |_
                    ----------
                    mountpoint:
                        salt://chrony
                  |_
                    ----------
                    all_saltenvs:
                        v1.3.0
            |_
              ----------
              https://github.com/saltstack-formulas/packages-formula.git:
                  |_
                    ----------
                    root:
                        packages
                  |_
                    ----------
                    mountpoint:
                        salt://packages
                  |_
                    ----------
                    all_saltenvs:
                        v0.16.0
            |_
              ----------
              https://github.com/saltstack-formulas/salt-formula.git:
                  |_
                    ----------
                    root:
                        salt
                  |_
                    ----------
                    mountpoint:
                        salt://salt
                  |_
                    ----------
                    all_saltenvs:
                        master
            |_
              ----------
              https://github.com/salt-formulas/salt-formula-auditd:
                  |_
                    ----------
                    root:
                        auditd
                  |_
                    ----------
                    mountpoint:
                        salt://auditd
                  |_
                    ----------
                    all_saltenvs:
                        master
        hash_type:
            sha256
        log_file:
            /var/log/salt/master
        log_level_logfile:
            info
        master_job_cache:
            sqlite3
        nodegroups:
            ----------
            cluster1:
                node1.cluster1.example.com
        peer_run:
            ----------
            .*:
                - vault.generate_token
        publisher_acl:
            ----------
            myuser|anotheruser:
                - config.get
                - grains.get
                - mine.get
                - service.status
        return:
            sqlite3
        show_jid:
            True
        sqlite3:
            ----------
            database:
                /var/salt/salt.db
            timeout:
                5.0
        state_output:
            changes
        state_verbose:
            False
        vault:
            ----------
            auth:
                ----------
                method:
                    approle
                role_id:
                    redacted
                secret_id:
                    redacted
            policies:
                - policy
            url:
                https://vault.example.com:8200
            verify:
                /etc/ssl/vault_cert.pem
        verify_env:
            False
    master_remove_config:
        True
    minion:
        ----------
        master:
            salt
        master_type:
            str
        metadata_server_grains:
            True
        pillarenv:
            base
        saltenv:
            base
        state_output:
            changes
        state_verbose:
            False
        vault:
            ----------
            verify:
                /etc/ssl/vault_cert.pem
    minion_remove_config:
        True
    pkgrepo_name:
        salt-amzn
    py_ver:
        py3
    release:
        3005
    repo:
        https://repo.saltproject.io/salt
    version:
        3005.2

Bug details

Describe the bug

Adding this to the pillar:

salt:
  master:
    master_job_cache: sqlite3

renders out in f_defaults.conf as:

master_job_cache:
  sqlite3

...which is invalid syntax and the saltmaster will not start.

Steps to reproduce the bug

https://github.com/saltstack-formulas/salt-formula/blob/master/salt/files/master.d/f_defaults.conf#L1828 is the source of the issue, because master_job_cache is not used in a {{ get_config('master_job_cache') }} line in the template.

Expected behaviour

in /etc/salt/master.d/f_defaults.conf (space-separated, not a sub-object):

master_job_cache: sqlite3

Attempts to fix the bug

N/A

Additional context

While we're at it, show_jid suffers from the same problem.