Skip to content

[BUG] sysrc.managed test=True TypeError: can only concatenate str (not "bool") to str #60048

@network-shark

Description

@network-shark

Description
When running sysrc.managed in test mode a bool is returned instead of a string . I could not figure out why , it only happens on one of my systems. Most of the time it works with the current code .

Setup

syssrc_vm_enable:
  sysrc.managed:
    - name: vm_enable
    - value: YES

Steps to Reproduce the behavior
salt '*' state.apply teststate test=True

Expected behavior

          ID: syssrc_vm_enable
    Function: sysrc.managed
        Name: vm_enable
      Result: None
     Comment: The value of "vm_enable" will be changed!
     Started: 20:45:55.254429
    Duration: 23.909 ms
     Changes:
              ----------
              new:
                  vm_enable = True will be set.
              old:
                  None

Versions Report

╰─ salt -V
Salt Version:
          Salt: 3002.6

Dependency Versions:
          cffi: 1.14.5
      cherrypy: Not Installed
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.11.2
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.10.1
        pygit2: Not Installed
        Python: 3.7.9 (default, Mar 27 2021, 01:17:51)
  python-gnupg: Not Installed
        PyYAML: 5.3.1
         PyZMQ: 22.0.3
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.1

System Versions:
          dist: freebsd 12.2
        locale: UTF-8
       machine: amd64
       release: 12.2-RELEASE-p4
        system: FreeBSD
       version: FreeBSD 12.2

Possible fix is salte/states/sysrc.py line 60

      if __opts__["test"] is True:
         ret["comment"] = 'The value of "{0}" will be changed!'.format(name)
         ret["changes"] = {
             "old": current_state,
             "new": name + " = " + str(value) + " will be set.",
         }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbroken, incorrect, or confusing behaviorseverity-low4th level, cosemtic problems, work around exists

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions