-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOnboardingAnsible.yml
47 lines (43 loc) · 1.9 KB
/
OnboardingAnsible.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
- name: "Onboard Linux Servers to Azure Arc-enabled servers with Public endpoint connectivity"
hosts: all
vars:
azure:
service_principal_id: '00cfee25-1338-4bf7-bcb8-6f3b359394c2'
service_principal_secret: 'INSERT-SERVICE-PRINCIPAL-SECRET'
resource_group: 'rg_raspberry'
tenant_id: '0290e2fc-e47a-4d27-9f33-28184a8224fb'
subscription_id: 'd90ff457-643a-4851-a0d4-d94cf2825e47'
location: 'westeurope'
tasks:
- name: "checkIfdownloaded"
stat:
path: /usr/bin/azcmagent
get_attributes: False
get_checksum: False
register: azcmagent_lnx_downloaded
when: ansible_system == 'Linux'
- name: "downloadConnectedMachineAgentLinuxANS"
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: "installConnectedMachineAgent"
become: yes
shell: bash ~/install_linux_azcmagent.sh
when: (ansible_system == 'Linux') and (not azcmagent_lnx_downloaded.stat.exists)
- name: "checkConnection"
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: "connectToAzureArc"
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 }}" --tags "Datacenter=rsp4,City=Amadora,StateOrDistrict=Lisboa,CountryOrRegion=Portugal"
when: (ansible_system == 'Linux') and (azcmagent_lnx_connected.rc is defined and azcmagent_lnx_connected.rc != 0)