Hi all,
I’m wonder if it’s possible to pass variables from playbook to role which has template.
Example:
playbook.yml
- roles:
- { role: monit, monit_proc: “sshd”,monit_ssh_port: “25”}
monit role:
monit/templates/sshd.conf.j2 :
check process sshd with pidfile {{ monit_ssh_pid }}
group system
start program “/etc/init.d/ssh start”
stop program “/etc/init.d/ssh stop”
if failed port {{ monit_ssh_port }} protocol ssh then restart
if {{ monit_restarts }} restarts within {{ monit_cycles}} cycles then timeout
monit/tasks/main.yml :
- name: Add {{ monit_proc }}
template: src=/etc/ansible/configs/monit/monit.d/{{monit_proc}}.j2.conf
dest=/etc/monit/conf.d/{{monit_proc}}.conf
tags: - monit_cfg
Or maybe it’s wrong approach ?
Best regards,
Morbious