Answers: <p>I was able to find the root of issue. The problem was in the configuration of salt master. After every change of reactor config, I must run <code>salt-call state.highstate</code> command on master to sync reactor source code changes with it. I missed this step and thus my reactor config differed from my original source code in IDE. So once I ran mentioned command, everything became in sync. Thanks everybody for help! </p>
  
  <p>P.S. regarding mentioned error, it occurred because I used kwarg in dev.sls for pillar and represented pillar as list: </p>
  
  <pre><code>&gt;     kwarg:
  &gt;      - pillar:
  &gt;          temp_var_transmit: {{ payload }}
  </code></pre>
  
  <p>Kwarg can not contain a list in this case. It may contain key:value format only. So the correct way is either use without kwarg as I did or remove hyphen near pillar.</p>
  
Answers: CC BY-SA 3.0
Answers: 2018-01-22T21:26:06.970Z
Answers: You might be relieved to know that things are changing in Nitrogen (if you every find you *can* upgrade) and you can [change the kwargs behavior](https://docs.saltstack.com/en/latest/topics/releases/2017.7.0.html#state-module-changes) beginning in this version. I would expect that might become the default behavior in oxygen or flurorine and the old syntax deprecated at some point.
Answers: James Shewey
Answers: CC BY-SA 3.0
Answers: 2018-01-21T13:55:30.403Z
Answers: 2018-01-21T14:04:10.993Z
Answers: 2018-01-21T14:04:10.993Z
Answers: user54
Body: <p>I have the next conf files for salt reactor: </p>
  
  <ol>
  <li>reactor.conf </li>
  </ol>
  
  <blockquote>
    <ul>
    <li>'salt/netapi/hook/cd':
    
    <ul>
    <li>/srv/reactor/dev.sls</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <ol start="2">
  <li>dev.sls</li>
  </ol>
  
  <blockquote>
  <pre><code># vim: sts=2 ts=2 sw=2 et ai
  
  {% set payload = data.get('post') %}
  
  {%      set master = [grains.fqdn] %}
  
  core|api|{{ master }}|jenkins-cd:
    runner.state.orchestrate:
      - tgt: {{ master }}
      - mods: myreactor.deploy
      - pillar:
          temp_var_transmit: {{ payload }}
  </code></pre>
  </blockquote>
  
  <ol start="3">
  <li>deploy.sls</li>
  </ol>
  
  <blockquote>
  <pre><code>{%      set payload = salt.pillar.get('temp_var_transmit') %}
  {%      set master = [grains.fqdn] %}
  my_state:
    salt.function:
      - name: cmd.run
      - tgt: {{ master }}
      - arg:
        - "salt-run state.orch my-reactor.cd_state pillar='{\"temp_var_transmit\":{\"host\":\"{{payload['host']}}\",\"artifact_id\":\"{{payload['artifact_id']}}\",\"artifact_version\":\"{{payload['artifact_version']}}\"}}'"
  {% endfor %}
  </code></pre>
    
    <p>4. cd_state.sls</p>
  
  <pre><code>{% set data = salt.pillar.get('temp_var_transmit') %}
  my_deploy:
    salt.state:
      - tgt: {{ member }}
      - expr_form: compound
      - sls: '{{ data.artifact_id }}_{{ data.artifact_version }}'
      - queue: true
      - test: {{ dry_run_mode }}
  </code></pre>
  </blockquote>
  
  <p>When I send API request and run salt-runner.events, I get the next error: </p>
  
  <pre><code>jid": "20180119065728472630", 
      "return": "Exception occurred in runner state.orchestrate: Traceback (most recent call last):\n  File \"/usr/lib/python2.7/dist-packages/salt/client/mixins.py\", line 395, in _low\n    data['return'] = self.functions[fun](*args, **kwargs)\nTypeError: orchestrate() argument after ** must be a mapping, not list\n", 
      "success": false, 
      "user": "Reactor"
  </code></pre>
  
  <p>Any thoughts? </p>
  
Comments: CC BY-SA 3.0
Comments: 2018-01-19T15:13:23.547Z
Comments: **TypeError: orchestrate() argument after ** must be a mapping, not list\n"**  => sounds like you have a problem in your payload (or jsut a hyphen missing before your `temp_var_transmit`
Comments: Tensibai
Comments: CC BY-SA 3.0
Comments: 2018-01-19T18:07:04.257Z
Comments: What version of saltstack are you running?
Comments: James Shewey
Comments: CC BY-SA 3.0
Comments: 2018-01-19T18:11:29.490Z
Comments: @JamesShewey, 2016.11.1 (Carbon)
Comments: user54
Comments: CC BY-SA 3.0
Comments: 2018-01-19T18:15:09.170Z
Comments: You might try upgrading to nitrogen to see if there was a known issue.
Comments: James Shewey
Comments: CC BY-SA 3.0
Comments: 2018-01-19T18:20:42.983Z
Comments: Unfortunately, can not upgrade in my case.
Comments: user54
Tags: <configuration-management><salt>
Title: SaltStack Reactor fails with exception
UserDisplayName: user54
ThreadText: # SaltStack Reactor fails with exception
  
  (Asked by: username_0 on 2018-01-19)
  
  I have the next conf files for salt reactor:
  
  1. reactor.conf
  
  > * 'salt/netapi/hook/cd':
  >   + /srv/reactor/dev.sls
  
  2. dev.sls
  
  > ```
  > # vim: sts=2 ts=2 sw=2 et ai
  >
  > {% set payload = data.get('post') %}
  >
  > {%      set master = [grains.fqdn] %}
  >
  > core|api|{{ master }}|jenkins-cd:
  >   runner.state.orchestrate:
  >     - tgt: {{ master }}
  >     - mods: myreactor.deploy
  >     - pillar:
  >         temp_var_transmit: {{ payload }}
  >
  > ```
  
  3. deploy.sls
  
  > ```
  > {%      set payload = salt.pillar.get('temp_var_transmit') %}
  > {%      set master = [grains.fqdn] %}
  > my_state:
  >   salt.function:
  >     - name: cmd.run
  >     - tgt: {{ master }}
  >     - arg:
  >       - "salt-run state.orch my-reactor.cd_state pillar='{\"temp_var_transmit\":{\"host\":\"{{payload['host']}}\",\"artifact_id\":\"{{payload['artifact_id']}}\",\"artifact_version\":\"{{payload['artifact_version']}}\"}}'"
  > {% endfor %}
  >
  > ```
  >
  > 4. cd\_state.sls
  >
  > ```
  > {% set data = salt.pillar.get('temp_var_transmit') %}
  > my_deploy:
  >   salt.state:
  >     - tgt: {{ member }}
  >     - expr_form: compound
  >     - sls: '{{ data.artifact_id }}_{{ data.artifact_version }}'
  >     - queue: true
  >     - test: {{ dry_run_mode }}
  >
  > ```
  
  When I send API request and run salt-runner.events, I get the next error:
  
  ```
  jid": "20180119065728472630", 
      "return": "Exception occurred in runner state.orchestrate: Traceback (most recent call last):\n  File \"/usr/lib/python2.7/dist-packages/salt/client/mixins.py\", line 395, in _low\n    data['return'] = self.functions[fun](*args, **kwargs)\nTypeError: orchestrate() argument after ** must be a mapping, not list\n", 
      "success": false, 
      "user": "Reactor"
  
  ```
  
  Any thoughts?
  
  **Tags:** configuration-management, salt
  
  > **Comments:**
  > **username_1**: **TypeError: orchestrate() argument after ** must be a mapping, not list\n"**  => sounds like you have a problem in your payload (or jsut a hyphen missing before your `temp_var_transmit`  
  > **username_2**: What version of saltstack are you running?  
  > **username_0**: @username_2, 2016.11.1 (Carbon)  
  > **username_2**: You might try upgrading to nitrogen to see if there was a known issue.  
  > **username_0**: Unfortunately, can not upgrade in my case.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-01-21. Score: 1 | Accepted answer
  
  I was able to find the root of issue. The problem was in the configuration of salt master. After every change of reactor config, I must run `salt-call state.highstate` command on master to sync reactor source code changes with it. I missed this step and thus my reactor config differed from my original source code in IDE. So once I ran mentioned command, everything became in sync. Thanks everybody for help!
  
  P.S. regarding mentioned error, it occurred because I used kwarg in dev.sls for pillar and represented pillar as list:
  
  ```
  >     kwarg:
  >      - pillar:
  >          temp_var_transmit: {{ payload }}
  
  ```
  
  Kwarg can not contain a list in this case. It may contain key:value format only. So the correct way is either use without kwarg as I did or remove hyphen near pillar.
  
  > **Comments:**
  > **username_2**: You might be relieved to know that things are changing in Nitrogen (if you every find you *can* upgrade) and you can [change the kwargs behavior](https://docs.saltstack.com/en/latest/topics/releases/2017.7.0.html#state-module-changes) beginning in this version. I would expect that might become the default behavior in oxygen or flurorine and the old syntax deprecated at some point.  
  
  ---
  
  