我已经摔了一个星期左右。

我通过docker-compose运行AWX并在EC2实例上进行设置。
我的部门没有创建Azure服务主体的凭据,因此在等待该请求通过时,我试图通过 Activity 目录凭据使AWX向Azure进行身份验证。在测试过程中,为简单起见,我有一个运行azure_rm_dnsrecordset_facts的测试任务设置,因此我可以简单地提取TXT记录以表明身份验证在进行身份验证。在我的开发机器上,我可以通过ansible-playbook命令安装azure cli,运行az登录并执行playbooks等,并且可以正常工作:我可以看到测试提取了预期的TXT记录。但是在AWX上我得到了错误。

使用az登录并将/root/.azure/中的文件复制到/var/lib/awx/.azure/中,我得到此错误:

{
    "_ansible_parsed": false,
    "exception": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1558728025.48-180262108746971/AnsiballZ_azure_rm_dnsrecordset_facts.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1558728025.48-180262108746971/AnsiballZ_azure_rm_dnsrecordset_facts.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1558728025.48-180262108746971/AnsiballZ_azure_rm_dnsrecordset_facts.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/__main__.py\", line 202, in <module>\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/__main__.py\", line 198, in main\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/__main__.py\", line 133, in __init__\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/ansible_azure_rm_dnsrecordset_facts_payload.zip/ansible/module_utils/azure_rm_common.py\", line 301, in __init__\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/ansible_azure_rm_dnsrecordset_facts_payload.zip/ansible/module_utils/azure_rm_common.py\", line 1045, in __init__\n  File \"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/msrestazure/azure_active_directory.py\", line 383, in __init__\n    self.set_token()\n  File \"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/msrestazure/azure_active_directory.py\", line 415, in set_token\n    raise_with_traceback(AuthenticationError, \"\", err)\n  File \"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/msrest/exceptions.py\", line 48, in raise_with_traceback\n    raise error\nmsrest.exceptions.AuthenticationError: , InvalidGrantError: (invalid_grant) AADSTS50126: Invalid username or password.\r\nTrace ID: 01cd8ac6-1c05-4391-96da-031e0da30500\r\nCorrelation ID: 03f28850-04cf-4344-b405-18594d8845a1\r\nTimestamp: 2019-05-24 20:00:26Z\n",
    "_ansible_no_log": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1558728025.48-180262108746971/AnsiballZ_azure_rm_dnsrecordset_facts.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1558728025.48-180262108746971/AnsiballZ_azure_rm_dnsrecordset_facts.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1558728025.48-180262108746971/AnsiballZ_azure_rm_dnsrecordset_facts.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/__main__.py\", line 202, in <module>\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/__main__.py\", line 198, in main\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/__main__.py\", line 133, in __init__\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/ansible_azure_rm_dnsrecordset_facts_payload.zip/ansible/module_utils/azure_rm_common.py\", line 301, in __init__\n  File \"/tmp/ansible_azure_rm_dnsrecordset_facts_payload_PlPfUW/ansible_azure_rm_dnsrecordset_facts_payload.zip/ansible/module_utils/azure_rm_common.py\", line 1045, in __init__\n  File \"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/msrestazure/azure_active_directory.py\", line 383, in __init__\n    self.set_token()\n  File \"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/msrestazure/azure_active_directory.py\", line 415, in set_token\n    raise_with_traceback(AuthenticationError, \"\", err)\n  File \"/var/lib/awx/venv/ansible/lib/python2.7/site-packages/msrest/exceptions.py\", line 48, in raise_with_traceback\n    raise error\nmsrest.exceptions.AuthenticationError: , **InvalidGrantError: (invalid_grant) AADSTS50126: Invalid username or password**.\r\nTrace ID: 01cd8ac6-1c05-4391-96da-031e0da30500\r\nCorrelation ID: 03f28850-04cf-4344-b405-18594d8845a1\r\nTimestamp: 2019-05-24 20:00:26Z\n",
    "changed": false,
    "module_stdout": "",
    "rc": 1,
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"
}

使用ad_username,password和subscription_id值作为环境变量时,多余的var和从Vault传递到模块中的所有这些都会导致相同的错误:
{
    "_ansible_parsed": true,
    "_ansible_no_log": false,
    "invocation": {
        "module_args": {
            "profile": null,
            "resource_group": "publicdns**********",
            "tags": null,
            "cloud_environment": "AzureCloud",
            "relative_name": "_acme-challenge",
            "record_type": "TXT",
            "client_id": null,
            "api_profile": "latest",
            "adfs_authority_url": null,
            "zone_name": "*************",
            "password": null,
            "tenant": null,
            "top": "100",
            "append_tags": true,
            "ad_user": null,
            "cert_validation_mode": null,
            "secret": null,
            "auth_source": null,
            "subscription_id": null
        }
    },
    "changed": false,
    "msg": "**Failed to get credentials. Either pass as parameters, set environment variables, define a profile in ~/.azure/credentials, or log in with Azure CLI (`az login`)**."
}

就是我还是这是一个错误?除了我在阅读文档时发现的内容外,我找不到任何明确地指导您进行设置的内容。我希望这会很简单,到目前为止,什么都没有。

这是我最近关注的文档之一:https://docs.ansible.com/ansible-tower/3.2.6/html/userguide/credentials.html#microsoft-azure-resource-manager

谢谢您的帮助。这是我尝试过的事情的 list :
  • 在awx_task和awx_web容器中为AZURE_AD_USER,AZURE_PASSWORD和AZURE_SUBSCRIPTION_ID设置环境变量。
  • 我已将ad_user,密码和subscription_id凭据设置为额外的变量。
  • 我已经将凭证放入保管库中,并直接传递给ansible模块,无论是否带有azure_adfs_authority_url。
  • 在awx_task docker 容器中,我安装了ansible [azure]和azure cli,运行az登录,验证是否填充了/root/.azure/azureProfile.json文件。
  • 我已将文件从/root/.azure/复制到/var/lib/awx/.azure/,AWX正在查找这些文件。我还验证了读写访问权限和文件所有权。
  • 我修补了Microsoft Azure资源管理器凭据,但它似乎不是我想要的。
  • ON EC2实例azure_adfs_authority_url的nslookup表明它正在命中正确的ADFS服务器。

  • 谢谢你的帮助

    最佳答案

    错误是“AADSTS50126用户名或密码无效”,因此,我建议您仔细检查并确保用户名或密码正确,以连接受管域。如果问题仍然存在,则(AFAIK对联合Azure租户的身份验证大多会失败,因此)尝试通过重置用户密码和/或尝试通过设置tenant_id / tenant来尝试。 here也出现了类似的问题,您可以检查将来的更新。

    希望这可以帮助!!

    10-06 07:17