42 lines
1.9 KiB
YAML
42 lines
1.9 KiB
YAML
---
|
|
# tasks file for windows_azure-arc
|
|
- name: Onboard Linux and Windows Servers to Azure Arc-enabled servers with public endpoint connectivity
|
|
hosts: all
|
|
# vars:
|
|
# azure:
|
|
# service_principal_id: 'INSERT-SERVICE-PRINCIPAL-CLIENT-ID'
|
|
# service_principal_secret: 'INSERT-SERVICE-PRINCIPAL-SECRET'
|
|
# resource_group: 'INSERT-RESOURCE-GROUP'
|
|
# tenant_id: 'INSERT-TENANT-ID'
|
|
# subscription_id: 'INSERT-SUBSCRIPTION-ID'
|
|
# location: 'INSERT-LOCATION'
|
|
tasks:
|
|
- name: Check if the Connected Machine Agent has already been downloaded on Windows servers
|
|
win_stat:
|
|
path: C:\Program Files\AzureConnectedMachineAgent
|
|
register: azcmagent_win_downloaded
|
|
when: ansible_os_family == 'Windows'
|
|
|
|
- name: Download the Connected Machine Agent on Windows servers
|
|
win_get_url:
|
|
url: https://aka.ms/AzureConnectedMachineAgent
|
|
dest: C:\AzureConnectedMachineAgent.msi
|
|
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: Connect the Connected Machine Agent on Windows servers to Azure
|
|
win_shell: '& $env:ProgramFiles\AzureConnectedMachineAgent\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 }}"'
|
|
|
|
- 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
|
|
|
|
|