# Rackspace and AWX

**URL:** <https://forum.ansible.com/t/rackspace-and-awx/25632>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [September 28, 2017, 11:26pm UTC](https://forum.ansible.com/t/rackspace-and-awx/25632 "2017-09-28T23:26:03Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [September 28, 2017, 11:26pm UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/1 "2017-09-28T23:26:03Z")

</div>

Hi,

I am trying to get AWX going with our Rackspace cloud. I already have Ansible & Tower scripts running for our cloud. At the moment I have two issues:

1. I cannot provision new VMs because pyrax is not installed. This is a Python module. How do I add this to AWX?

2. I cannot get an inventory. I can see the openstack inventory plugin, but I can’t see any documentation on how to configure this for Rackspace. Should I be be using this plugin or a custom script?

Larry Singer

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [September 29, 2017, 1:45am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/2 "2017-09-29T01:45:49Z")

</div>

Howdy Larry,

At one time we did support Rackspace inventory and modules directly (in downstream Tower). This was deprecated in our last major release and was removed several months ago from our mainline development branch. We did this because we actually found it difficult to maintain the shared dependencies between pyrax and openstack.

It might be totally possible to support these but you’ll need to update the the container image and rebuild (in the form of updating the requirements files). In the process of deprecating this the inventory source was removed. If you solve the dependency issues then you can import the inventory script into the custom inventory script system and add a username/password credential source for it.

If you can get it to work let us know… pyrax gave us a whole lot of grief.

---

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [September 29, 2017, 2:23am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/3 "2017-09-29T02:23:13Z")

</div>

Hi Matthew,

Thank you for your reply.

I am happy to try to use the openstack inventory and Ansible modules. I can’t find any doco on how to configure these. Are you able to point me in the right direction?

Larry Singer

---

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [September 29, 2017, 5:24am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/4 "2017-09-29T05:24:52Z")

</div>

I am getting stack traces when running the openstack plugin:

2017-09-29 03:44:25,668 INFO awx.main.commands.inventory\_import Updating inventory 2: Rackspace  
2017-09-29 03:44:25,681 DEBUG awx.main.commands.inventory\_import Using system install of ansible-inventory CLI: /usr/bin/ansible-inventory 2  
017-09-29 03:44:25,681 INFO awx.main.commands.inventory\_import Reading Ansible inventory source: /usr/lib/python2.7/site-packages/awx/plugins/inventory/openstack.py  
Traceback (most recent call last): File “/usr/bin/awx-manage”, line 9, in load\_entry\_point(‘awx==1.0.0.561’, ‘console\_scripts’, ‘awx-manage’)()  
File “/usr/lib/python2.7/site-packages/awx/ **init**.py”, line 107, 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 354, in execute\_from\_command\_line utility.execute()  
File “/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/ **init**.py”, line 346, 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 394, 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 445, in execute output = self.handle(\*args, \*\*options)  
File “/var/lib/awx/venv/awx/lib/python2.7/site-packages/django/core/management/base.py”, line 661, in handle return self.handle\_noargs(\*\*options)  
File “/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory\_import.py”, line 979, in handle\_noargs self.is\_custom)  
File “/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory\_import.py”, line 234, in load\_inventory\_source is\_custom=is\_custom).load()  
File “/usr/lib/python2.7/site-packages/awx/main/management/commands/inventory\_import.py”, line 179, 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 163, 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/openstack.py with available plugins:  
Plugin script failed: Inventory script (/usr/lib/python2.7/site-packages/awx/plugins/inventory/openstack.py) had an execution error: Error fetching server list on devstack::

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

I think this is because the Openstack inventory plugin imports packages os\_client\_config and shade and these are installed in the Docker container. I am not having any success in adding these either manually through the container shell, or via the install script.

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [September 29, 2017, 11:42am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/5 "2017-09-29T11:42:06Z")

</div>

os-client-config is installed both in our AWX environment:

