Skip to content

Unexpected character when running state in orchestartor #53375

@vlebo

Description

@vlebo

Description of Issue

When setting jinja variable with {% set dns_name = '-'.join(instance.split('-')[1:]) %} it works fine when state is applied from master or ran with salt-call. When running in orch it adds ' char at the end

Setup

/srv/salt/test/init.sls

# -*- coding: utf-8 -*-
# Set variables
{% set instance_list = salt['pillar.get']('records:instances', ['default_instance']) %}

call_state:
  salt.runner:
    - name: state.orchestrate
    - arg:
      - test.create
    - kwarg:
        pillar:
          records:
            instances: {{ instance_list }}

/srv/salt/test/create.sls

# -*- coding: utf-8 -*-
# set variables
{% set instance_list = salt['pillar.get']('records:instances', ['default_instance']) %}

{% for instance in instance_list  %}
{% set dns_name = '-'.join(instance.split('-')[1:]) %}
{% set len = dns_name|length %}

echo "name {{ dns_name }}":
  cmd.run

echo length {{ len }}:
  cmd.run
{% endfor %}

Steps to Reproduce Issue

Running with salt-call state.sls test.create pillar='{"records": { "env": "qa", "instances": [ 'qa-minion2'] }}' i get expected result

----------
          ID: echo "name minion2"
    Function: cmd.run
      Result: True
     Comment: Command "echo "name minion2"" run
     Started: 23:15:54.642170
    Duration: 24.821 ms
     Changes:   
              ----------
              pid:
                  8658
              retcode:
                  0
              stderr:
              stdout:
                  name minion2
----------
          ID: echo length 7
    Function: cmd.run
      Result: True
     Comment: Command "echo length 7" run
     Started: 23:15:54.667298
    Duration: 21.532 ms
     Changes:   
              ----------
              pid:
                  8659
              retcode:
                  0
              stderr:
              stdout:
                  length 7

Summary for local
------------
Succeeded: 2 (changed=2)
Failed:    0
------------
Total states run:     2
Total run time:  46.353 ms

But when running with salt-run state.orch test pillar='{"records": { "instances": [ 'qa-minion2'] }}'

          ID: call_state
    Function: salt.runner
        Name: state.orchestrate
      Result: True
     Comment: Runner function 'state.orchestrate' executed.
     Started: 23:16:52.411937
    Duration: 1265.393 ms
     Changes:                 
              qa-mlg-ubuntu-vla-bla_master:
              ----------
                        ID: echo "name minion2'"
                  Function: cmd.run
                    Result: True
                   Comment: Command "echo "name minion2'"" run
                   Started: 23:16:53.623865
                  Duration: 24.625 ms
                   Changes:   
                            ----------
                            pid:
                                8786
                            retcode:
                                0
                            stderr:
                            stdout:
                                name minion2'
              ----------
                        ID: echo length 8
                  Function: cmd.run
                    Result: True
                   Comment: Command "echo length 8" run
                   Started: 23:16:53.648729
                  Duration: 22.95 ms
                   Changes:   
                            ----------
                            pid:
                                8787
                            retcode:
                                0
                            stderr:
                            stdout:
                                length 8
              
              Summary for qa-mlg-ubuntu-vla-bla_master
              ------------
              Succeeded: 2 (changed=2)
              Failed:    0
              ------------
              Total states run:     2
              Total run time:  47.575 ms

Summary for qa-mlg-ubuntu-vla-bla_master
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time:   1.265 s

Am i doing something wrong here? It messes up couple of states like adding DNS record wirg boto3_route53 with error

[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1933, in call
    **cdata['kwargs'])
  File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1939, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/states/boto3_route53.py", line 553, in rr_present
    if rr.startswith('magic:'):
AttributeError: 'OrderedDict' object has no attribute 'startswith'

[ERROR   ] {u'return': {u'outputter': u'highstate', u'data': {u'qa-mlg-ubuntu-vla-bla_master': {u"boto3_route53_|-create_A_record_u'qa-minion2'_|-minion2'.qa.aws.mlg._|-rr_present": {u'comment': u'An exception occurred in this state: Traceback (most recent call last):\n  File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1933, in call\n    **cdata[\'kwargs\'])\n  File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1939, in wrapper\n    return f(*args, **kwargs)\n  File "/usr/lib/python2.7/dist-packages/salt/states/boto3_route53.py", line 553, in rr_present\n    if rr.startswith(\'magic:\'):\nAttributeError: \'OrderedDict\' object has no attribute \'startswith\'\n', u'name': u"minion2'.qa.aws.mlg.", u'start_time': '23:27:14.060745', u'result': False, u'duration': 1043.448, u'__run_num__': 0, u'__sls__': u'route53.createArecord', u'changes': {}, u'__id__': u"create_A_record_u'qa-minion2'"}}}, u'retcode': 1}}
qa-mlg-ubuntu-vla-bla_master:
----------
          ID: call_dns_create_record_state
    Function: salt.runner
        Name: state.orchestrate
      Result: False
     Comment: Runner function 'state.orchestrate' failed.
     Started: 23:27:12.134361
    Duration: 2979.532 ms
     Changes:                 
              qa-mlg-ubuntu-vla-bla_master:
              ----------
                        ID: create_A_record_u'qa-minion2'
                  Function: boto3_route53.rr_present
                      Name: minion2'.qa.aws.mlg.
                    Result: False
                   Comment: An exception occurred in this state: Traceback (most recent call last):
                              File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1933, in call
                                **cdata['kwargs'])
                              File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1939, in wrapper
                                return f(*args, **kwargs)
                              File "/usr/lib/python2.7/dist-packages/salt/states/boto3_route53.py", line 553, in rr_present
                                if rr.startswith('magic:'):
                            AttributeError: 'OrderedDict' object has no attribute 'startswith'
                   Started: 23:27:14.060745
                  Duration: 1043.448 ms
                   Changes:   
              
              Summary for qa-mlg-ubuntu-vla-bla_master
              ------------
              Succeeded: 0
              Failed:    1
              ------------
              Total states run:     1
              Total run time:   1.043 s

Summary for qa-mlg-ubuntu-vla-bla_master
------------
Succeeded: 0 (changed=1)
Failed:    1
------------
Total states run:     1
Total run time:   2.980 s

Versions Report

           Salt: 2019.2.0
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: 3.2.2
       dateutil: 2.7.3
      docker-py: Not Installed
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: 0.9.1
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.6 (default, Nov 23 2017, 15:49:48)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.0.1
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
 
System Versions:
           dist: Ubuntu 14.04 trusty
         locale: UTF-8
        machine: x86_64
        release: 3.13.0-149-generic
         system: Linux
        version: Ubuntu 14.04 trusty

Metadata

Metadata

Assignees

No one assigned

    Labels

    ConfirmedSalt engineer has confirmed bug/feature - often including a MCVEbugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions