# Ansible 2.0 os\_server 404 image not found

**URL:** <https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171>\
**Category:** Ansible Project\
**Created:** [September 2, 2015, 5:10pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171 "2015-09-02T17:10:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![V\_Benincosa](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@V\_Benincosa](https://forum.ansible.com/u/V_Benincosa)\
**Post date:** [September 2, 2015, 5:10pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/1 "2015-09-02T17:10:12Z")

</div>

Hi!  
Checking out the 2.0 release and having some problems launching machine. When I run:

ansible-playbook lab-machines.yml

- name: Ensure lab machines are up  
connection: local  
hosts: localhost  
vars\_files:
- vars/metacloud\_vars.yml

tasks:

- name: Ensure lab machines are up  
os\_server:  
state: present

# auth:

# auth\_url: “{{ lookup(‘env’, ‘OS\_AUTH\_URL’) }}”

# username: “{{ lookup(‘env’, ‘OS\_USERNAME’) }}”

# password: “{{ lookup(‘env’, ‘OS\_PASSWORD’) }}”

# project\_name: “{{ lookup(‘env’, ‘OS\_TENANT\_NAME’) }}”

name: “{{ item }}”  
key\_name: “{{ keypair }}”  
flavor: “{{ m1large }}”  
floating\_ip\_pools:

- “{{ floating\_ip\_pool }}”  
security\_groups: “{{ security\_group }}”  
userdata: “{{ lookup(‘file’, ‘files/coreos-python.sh’) }}”  
image: CoreOS723  
with\_items:
- lab01

I get the error:

failed: [localhost] =\> (item=lab01) =\> {“extra\_data”: null, “failed”: true, “item”: “lab01”, “msg”: “Error fetching image list: 404 Not Found: The resource could not be found. (HTTP 404)”}

So you’re probably thinking: I don’t have that image named CoreOS723 defined. I tried nova image-list and that shows the image:

$ nova image-show CoreOS723

---

<div class="post-metadata">

**Author:** ![V\_Benincosa](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@V\_Benincosa](https://forum.ansible.com/u/V_Benincosa)\
**Post date:** [September 2, 2015, 6:19pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/2 "2015-09-02T18:19:43Z")

</div>

I downgraded python-glanceclient to 0.19.0 and it seems to get past that error. Now I get:  
failed: [localhost] =\> (item=lab01) =\> {“extra\_data”: null, “failed”: true, “item”: “lab01”, “msg”: “Error fetching image list: Expected endpoint”}

So it looks like I’ll have to downgrade most of my python openstack clients one revision for this to work in my environment.

---

<div class="post-metadata">

**Author:** ![V\_Benincosa](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@V\_Benincosa](https://forum.ansible.com/u/V_Benincosa)\
**Post date:** [September 2, 2015, 6:34pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/3 "2015-09-02T18:34:34Z")

</div>

well, that was the wrong way to go. Shade reinstalled version python-glanceclient 1.0.0 so I guess I need to figure out why glance doesn’t return any images. Metacloud uses icehouse.

---

<div class="post-metadata">

**Author:** ![V\_Benincosa](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@V\_Benincosa](https://forum.ansible.com/u/V_Benincosa)\
**Post date:** [September 2, 2015, 6:48pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/4 "2015-09-02T18:48:57Z")

</div>

Running: export OS\_IMAGE\_API\_VERSION=1 (and placing in .bash\_profile) will now make glance image-list show something… but ansible still gets the same error.

---

<div class="post-metadata">

**Author:** ![Greg\_DeKoenigsberg1](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Greg\_DeKoenigsberg1](https://forum.ansible.com/u/Greg_DeKoenigsberg1)\
**Post date:** [September 2, 2015, 7:03pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/5 "2015-09-02T19:03:34Z")

</div>

So this is specifically in the os\_ modules, right?

--g

---

<div class="post-metadata">

**Author:** ![James\_Martin1](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@James\_Martin1](https://forum.ansible.com/u/James_Martin1)\
**Post date:** [September 2, 2015, 7:17pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/6 "2015-09-02T19:17:41Z")

</div>

I’ve successfully launched servers with os\_server as of today, with the latest version of shade, so I don’t think the module is completely broken. I do see that a 404 is being returned in your error, which is a “page not found” status code ([https://en.wikipedia.org/wiki/HTTP\_404](https://en.wikipedia.org/wiki/HTTP_404)). My guess is that you’re getting the initial token after keystone authentication, but a subsequent request is failing. Since you don’t have access to the openstack infrastructure to debug, I’d recommend using tcpdump and taking a look at what request is causing the 404.

- James

---

<div class="post-metadata">

**Author:** ![V\_Benincosa](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@V\_Benincosa](https://forum.ansible.com/u/V_Benincosa)\
**Post date:** [September 2, 2015, 8:06pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/7 "2015-09-02T20:06:59Z")

</div>

Yes.

---

<div class="post-metadata">

**Author:** ![V\_Benincosa](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@V\_Benincosa](https://forum.ansible.com/u/V_Benincosa)\
**Post date:** [September 2, 2015, 9:14pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/8 "2015-09-02T21:14:07Z")

</div>

The 404 I believe comes from ansible defaulting to the v2 for glance, in which case no images are found and thus the 404 error. Our openstack only has v1 support.  
When I run glance image-list with the OS\_IMAGE\_API\_VERSION=1 the command line tools show images.  
This is the new behavior change in Python-glanceclient 1.0.0

Does Ansible honor that flag?

---

<div class="post-metadata">

**Author:** ![V\_Benincosa](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@V\_Benincosa](https://forum.ansible.com/u/V_Benincosa)\
**Post date:** [September 4, 2015, 4:10pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/9 "2015-09-04T16:10:38Z")

</div>

I’ve done some more debugging on this and it looks like shade is putting an extra v1 in the URL so it looks like:

[http://some.client.metacloud.net:9292/v1/v1/images/detail?limit=20](http://some.client.metacloud.net:9292/v1/v1/images/detail?limit=20)

I ended up changing the glanceclient/v1/images.py by removing all the v1s. This solved the ansible problem, but now the command line doesn’t work even though ansible does (e.g: glance image-list doesn’t work). I’ll start digging into the shade implementation to see where this extra v1 is being added. Would love any help.

---

<div class="post-metadata">

**Author:** ![Monty\_Taylor](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@Monty\_Taylor](https://forum.ansible.com/u/Monty_Taylor)\
**Post date:** [September 4, 2015, 7:02pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/10 "2015-09-04T19:02:26Z")

</div>

Sorry for your troubles. The problem is almost certianly in the v1/v2 version detection. I think we can do better for you here. However, in the mean time - would you mind trying something to test a hypothesis?

Make a ~/.config/openstack/clouds.yaml with:

clouds:  
metacloud:  
auth:  
username: your-user  
password: your-password  
project\_name: your-project-name  
auth\_url: your-auth-url  
image\_api\_version: ‘1’

And then put “cloud: metacloud” in your playbook and see if it works?

Figuring out v1 vs. v2 in glance is _hard_ and complex and very prone to breaking, which is why it’s one of the tings we put in known-cloud profiles in os-client-config.

Now - if that works, awesome. It still sucks as a user experience for you - so I think we need to make sure we can plumb api version overrides through sanely in playbooks. Also - I’m going to go poke the metacloud folks about getting me a metacloud so that I can add a metacloud profile to occ.

Also - I’ll see if I can reproduce and find another workaround/detection in case all of the above don’t work.

---

<div class="post-metadata">

**Author:** ![V\_Benincosa](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@V\_Benincosa](https://forum.ansible.com/u/V_Benincosa)\
**Post date:** [September 4, 2015, 8:26pm UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/11 "2015-09-04T20:26:23Z")

</div>

Thanks a bunch Monty for looking into that. Using the clouds.yaml file didn’t work for me. Same error with 404. I instead hacked shade to make it work.

in def get\_session\_endpoint in the shade **init** I added a sub to get rid of the v1:

if service\_key == ‘image’:  
endpoint = re.sub(‘/v1’, ‘’, endpoint)

then passed that into the client create. I didn’t understand why the endpoint was never passed into the client create around line 605. Total hack, but I’m running now.

Also, I didn’t see in github a place to open issues or how you track this. Thanks for any pointers. I’m happy to help.

---

<div class="post-metadata">

**Author:** ![Robyn\_Bergeron2](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@Robyn\_Bergeron2](https://forum.ansible.com/u/Robyn_Bergeron2)\
**Post date:** [September 5, 2015, 1:17am UTC](https://forum.ansible.com/t/ansible-2-0-os-server-404-image-not-found/19171/12 "2015-09-05T01:17:57Z")

</div>

> Thanks a bunch Monty for looking into that. Using the clouds.yaml file  
> didn't work for me. Same error with 404. I instead hacked shade to make  
> it work.
> 
> in def get\_session\_endpoint in the shade \_\_init\_\_ I added a sub to get rid  
> of the v1:
> 
> if service\_key == 'image':  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endpoint = re.sub('/v1', '', endpoint)
> 
> then passed that into the client create. I didn't understand why the  
> endpoint was never passed into the client create around line 605. Total  
> hack, but I'm running now.
> 
> Also, I didn't see in github a place to open issues or how you track  
> this. Thanks for any pointers. I'm happy to help.

Per a similar threat on twitter with the same folks involved 😃 ... (  
[https://twitter.com/vallard/status/639862545738633216](https://twitter.com/vallard/status/639862545738633216))

... I think we all agree this is a bit confusing. I believe the place where  
shade issues are currently supposed to be filed is in the openstack  
storyboard for shade [1] -- but I don't know that that's obvious to people  
having trouble with the associated modules or shade itself.

Any suggestions on what might be better? Hoping to find something logical  
that accommodates the overlapping workflows of two projects... 🙂

-robyn

[1] [https://storyboard.openstack.org/#!/project/760](https://storyboard.openstack.org/#!/project/760)
