无法使用Ansible添加扩展以使用Azure VM扩展

时间:2018-02-08 10:38:58

标签: azure ansible

我正在尝试将Azure VM扩展添加到现有VM。下面是我用来尝试安装Octopus Deploy Azure扩展

的示例剧本
  - name: Install Octopus deploy tentacle 
      hosts: localhost
      gather_facts: false
      vars:
        sec: 'YK/xxxxxxxxxx/JnCsPTj4kRdsWblc='
      tasks:
      - name: Create Azure clear
        azure_rm_deployment:
        state: present
        subscription_id: 'b1514ce2-xxxx-xxxxxx-xxxxx-xxxxxx'
        client_id: 'xxxxxxx-cae7-45a3-xxxxxx-9b37bce64746'
        secret: '{{ sec }}'
        tenant: "78e60c0f-xxxx-xxxx-xxxxx-63fe13a30962"
        location: 'uk west'
        resource_group_name: 'AnsibleRG'
        template_link: https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/octopus-deploy-tentacle-windows/azuredeploy.json
  #template: "{{ lookup('file', '/etc/ansible/playbooks/OctopusDeployTentacle.json') | from_json }}"

        parameters:
          vmAdminUserName:
            value: adminUser
          vmAdminPassword:
            value: mYpAss
          vmDnsName:
            value: WinVM01
          tentacleOctopusServerUrl:
            value: https://octopus.example.com
          tentacleCommunicationMode:
            value: Listen
          tentacleApiKey:
            value: XXX-ABC-DDE-DDJD-GGGJ
          tentacleRoles:
            value: web
          tentacleEnvironments:
            value: Test
          tentaclePort:
            value: 10933

当我运行剧本时,我收到错误

  

“部署失败,状态码:400,消息:模板部署'ansible-arm'根据验证程序无效。跟踪ID为'c73feca6-ae2d-4c10-83a0-16be06819f5a'。查看内部错误有关详细信息,请参阅aka.ms/arm-deploy了解使用详情。“

我也尝试了其他一些扩展程序,但仍然遇到同样的错误。 有人可以指导我如何解决这个问题?

贝娄稍微有点错误的细节

使用-vvvv

