Lógica Ansible e Jinja2 para loops
Arquivo Variávelcreateuser
:
userslist:
- da_cel_upload
- da_tag_upload
Lógica Ansible:
- include_vars: group_vars/createuser
- name: Create custom file /etc/ssh/shhd_config for user configuration and restart sshd service
template: src=sshconfig.j2 dest=/etc/ssh/sshd_config
with_items: '{{userslist}}'
notify: restart ssh
Conteúdo desshconfig.j2
:
Match User {{ item }}
{% raw %}ChrootDirectory /home/{% endraw %}{{ item }}
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Saída que eu recebo/etc/ssh/sshd_config
:
Match User da_tag_upload
ChrootDirectory /home/da_tag_upload
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Saída que eu preciso:
Match User da_cel_upload
ChrootDirectory /home/da_tag_upload
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Match User da_tag_upload
ChrootDirectory /home/da_tag_upload
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
Por favor ajude.