Starting ansible job template from Katello template

Is there a way to start a ansible template from a script ERB?

I tried just using <%= render_template “template_name” %> but it doesn’t appear to be using ansible to render the template. Any ideas? I want to perform a job that does both script and ansible tasks started from 1 template

Hi Gary,
If I understand correctly, you want to run ansible playbook from an ERB script?
If so, I think that rendering the template wouldn’t help here, because it is not triggering the execution of the ansible playbook.

Hi @nofaralfasi

Thanks for the reply, and yes that’s what I’ve observed as well. Is there anyway to trigger an Ansible playbook from an ERB template?

I figured this is what would have happened by default if I rendered the template and the rendered templates type was set to Ansible, but this doesn’t appear to be the case. It instead appears to be executing the template as if it’s another ERB script.

Any ideas on if this is possible or not…?

Cleanly? No.

However, if you have a job template for the script provider, it gets rendered on Foreman and then executed on the remote host. In theory you could have a script template that when run, would dump another rendered template onto the disk and you could then execute it either directly or by launching ansible-playbook yourself. I can’t say I’d recommend that though.

1 Like

Gotcha, thanks. And yeah, that’s a bit outside the scope of what I’m trying to accomplish.