title: Concatenate strings in Jinja?
body: <p>I'm trying to concatenate strings in a state, and I'm not having much luck.  I've seen the posts that suggest using (|join), but all my strings are not in a single dictionary.  Here's my code:</p>
  
  <pre><code>sshd_content:
    file.line:
  {% set admin_groups = '' %}
  {% for app in grains['application_groups'] %}
  {% for group in pillar['admin_users'][app]['members'] %}
  {% set admin_groups = admin_groups ~ ' ' ~ group ~ '@mydomain.com' %}
  {% endfor %}
  {% endfor %}
      - name: /etc/ssh/sshd_config
      - match: AllowGroups wheel fred
      - mode: replace
      - content: AllowGroups wheel fred bob {{ admin_groups }}
  </code></pre>
  
  <p>I've tried using + instead of ~ without luck, too.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>This state works fine:</p>
  
  <pre><code>sudoers_asmgroups_content:
    file.append:
      - name: /etc/sudoers.d/mygroups
      - text:
  {% for app in grains['application_groups'] %}
    {% for group in pillar['admin_users'][app]['members'] %}
        - '%{{ group }}@mydomain.com ALL=(ALL) ALL'
    {% endfor %}
  {% endfor %}
  </code></pre>