(Ansible) Error when trying to import Ansible variables even though roles are imported

Problem:
When trying to import Ansible variables into Foreman I get the following error:

undefined method `imported=' for #<AnsibleVariable:0x00007f7b643fcaa0>.

However, importing the Ansible roles worked.

Expected outcome:
Import the Ansible Variables in Foreman

Foreman and Proxy versions:
Foreman version: 2.4.0
Plugins:

  • foreman-tasks 4.0.1
  • foreman_ansible 6.1.1
  • foreman_bootdisk 17.0.2
  • foreman_hooks 0.3.17
  • foreman_remote_execution 4.2.2
  • foreman_setup 6.0.0

Distribution and version:
Debian GNU/Linux 10 (buster)
Linux rzvforeman02.vit.de 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux

ansible 2.9.20
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/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.16 (default, Oct 10 2019, 22:02:15) [GCC 8.3.0]

foreman_trace.log (13.5 KB)

That’s weird. Are you sure, you’ve run foreman-rake db:migrate after enabling the ansible plugin?
It should get run automatically by foreman-installer, but I’d like to make sure, because this method is added by Ansible migrations and only reason it could be missing is, that those migrations didn’t run.

If that didn’t help can you think of something that you’ve done in the past with the database?
The migration that is adding this method is 20190318094437_add_imported_attr_to_ansible_variables, you can run only that one if neccessary, let me know if foreman-rake db:migrate would not work and we can take it from there.

1 Like

I now fixed the error.
After the dbmigartion no result was to be seen, I have deselected the Ansible module in the Forman installer and then activated again and run each time.
Then run the DB-Migrartiomn again and now the import runs :slight_smile:

1 Like