# Unable to get / load credentials

**URL:** <https://forum.ansible.com/t/unable-to-get-load-credentials/27788>\
**Category:** Ansible Project\
**Tags:** azure\
**Created:** [June 12, 2018, 9:38pm UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788 "2018-06-12T21:38:46Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlton\_Patterson1](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@Carlton\_Patterson1](https://forum.ansible.com/u/Carlton_Patterson1)\
**Post date:** [June 12, 2018, 9:38pm UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/1 "2018-06-12T21:38:46Z")

</div>

Hello community,

I have followed the document [https://docs.ansible.com/ansible/latest/scenario\_guides/guide\_azure.html](https://docs.ansible.com/ansible/latest/scenario_guides/guide_azure.html) to authenticate with Azure.

I have created two credential files on my Ansible host as follows:

(venv27) packt@ubuntu2:~/.azure$ pwd  
**/home/packt/.azure**  
(venv27) packt@ubuntu2:~/.azure$ ls -la  
total 32  
drwxrwxr-x 2 packt packt 4096 Jun 12 22:24 .  
drwxr-xr-x 9 packt packt 4096 Jun 12 21:59 …  
-rw-rw-r-- 1 packt packt 5 Jun 12 22:19 az.json  
-rw-rw-r-- 1 packt packt 5 Jun 12 22:19 az.sess  
-rw-rw-r-- 1 packt packt 5 Jun 12 22:19 azureProfile.json  
-rw------- 1 packt packt 27 Jun 12 22:19 config  
-rw-rw-r-- 1 packt packt 296 Jun 12 22:24 credentials  
-rw-rw-r-- 1 packt packt 306 Jun 12 22:24 credentials.ini

My credential files look as follows:

[default]  
AZURE\_CLIENT\_ID=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx  
AZURE\_SECRET=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx  
AZURE\_SUBSCRIPTION\_ID=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx  
AZURE\_TENANT=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx  
AZURE\_AD\_USER=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx  
AZURE\_PASSWORD=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx

My playbook is a follows:

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [June 13, 2018, 9:17am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/2 "2018-06-13T09:17:43Z")

</div>

That looks like a python virtual. Is Ansible hiding in venv27?

---

<div class="post-metadata">

**Author:** ![Carlton\_Patterson](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Carlton\_Patterson](https://forum.ansible.com/u/Carlton_Patterson)\
**Post date:** [June 13, 2018, 9:50am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/3 "2018-06-13T09:50:13Z")

</div>

Hi Karl,

It is a python virtual. How can I tell if Ansible is hiding in venv27? And how do I fix this? It’s never happened before

---

<div class="post-metadata">

**Author:** ![Carlton\_Patterson](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Carlton\_Patterson](https://forum.ansible.com/u/Carlton_Patterson)\
**Post date:** [June 13, 2018, 10:18am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/4 "2018-06-13T10:18:18Z")

</div>

All, please ignore the last comment where I said:

‘It is a python virtual. How can I tell if Ansible is hiding in venv27? And how do I fix this? It’s never happened before’

I was referring to another question…

I still need help with this question and Unable load credentials…

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [June 13, 2018, 10:19am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/5 "2018-06-13T10:19:14Z")

</div>

Sorry Carlton, I’m running out of know-how ☹

Try this. Go to your home directory on the virtual and run this command:

find . -name “_ansible_” -print

That will locate any directories or files with “ansible” in them, and perhaps give you a clue as to how Ansible was installed, and where it was installed to.

If that command finds nothing, go to the root directory of your virtual and repeat the comand.

Beyond that, I’m as stumped as you. But I do know that either it was never installed, or it was installed somewhere other than you now expect. It has not uninstalled itself.

Regards, K.

---

<div class="post-metadata">

**Author:** ![Carlton\_Patterson](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Carlton\_Patterson](https://forum.ansible.com/u/Carlton_Patterson)\
**Post date:** [June 13, 2018, 10:26am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/6 "2018-06-13T10:26:46Z")

</div>

Hi Karl,

I think we’re answering a different question.

This question refers to Ansible not loading my Azure credentials … which I desperately need help with.

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [June 13, 2018, 10:47am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/7 "2018-06-13T10:47:05Z")

</div>

I know nothing about Azure. However, some possibilities:

- the permissions on your credentials files should probably not include o=r

- are you are executing Ansible as the user with the credentials files?

- the docs I can find in a cursory search suggest that the creds file should look like this:

[default]  
subscription\_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  
client\_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  
secret=xxxxxxxxxxxxxxxxx

tenant=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

… which is very different to what you have.

Also you have credentials, config and credentials.ini and other files as well, not sure which is what or which is correct. Suggest you move everything OUT of that directory and move them back in one at a time while testing access, to make sure you are using the correct file.

See [https://docs.ansible.com/ansible/latest/scenario\_guides/guide\_azure.html](https://docs.ansible.com/ansible/latest/scenario_guides/guide_azure.html)

```auto

```

​Regards, K.

---

<div class="post-metadata">

**Author:** ![Carlton\_Patterson](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Carlton\_Patterson](https://forum.ansible.com/u/Carlton_Patterson)\
**Post date:** [June 13, 2018, 11:01am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/8 "2018-06-13T11:01:52Z")

</div>

Hi Karl,

Really appreciate you helping with this:

Not sure what you mean by ’ should probably not include o=r’

Also, not sure how my creds file differ from:

[default]  
subscription\_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  
client\_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  
secret=xxxxxxxxxxxxxxxxx

tenant=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [June 13, 2018, 11:11am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/9 "2018-06-13T11:11:45Z")

</div>

The permissions on your credentials files allow anyone with access to the computer to read the files. That means they can see your credentials and presumably access your Azure account. Hence probably not right.

---

<div class="post-metadata">

**Author:** ![Carlton\_Patterson](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Carlton\_Patterson](https://forum.ansible.com/u/Carlton_Patterson)\
**Post date:** [June 13, 2018, 11:35am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/10 "2018-06-13T11:35:39Z")

</div>

Ok, I got yer,

So I changed it to:  
[default]

AZURE\_CLIENT\_ID=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx  
AZURE\_SECRET=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx  
AZURE\_SUBSCRIPTION\_ID=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx  
AZURE\_TENANT=xxxxxx.xxxxxx.xxxxxxxxx.xxxxxx

From the Ansible document it specifies using CAPITALS … instead of lowercase ie. the docs specify using AZURE\_SUBSCRIPTION\_ID, instead of subscription\_id … or am I wrong?

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [June 13, 2018, 11:55am UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/11 "2018-06-13T11:55:49Z")

</div>

Not quite what I meant. When I look at that web page, it seems to me to be saying that you should have a credentials file in ~.azure called credentials, and that that file should contain the following:

[default]  
subscription\_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  
client\_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  
secret=xxxxxxxxxxxxxxxxx

tenant=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

… with the “xxxx” parts replaced by the correct values for your subscription ID and so on.

The exact names and the exact case of the names are almost certainly relevant. For example, I think it has to be exactly and literally “subscription\_id” - not “SUBSCRIPTION\_ID” or “SubscriptionId” or “AZURE\_SUBSCRIPTION\_ID” or anything else. The One True And Correct Name for it is “subscription\_id”.

I may be wrong, but unless you have definite evidence to the contrary, it is safest to assume that the exact spelling, punctuation and case of everything in the INI file is meaningful.

Look at the web page again:

[https://docs.ansible.com/ansible/latest/scenario\_guides/guide\_azure.html](https://docs.ansible.com/ansible/latest/scenario_guides/guide_azure.html)

… and scroll down to where it says “Providing Credentials to Azure Modules”. Then scroll down some more until you find “Storing in a File” and read that bit.

If you were using environment variables rather than a credentials file, then you would use the upper-case names with the “AZURE\_” prefix, as detailed in the section called “Using Environment Variables”. Since you are storing credentials in a file, it seems to me to make sense to use the instructions in the section called “Storing in a File”.

​Regards, K.  
​  
PS: This is just me reading a document describing something I know nothing about. Anyone with actual Azure experience should feel free to chime in any time…

---

<div class="post-metadata">

**Author:** ![Carlton\_Patterson](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Carlton\_Patterson](https://forum.ansible.com/u/Carlton_Patterson)\
**Post date:** [June 13, 2018, 12:25pm UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/12 "2018-06-13T12:25:46Z")

</div>

OK, I hear yer … gonna try that right now.

---

<div class="post-metadata">

**Author:** ![Carlton\_Patterson](https://avatars.discourse-cdn.com/v4/letter/c/fbc32d/32.png) [@Carlton\_Patterson](https://forum.ansible.com/u/Carlton_Patterson)\
**Post date:** [June 13, 2018, 12:31pm UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/13 "2018-06-13T12:31:47Z")

</div>

Karl,

SUCCESS!

Are you in England? If so, I would love to buy you a beer… It won’t as you suggested… I only wish I had followed your advice earlier

YOU ABSOLUTE BEAUTY

THANK YOU, THANK YOU, THANK YOU…

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [June 13, 2018, 12:40pm UTC](https://forum.ansible.com/t/unable-to-get-load-credentials/27788/14 "2018-06-13T12:40:58Z")

</div>

No, I’m not in England. Land of Oz, me.

Glad it worked. All I did was read the docs 🙂

Regards, K.