运行playbook后
    Using module file /usr/lib/python2.7/dist-packages/ansible/modules/cloud/azure/azure_rm_deployment.py
    <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
    <127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/rafid/.ansible/tmp/ansible-tmp-1518117111.96-175732666939842 `" && echo ansible-tmp-1518117111.96-175732666939842="` echo /home/rafid/.ansible/tmp/ansible-tmp-1518117111.96-175732666939842 `" ) && sleep 0'
    <127.0.0.1> PUT /tmp/tmpQY52K0 TO /home/rafid/.ansible/tmp/ansible-tmp-1518117111.96-175732666939842/azure_rm_deployment.py
    <127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/rafid/.ansible/tmp/ansible-tmp-1518117111.96-175732666939842/ /home/rafid/.ansible/tmp/ansible-tmp-1518117111.96-175732666939842/azure_rm_deployment.py && sleep 0'
    <127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/rafid/.ansible/tmp/ansible-tmp-1518117111.96-175732666939842/azure_rm_deployment.py; rm -rf "/home/rafid/.ansible/tmp/ansible-tmp-1518117111.96-175732666939842/" > /dev/null 2>&1 && sleep 0'
    The full traceback is:
      File "/tmp/ansible_PZzWZG/ansible_module_azure_rm_deployment.py", line 509, in deploy_template
        deploy_parameter)
      File "/usr/local/lib/python2.7/dist-packages/azure/mgmt/resource/resources/v2017_05_10/operations/deployments_operations.py", line 282, in create_or_update
        get_long_running_status, long_running_operation_timeout)
      File "/usr/local/lib/python2.7/dist-packages/msrestazure/azure_operation.py", line 350, in __init__
        raise CloudError(self._response)

    fatal: [localhost]: FAILED! => {
        "changed": false,
        "failed_deployment_operations": [],
        "invocation": {
            "module_args": {
                "ad_user": null,
                "append_tags": true,
                "cli_default_profile": null,
                "client_id": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "cloud_environment": null,
                "deployment_mode": "incremental",
                "deployment_name": "ansible-arm",
                "location": "uk west",
                "parameters": {
                    "tentacleApiKey": {
                        "value": "XXX-ABC-DDE-DDJD-GGGJ"
                    },
                    "tentacleCommunicationMode": {
                        "value": "Listen"
                    },
                    "tentacleEnvironments": {
                        "value": "Test"
                    },
                    "tentacleOctopusServerUrl": {
                        "value": "https://octopus.example.com"
                    },
                    "tentaclePort": {
                        "value": 10933
                    },
                    "tentacleRoles": {
                        "value": "web"
                    },
                    "vmAdminPassword": {
                        "value": "mYpAss"
                    },
                    "vmAdminUserName": {
                        "value": "adminUser"
                    },
                    "vmDnsName": {
                        "value": "WinVM01"
                    }
                },
                "parameters_link": null,
                "password": null,
                "profile": null,
                "resource_group_name": "AnsibleRG",
                "secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "state": "present",
                "subscription_id": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "tags": null,
                "template": null,
                "template_link": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/octopus-deploy-tentacle-windows/azuredeploy.json",
                "tenant": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "wait_for_deployment_completion": true,
                "wait_for_deployment_polling_period": 10
            }
        },
        "msg": "Deployment failed with status code: 400 and message: The template deployment 'ansible-arm' is not valid according to the validation procedure. The tracking id is '1bf65caf-3b8c-4521-8370-65bae816404b'. See inner errors for details. Please see https://aka.ms/arm-deploy for usage details."
    }

以下是我在Azure门户活动日志中看到的内容

{
    "authorization": {
        "action": "Microsoft.Resources/deployments/write",
        "scope": "/subscriptions/xxx-xxx-xxx-xxx/resourcegroups/AnsibleRG/providers/Microsoft.Resources/deployments/ansible-arm"
    },
    "caller": "2c02c92d-c9b8-4fc2-8140-40f8ba2052a5",
    "channels": "Operation",
    "claims": {
        "aud": "https://management.core.windows.net/",
        "iss": "https://sts.windows.net/78e60c0f-344b-405f-8c9a-63fe13a30962/",
        "iat": "1518116812",
        "nbf": "1518116812",
        "exp": "1518120712",
        "aio": "Y2NgYDjveebWbh3lRJuJone1i7fPAwA=",
        "appid": "004bc69c-cae7-45a3-8bed-9b37bce64746",
        "appidacr": "1",
        "http://schemas.microsoft.com/identity/claims/identityprovider": "https://sts.windows.net/78e60c0f-344b-405f-8c9a-63fe13a30962/",
        "http://schemas.microsoft.com/identity/claims/objectidentifier": "2c02c92d-c9b8-4fc2-8140-40f8ba2052a5",
        "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "2c02c92d-c9b8-4fc2-8140-40f8ba2052a5",
        "http://schemas.microsoft.com/identity/claims/tenantid": "78e60c0f-344b-405f-8c9a-63fe13a30962",
        "uti": "xhHR-2Xepke_G1gchNgPAA",
        "ver": "1.0"
    },
    "correlationId": "1bf65caf-3b8c-4521-8370-65bae816404b",
    "description": "",
    "eventDataId": "9c32a95d-ed19-4b1f-9826-d68e45742629",
    "eventName": {
        "value": "EndRequest",
        "localizedValue": "End request"
    },
    "category": {
        "value": "Administrative",
        "localizedValue": "Administrative"
    },
    "eventTimestamp": "2018-02-08T19:11:54.0105833Z",
    "id": "/subscriptions/xxx-xxx-xxx-xxx/resourcegroups/AnsibleRG/providers/Microsoft.Resources/deployments/ansible-arm/events/9c32a95d-ed19-4b1f-9826-d68e45742629/ticks/636537139140105833",
    "level": "Error",
    "operationId": "1bf65caf-3b8c-4521-8370-65bae816404b",
    "operationName": {
        "value": "Microsoft.Resources/deployments/write",
        "localizedValue": "Microsoft.Resources/deployments/write"
    },
    "resourceGroupName": "AnsibleRG",
    "resourceProviderName": {
        "value": "Microsoft.Resources",
        "localizedValue": "Microsoft Resources"
    },
    "resourceType": {
        "value": "Microsoft.Resources/deployments",
        "localizedValue": "Microsoft.Resources/deployments"
    },
    "resourceId": "/subscriptions/xxx-xxx-xxx-xxx/resourcegroups/AnsibleRG/providers/Microsoft.Resources/deployments/ansible-arm",
    "status": {
        "value": "Failed",
        "localizedValue": "Failed"
    },
    "subStatus": {
        "value": "BadRequest",
        "localizedValue": "Bad Request (HTTP Status Code: 400)"
    },
    "submissionTimestamp": "2018-02-08T19:12:10.4497444Z",
    "subscriptionId": "xxx-xxx-xxx-xxx",
    "properties": {
        "statusCode": "BadRequest",
        "serviceRequestId": null,
        "statusMessage": "{\"error\":{\"code\":\"InvalidTemplateDeployment\",\"message\":\"The template deployment 'ansible-arm' is not valid according to the validation procedure. The tracking id is '1bf65caf-3b8c-4521-8370-65bae816404b'. See inner errors for details. Please see https://aka.ms/arm-deploy for usage details.\",\"details\":[{\"code\":\"InvalidDomainNameLabel\",\"message\":\"The domain name label WinVM01 is invalid. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.\",\"details\":[]}]}}"
    },
    "relatedEvents": []
}

谢谢, RFD

1 个答案:

答案 0 :(得分:0)

错误是:

The domain name label WinVM01 is invalid. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$
基本上,没有大写字母