Pull inventory from spacewalk

239 views
Skip to first unread message

Prakash Sharma

unread,
Apr 9, 2018, 11:43:03 PM4/9/18
to AWX Project
Hello Team, 

Do we have any method to pull inventory from spacewalk into AWX?

I tried to use Redhat Satellite 6 as source , but it failed with below error



2018-04-10 03:33:13,037 INFO     awx.main.commands.inventory_import Updating inventory 2: FromSpacewalk
2018-04-10 03:33:13,053 DEBUG    awx.main.commands.inventory_import Using system install of ansible-inventory CLI: /usr/bin/ansible-inventory
2018-04-10 03:33:13,053 INFO     awx.main.commands.inventory_import Reading Ansible inventory source: /usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py
Traceback (most recent call last):
  File "/usr/bin/awx-manage", line 9, in <module>
    load_entry_point('awx==1.0.2.372', 'console_scripts', 'awx-manage')()
  File "/usr/lib/python2.7/site-packages/awx/__init__.py", line 109, in manage
    execute_from_command_line(sys.argv)
  File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py", line 993, in handle
    self.is_custom)
  File "/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py", line 242, in load_inventory_source
    is_custom=is_custom).load()
  File "/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py", line 177, in load
    data = self.command_to_json(base_args + ['--list'])
  File "/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory_import.py", line 160, in command_to_json
    self.method, proc.returncode, stdout, stderr))
RuntimeError: ansible-inventory failed (rc=4) with stdout:

stderr:
ERROR! Could not parse inventory source /usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py with available plugins:
Plugin script failed: Inventory script (/usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py) had an execution error: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py", line 379, in <module>
    sys.exit(not ForemanInventory().run())
  File "/usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py", line 374, in run
    self.get_inventory()
  File "/usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py", line 327, in get_inventory
    self.update_cache()
  File "/usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py", line 236, in update_cache
    for host in self._get_hosts():
  File "/usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py", line 170, in _get_hosts
    return self._get_json("%s/api/v2/hosts" % self.foreman_url)
  File "/usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py", line 146, in _get_json
    ret = s.get(url, params={'page': page, 'per_page': 250})
  File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/requests/sessions.py", line 531, in get
    return self.request('GET', url, **kwargs)
  File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/requests/sessions.py", line 504, in request
    prep = self.prepare_request(req)
  File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/requests/sessions.py", line 436, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/requests/models.py", line 302, in prepare
    self.prepare_url(url, params)
  File "/var/lib/awx/venv/ansible/lib/python2.7/site-packages/requests/models.py", line 382, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'spacewalk/rhn/systems/Overview.do/api/v2/hosts': No schema supplied. Perhaps you meant http://spacewalk/rhn/systems/Overview.do/api/v2/hosts?

 
Plugin ini failed: /usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py:24: Expected key=value host variable assignment, got: __future__


Does anyone have better solution for this ?

Regards,
Prakash.

yxfg...@gmail.com

unread,
Apr 23, 2018, 4:12:05 AM4/23/18
to AWX Project
Hello Prashakh,

I've faced a similar or identical problem and discovered this site while trying too google the error "Plugin ini failed: /usr/lib/python2.7/site-packages/awx/plugins/inventory/foreman.py:24: Expected key=value host variable assignment, got: __future__".

It seems to solely depend on the role configured on Spacewalk / Satellite. View facts and host groups permissions plus view hosts permissions appear to be required. Problems seem to start when trying to filter the role's rights by host collection. I had some logical errors in there before (filtering hosts by collection without having permissions to view collections), still having some issues even after resolving that (or so I believe) though. Yet, simpler filters work (like, viewing hosts filtered by specific hostnames). So presumably it's still mostly a matter of wrong role permissions.
Reply all
Reply to author
Forward
0 new messages