Import ansible variables to foreman

Problem:
Hello
I imported ansible roles in foreman but cant import ansible variables (no errormessage).
Where foreman/foreman-proxy search for ansible variables?

My roles looks like:
   rolepath/roles/apache
                         - doku
                         - handlers
                         - meta
                         - tasks
                         - templates
                         - vars

and in folder vars i defined a lot off variables for example:

rolepath/roles/apache/vars/debian.yml
package_list: ['apache2', 'w3m']
httpd_conf_dir: '/etc/apache2/conf-available'

Expected outcome:
Import ansible roles correctly.

Foreman and Proxy versions:
foreman 1.21.0~rc5-1
foreman-proxy 1.21.0~rc5-1

Foreman and Proxy plugin versions:
ruby-foreman-ansible 2.3.1-1
ruby-smart-proxy-ansible 2.1.0-1

Any Idea?
mobios

Hi,
proxy searches the defaults dir in your roles. Role vars have very high priority and are difficult to override, is there a specific reason why you are using them?

When you do:
mv rolepath/roles/apache/vars/debian.yml rolepath/roles/apache/defaults/debian.yml
proxy should find the variables from debian.yml.

Hello Ondrej,
thanks for your help. We will move the variables to the right place.

Best regards
mobios

How do you load defaults from multiple files? Since ansible only loads main.yml AFAIK.

You can have role-path/defaults/main/{debian,ubuntu}.yml and Ansible will find them (tested on Ansible 2.7.8).

The role-path/defaults/debian.yml is ignored by Ansible, but proxy will import defaults from there as well, we are globbing the whole defaults dir. This might need a change to have the same behavior as Ansible.

Hello Ondrej,

Thank you for your help. But the problem still exists.
The VariableExtractor Class
--> /usr/lib/ruby/vendor_ruby/smart_proxy_ansible/variables_extractor.rb <--

searches for {{ }} in variables files. But as you can see in ansible documentation
https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#defining-variables-in-files

The contents of each variables file is a simple YAML dictionary, like this:
---
# in the above example, this would be vars/external_vars.yml
somevar: somevalue
password: magic

variable files look different to playbook files. Therfore the VariableExtractor violates
the ansible specs.

Can you check please.

The 2.1.0 version of smart_proxy_ansible had that, it is fixed in 2.1.1. Could you try to update if it resolves the issue for you?

Thanks for your help. I see the new version looks good but cant currently install. I included the foreman repos and with apt install i dont get the new version. Maybe i have to wait.

Best regards
mobios