Foreman ansible error - 'NoneType' object has no attribute 'set_options'

Every job in foreman ansible returns ERROR! Unexpected Exception, this is probably a bug: ‘NoneType’ object has no attribute 'set_options’

Executing the same template locally with ansible-playbook echo.yaml -i localhost, completes successfully so this seems to be a foreman configuration issue.

This is Foreman 3.1 on Ubuntu 20.04

Job log:

ansible-playbook 2.9.6
  config file = /usr/share/foreman-proxy/.ansible.cfg
  configured module search path = ['/usr/share/foreman-proxy/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
Using /usr/share/foreman-proxy/.ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /tmp/d20220125-688-fjw2ek/inventory/hosts as it did not pass its verify_file() method
Parsed /tmp/d20220125-688-fjw2ek/inventory/hosts inventory source with script plugin
Loading callback plugin awx_display of type stdout, v2.0 from /usr/lib/python3/dist-packages/ansible_runner/callbacks/awx_display.py
ERROR! Unexpected Exception, this is probably a bug: 'NoneType' object has no attribute 'set_options'
the full traceback was:
 
Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", line 123, in <module>
    exit_code = cli.run()
  File "/usr/lib/python3/dist-packages/ansible/cli/playbook.py", line 127, in run
    results = pbex.run()
  File "/usr/lib/python3/dist-packages/ansible/executor/playbook_executor.py", line 99, in run
    self._tqm.load_callbacks()
  File "/usr/lib/python3/dist-packages/ansible/executor/task_queue_manager.py", line 164, in load_callbacks
    callback_obj.set_options()
AttributeError: 'NoneType' object has no attribute 'set_options'
Exit status: 250

Job template:

---
- hosts: all
  tasks:
    - shell:
        cmd: |
          echo foo
      register: out
    - debug: var=out

seems like some whitelisted ansible callback issue, try to disable them in ~foreman-proxy/.ansible.cfg them and retry

Thank you. It seems to work when callback_whitelist is commented out. Is the foreman ansible callback necessary on the proxy?

This is the contents of ~foreman-proxy/.ansible.cfg created by foreman-installer.

[defaults]
callback_whitelist = theforeman.foreman.foreman
local_tmp = /tmp
host_key_checking = False
stdout_callback = yaml
roles_path = /etc/ansible/roles:/usr/share/ansible/roles
collections_paths = /etc/ansible/collections:/usr/share/ansible/collections

[callback_foreman]
report_type = foreman
proxy_url = https://foreman-2.westus2.cloudapp.azure.com:8443
url = https://foreman-2.westus2.cloudapp.azure.com
ssl_cert = /etc/puppetlabs/puppet/ssl/certs/foreman-2.westus2.cloudapp.azure.com.pem
ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/foreman-2.westus2.cloudapp.azure.com.pem
verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem

[ssh_connection]
ssh_args = -o ProxyCommand=none -C -o ControlMaster=auto -o ControlPersist=60s

It actually is required for sending facts and reports to the Foreman. If you’re not using that at all, feel free to keep it disabled. However if you want to get facts/reports in (recommended), we need to fix it. cc @lzap and @evgeni, this may be a regression in the recent changes, I’m not sure how to debug this or what other information to ask for.

My memory says that there was some bugs with collection-based callbacks in early 2.9 versions.

I had this exact error on a fresh Foreman 3.1 install on Ubuntu 20, and a matching copy of your posted ~foreman-proxy/.ansible.cfg file. I was able to get this working by changing callback_whitelist to

callback_whitelist = foreman

Facts and reporting are working for me with this change.

1 Like