Answers: <p>You didn't say how the sls file is executed.</p>
  
  <ul>
  <li>One way would be to <a href="https://docs.saltstack.com/en/getstarted/config/pillar.html#salt-pillar-on-the-command-line" rel="nofollow noreferrer">pass pillars on command line</a>:</li>
  </ul>
  
  <pre><code>salt '*' state.apply ftpsync pillar='{"ftpusername": "test", "ftppassword": "0ydyfww3giq8"}'
  </code></pre>
  
  <ul>
  <li><p>Or you can set the group name as a <a href="https://docs.saltstack.com/en/latest/topics/grains/" rel="nofollow noreferrer">grain</a> on the minion in advance.</p></li>
  <li><p>Yet another way would be to set the group name as a jinja variable in the sls formula, depending on the hostname grain. Assuming your host names are set and standardized.</p></li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2019-03-16T10:53:52.223Z
Answers: 2019-03-16T10:53:52.223Z
Answers: bgdnlp
Body: <p>I have a Jenkins job with string parameter as target "server1,server2". Jenkins pipeline script is expected to execute the job on server1 and server2 respectively.
  There is a common salt sls file that updates directory permissions and groups on both servers. The expectation is when the job is executed on server1, a group by name xx-server1-yy must be created and updated in server1, similarly a group xx-server2-yy be created in server2 only.
  One sls file for Jenkins job on multiple servers with groups created specific to each server. What is the best approach?</p>
  
Tags: <jenkinsfile><salt><groovy>
Title: How to assign saltstack pillar values from Jenkins comma separated input parameters?
UserDisplayName: Narasimha
ThreadText: # How to assign saltstack pillar values from Jenkins comma separated input parameters?
  
  (Asked by: username_0 on 2019-03-08)
  
  I have a Jenkins job with string parameter as target "server1,server2". Jenkins pipeline script is expected to execute the job on server1 and server2 respectively.
  There is a common salt sls file that updates directory permissions and groups on both servers. The expectation is when the job is executed on server1, a group by name xx-server1-yy must be created and updated in server1, similarly a group xx-server2-yy be created in server2 only.
  One sls file for Jenkins job on multiple servers with groups created specific to each server. What is the best approach?
  
  **Tags:** jenkinsfile, salt, groovy
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-03-16. Score: 1
  
  You didn't say how the sls file is executed.
  
  * One way would be to [pass pillars on command line](https://docs.saltstack.com/en/getstarted/config/pillar.html#salt-pillar-on-the-command-line):
  
  ```
  salt '*' state.apply ftpsync pillar='{"ftpusername": "test", "ftppassword": "0ydyfww3giq8"}'
  
  ```
  
  * Or you can set the group name as a [grain](https://docs.saltstack.com/en/latest/topics/grains/) on the minion in advance.
  * Yet another way would be to set the group name as a jinja variable in the sls formula, depending on the hostname grain. Assuming your host names are set and standardized.
  
  
  ---
  
  