[https://github.com/ansible/awx/blob/devel/requirements/requirements.txt#L116](https://github.com/ansible/awx/blob/devel/requirements/requirements.txt#L116)

and in the ansible execution environment:

[https://github.com/ansible/awx/blob/devel/requirements/requirements\_ansible.txt#L75](https://github.com/ansible/awx/blob/devel/requirements/requirements_ansible.txt#L75)

So you don’t need to install it by hand… this looks like it could be some other issue.

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [September 29, 2017, 11:42am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/6 "2017-09-29T11:42:29Z")

</div>

If you try to run the inventory script from inside of the container what does it look like?

---

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [October 3, 2017, 4:23am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/7 "2017-10-03T04:23:52Z")

</div>

Matthew,

I run `sudo docker exec -it awx_task /bin/bash `to get into the container, then:  
`[root@awx awx]# /usr/lib/python2.7/site-packages/awx/plugins/inventory/openstack.py`  
`Traceback (most recent call last):`  
`File "/usr/lib/python2.7/site-packages/awx/plugins/inventory/openstack.py", line 60, in <module>`  
`import os_client_config`  
`ImportError: No module named os_client_config`

Is this running the wrong install of Python? I remember seeing something about running embedded python somewhere, but I can’t find any doco on it.

Larry

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [October 3, 2017, 11:44am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/8 "2017-10-03T11:44:58Z")

</div>

you’ll need to activate the virtualenv:

```auto
$ source /var/lib/awx/venv/awx/bin/activate
$ /usr/lib/python2.7/site-packages/awx/plugins/inventory/openstack.py

```

---

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [October 4, 2017, 12:50am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/9 "2017-10-04T00:50:56Z")

</div>

Matthew,

I got the plugin running inside the container, but it is not running from the inventory. This appears to be related to Issue [https://github.com/ansible/awx/issues/268](https://github.com/ansible/awx/issues/268) . This points me at the code I need to look at, which appears to only support devstack. I’ll see what I can do to make this work.

Larry

---

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [October 4, 2017, 4:26am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/10 "2017-10-04T04:26:03Z")

</div>

Matthew,

I have been trying to trace the execution of this by inserting logger statements. This is my understanding so far:

The Inventory Source refresh in the UI calls class AnsibleInventoryLoader in /awx/main/management/commands/inventory\_import.py. This runs the command

/usr/bin/ansible-inventory -i /usr/lib/python2.7/site-packages/awx/plugins/inventory/openstack.py --list

An environment variable OS\_CLIENT\_CONFIG\_FILE points to a temporary file with the settings to get the inventory. (I need to change the contents of this file to support Rackspace.)

The class RunInventoryUpdate in /awx/main/tasks.py prepares the temporary settings file.

I cannot see RunInventoryUpdate being called.

I have changed the data that is output by RunInventoryUpdate (/usr/lib/python2.7/site-packages/awx/main/tasks.py in Docker container awx\_task), but the temporary settings file is not changing when I refresh the inventory.

Can you tell me where RunInventoryUpdate (or some other code) is preparing the temporary settings file?

Larry

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [October 4, 2017, 12:08pm UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/11 "2017-10-04T12:08:58Z")

</div>

The task container _will_ need to be restarted before it picks up the changes that you are making in tasks.py

You might consider using the development environment rather than the production environment when working with this: [https://github.com/ansible/awx/blob/devel/CONTRIBUTING.md](https://github.com/ansible/awx/blob/devel/CONTRIBUTING.md)

---

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [October 4, 2017, 10:56pm UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/12 "2017-10-04T22:56:10Z")

</div>

Matthew,

Thanks, restarting the container worked. I’ll see if I can work out what needs be changed to support this in the codebase.

Larry

---

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [October 5, 2017, 5:57am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/13 "2017-10-05T05:57:04Z")

</div>

Hi,

I would like some guidance on the best way to implement some changes to support Rackspace inventories using the openstack inventory plugin. This can be done without major changes to the codebase. The method build\_private\_data() in RunInventoryUpdate in awx/main/tasks.py needs to be changed to be able to generate a file that supports Rackspace (and retain backward compatibility for devstack). The file needs to contain the rax data as shown in awx/plugins/inventory/openstack.yml rather than the devstack data.

To do this we need to be able to tell the difference between a devstack inventory and a Rackspace inventory. I have identified a few ways this could be done:

- Create a new credentials type for Rackspace and supply these to the inventory source.
- Reuse the OpenStack credentials type: Username, Password and Project fields would remain the same, Host field would be “rackspace” to identify that these are Rackspace credentials, Domain Name field could be reused to hold region names.
- Use variables on the inventory source to identify a Rackspace source: profile: rackspace, region\_name: SYD

Thanks in advance.

Larry Singer

---

<div class="post-metadata">

**Author:** ![Christopher\_Meyers](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@Christopher\_Meyers](https://forum.ansible.com/u/Christopher_Meyers)\
**Post date:** [October 5, 2017, 6:43pm UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/14 "2017-10-05T18:43:46Z")

</div>

I’m a bit confused Larry. Do you want to get Rackspace Dynamic Inventory Script to work in Tower or OpenStack Dynamic Inventory Script?

FYI, this was the commit that removed support for Rackspace in Tower [https://github.com/ansible/awx/commit/cfb633e8a643b0190fa07b6204b339a1d336cbb3](https://github.com/ansible/awx/commit/cfb633e8a643b0190fa07b6204b339a1d336cbb3)

---

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [October 5, 2017, 9:59pm UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/15 "2017-10-05T21:59:48Z")

</div>

Christopher,

I am trying to use terms from the AWX UI, rather than from Ansible Tower. The OpenStack inventory source (dynamic inventory) can support Rackspace if different parameters are passed to the inventory plugin. This is about the best way to get those parameters to the OpenStack plugin.

Larry

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [October 6, 2017, 4:20pm UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/16 "2017-10-06T16:20:22Z")

</div>

I reckon I’d prefer a standalone credential… but I will point out that we removed support for rax originally because of the dependency conflict. If you can make it work then I’m all ears.

---

<div class="post-metadata">

**Author:** ![larry.singer](https://avatars.discourse-cdn.com/v4/letter/l/bc79bd/32.png) [@larry.singer](https://forum.ansible.com/u/larry.singer)\
**Post date:** [October 8, 2017, 11:34pm UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/17 "2017-10-08T23:34:36Z")

</div>

Matthew,

The old Rackspace inventory (and the ansible modules) used a package pyrax. This has been deprecated by Rackspace. The openstack inventory plugin in AWX does allow access to Rackspace without any extra packages. So we should be able to support Rackspace without Pyrax.

I will have a go at a separate credential for Rackspace.

Larry

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [October 9, 2017, 1:59am UTC](https://forum.ansible.com/t/rackspace-and-awx/25632/18 "2017-10-09T01:59:45Z")

</div>

Excellent, carry on then!
