error connecting ansible to azure portal

75 views
Skip to first unread message

TheRock

unread,
Oct 19, 2022, 3:03:33 AM10/19/22
to Ansible Project
Dears,

while i am trying to connect my Ansible Platform to my Azure Portal, i am facing below error when lunching the job from Ansible portal, so any idea?

ansible-inventory [core 2.12.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections:/usr/share/automation-controller/collections
  executable location = /usr/bin/ansible-inventory
  python version = 3.8.8 (default, Aug 11 2021, 06:52:42) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 2.10.3
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
redirecting (type: inventory) ansible.builtin.azure_rm to azure.azcollection.azure_rm
[WARNING]:  * Failed to parse /runner/inventory/azure_rm.yml with auto plugin:
HTTPSConnectionPool(host='login.microsoftonline.com', port=443): Max retries
exceeded with url: /41bb3422-2e0e-42e8-88d2-------/oauth2/token (Caused
by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at
-----f199c8a------>: Failed to establish a new connection: [Errno -2] Name or
service not known'))
  File "/usr/lib/python3.8/site-packages/ansible/inventory/manager.py", line 290, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3.8/site-packages/ansible/plugins/inventory/auto.py", line 58, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/usr/share/ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py", line 219, in parse
    self._credential_setup()
  File "/usr/share/ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py", line 240, in _credential_setup
    self.azure_auth = AzureRMAuth(**auth_options)
  File "/usr/share/ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py", line 1516, in __init__
    self.azure_credentials = ServicePrincipalCredentials(client_id=self.credentials['client_id'],
  File "/usr/local/lib/python3.8/site-packages/msrestazure/azure_active_directory.py", line 355, in __init__
    self.set_token()
  File "/usr/local/lib/python3.8/site-packages/msrestazure/azure_active_directory.py", line 364, in set_token
    token = self._context.acquire_token_with_client_credentials(
  File "/usr/local/lib/python3.8/site-packages/adal/authentication_context.py", line 179, in acquire_token_with_client_credentials
    return self._acquire_token(token_func)
  File "/usr/local/lib/python3.8/site-packages/adal/authentication_context.py", line 128, in _acquire_token
    return token_func(self)
  File "/usr/local/lib/python3.8/site-packages/adal/authentication_context.py", line 177, in token_func
    return token_request.get_token_with_client_credentials(client_secret)
  File "/usr/local/lib/python3.8/site-packages/adal/token_request.py", line 312, in get_token_with_client_credentials
    token = self._oauth_get_token(oauth_parameters)
  File "/usr/local/lib/python3.8/site-packages/adal/token_request.py", line 112, in _oauth_get_token
    return client.get_token(oauth_parameters)
  File "/usr/local/lib/python3.8/site-packages/adal/oauth2_client.py", line 263, in get_token
    resp = requests.post(token_url.geturl(),
  File "/usr/lib/python3.8/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
[WARNING]: Unable to parse /runner/inventory/azure_rm.yml as an inventory
source
ERROR! No inventory was parsed, please check your configuration and options.

Dick Visser

unread,
Oct 19, 2022, 4:31:24 AM10/19/22
to ansible...@googlegroups.com
On Wed, 19 Oct 2022 at 09:03, TheRock <idriss.m...@gmail.com> wrote:
>
> Dears,
>
> while i am trying to connect my Ansible Platform to my Azure Portal, i am facing below error when lunching the job from Ansible portal, so any idea?

Yes, it's pretty easy to see:

> HTTPSConnectionPool(host='login.microsoftonline.com', port=443): Max retries
> exceeded with url: /41bb3422-2e0e-42e8-88d2-------/oauth2/token (Caused
> by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at
> -----f199c8a------>: Failed to establish a new connection: [Errno -2] Name or
> service not known'))

The system that executes this code cannot resolve the hostname
"login.microsoftonline.com".
So you should look into that.
Just to be clear, this error is not ansible related, it's merely
ansible that reports it.

Dick

TheRock

unread,
Oct 19, 2022, 6:38:22 AM10/19/22
to Ansible Project
thank you Dick, i will try to fix this issue and run the job again.
Reply all
Reply to author
Forward
0 new messages