first commit
This commit is contained in:
48
roles/linux_azure-arc/tasks/main.yml
Normal file
48
roles/linux_azure-arc/tasks/main.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
# tasks file for linux_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 Linux servers
|
||||
stat:
|
||||
path: /usr/bin/azcmagent
|
||||
get_attributes: False
|
||||
get_checksum: False
|
||||
register: azcmagent_lnx_downloaded
|
||||
when: ansible_system == 'Linux'
|
||||
|
||||
- name: Download the Connected Machine Agent on Linux servers
|
||||
become: yes
|
||||
get_url:
|
||||
url: https://aka.ms/azcmagent
|
||||
dest: ~/install_linux_azcmagent.sh
|
||||
mode: '700'
|
||||
when: (ansible_system == 'Linux') and (azcmagent_lnx_downloaded.stat.exists == false)
|
||||
|
||||
- name: Install the Connected Machine Agent on Linux servers
|
||||
become: yes
|
||||
shell: bash ~/install_linux_azcmagent.sh
|
||||
when: (ansible_system == 'Linux') and (not azcmagent_lnx_downloaded.stat.exists)
|
||||
|
||||
- name: Check if the Connected Machine Agent has already been connected
|
||||
become: true
|
||||
command:
|
||||
cmd: azcmagent check
|
||||
register: azcmagent_lnx_connected
|
||||
ignore_errors: yes
|
||||
when: ansible_system == 'Linux'
|
||||
failed_when: (azcmagent_lnx_connected.rc not in [ 0, 16 ])
|
||||
changed_when: False
|
||||
|
||||
- name: Connect the Connected Machine Agent on Linux servers to Azure Arc
|
||||
become: yes
|
||||
shell: azcmagent 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 }}"
|
||||
when: (ansible_system == 'Linux') and (azcmagent_lnx_connected.rc is defined and azcmagent_lnx_connected.rc != 0)
|
||||
Reference in New Issue
Block a user