Problem:
Maybe it’s a stupid question and I’m sorry for that but i’m not able to figure it out to run an ansible playbook during a provision/installation of a new VM.
I created an ansible playbook into /etc/ansible/roles called test.yml (eg configuring the server for joining the AD):
- hosts: all
tasks:
...
I imported it into Configure -> Ansible -> Roles and it’s active, I associated it to a new VM into the Ansible tab of the “Create Hosts” but nothing ran after foreman completed the provision.
I could run the playbook after the provision and it’s working properly or I can run it as a new job - I created a Job template:
---
- hosts: all
tasks:
....
but there is no way to run it during/after the provision.
I’ve also an error when I run the callback job/Play ansible roles:
---
- hosts: all
tasks:
- name: Display all parameters known for the Foreman host
debug:
var: foreman
roles:
<%- if @host.all_ansible_roles.present? -%>
<%= @host.all_ansible_roles.map { |role| " - #{role.name.strip}" }.join("\n") %>
<%- end -%>
the error:
[WARNING]: Ignoring invalid path provided to plugin path: '/etc/ansible/roles
/test.yml' is not a directory
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ok: [linux-test]
TASK [Display all parameters known for the Foreman host] ***********************
ok: [linux-test] =>
foreman:
comment: test linux
content_view: RHEL_Views
content_view_info:
components: {}
....
What am I missing?
Expected outcome:
Running an ansible playbook after the provision of the VM is finished as written/expected by documentation Foreman :: Plugin Manuals
Foreman and Proxy versions:
Foreman 1.22.1-1.el7
Katello 3.12.3-1.el7
rubygem-smart_proxy_ansible.noarch 2.1.2-3.fm1_22.el7
tfm-rubygem-foreman_ansible.noarch 3.0.2-1.fm1_22.el7
tfm-rubygem-foreman_ansible_core.noarch 3.0.0-1.fm1_22.el7
ansible 2.8.4
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Foreman and Proxy plugin versions:
Other relevant data:
My /etc/ansible/ansible.cfg is:
[defaults]
callback_whitelist = foreman
[callback_foreman]
url = 'https://foreman.mylan'
ssl_cert = /etc/foreman-proxy/foreman_ssl_cert.pem
ssl_key = /etc/foreman-proxy/foreman_ssl_key.pem
verify_certs = /etc/foreman-proxy/foreman_ssl_ca.pem
My /etc/foreman-proxy/ansible.cfg is:
[defaults]
callback_whitelist = foreman
local_tmp = /tmp
host_key_checking = False
stdout_callback = yaml
[callback_foreman]
url = 'https://foreman.mylan'
ssl_cert = /etc/foreman-proxy/foreman_ssl_cert.pem
ssl_key = /etc/foreman-proxy/foreman_ssl_key.pem
verify_certs = /etc/foreman-proxy/foreman_ssl_ca.pem