--- - name: "Onboard Windows Servers to Azure Arc-enabled servers with Public endpoint connectivity" hosts: all vars: azure: service_principal_id: 'ced53ad3-2832-4e85-8034-14d0e30896a3' service_principal_secret: '{{ secret_arc }}' resource_group: 'ape-platform-management-arc-prd-rg' tenant_id: '26845d4f-0cf4-4d08-b717-06b6b7824ec4' subscription_id: '831ece7a-8318-4861-9a74-789d4d221dd9' location: 'westeurope' tasks: - name: flushdns ansible.windows.win_command: cmd: ipconfig /flushdns - name: Download the Connected Machine Agent on Windows servers win_get_url: url: https://aka.ms/AzureConnectedMachineAgent dest: C:\AzureConnectedMachineAgent.msi # proxy_url: 10.245.143.7:3128 # when: (ansible_os_family == 'Windows') and (not azcmagent_win_downloaded.stat.exists) - name: Install the Connected Machine Agent on Windows servers win_package: path: C:\AzureConnectedMachineAgent.msi # when: (ansible_os_family == 'Windows') and (not azcmagent_win_downloaded.stat.exists) - name: Check if the Connected Machine Agent has already been connected on Windows win_command: azcmagent check register: azcmagent_win_connected # when: ansible_os_family == 'Windows' ignore_errors: yes failed_when: (azcmagent_win_connected.rc not in [ 0, 16 ]) changed_when: False - name: Connect the Connected Machine Agent on Windows servers to Azure Arc win_shell: azcmagent.exe connect --service-principal-id "{{ azure.service_principal_id }}" --service-principal-secret "{{ azure.service_principal_secret }}" --resource-group "{{ azure.resource_group }}" --tenant-id "{{ azure.tenant_id }}" --location "{{ azure.location }}" --subscription-id "{{ azure.subscription_id }}" args: chdir: 'C:\Program Files\AzureConnectedMachineAgent' # when: (azcmagent_win_connected.rc is defined and azcmagent_win_connected.rc != 0) # when: (ansible_os_family == 'Windows') and