Debian Codegraph @

ansible_collections/azure/azcollection/roles/azure_arc/tasks/main.yml

raw symbols SCIP
1 ---
2 - name: Generate tags string
3 ansible.builtin.set_fact:
4 azure_arc_processed_tags: |-
5 {%- for k, v in azure_arc_tags.items() %}
6 {{ k | quote }}={{ v | replace(",", "\,") | quote }}{% if not loop.last %},{% endif %}
7 {%- endfor %}
8
9 - name: Set helper fact for proxy proxy.url if needed
10 when: proxy is defined
11 ansible.builtin.set_fact:
12 azure_arc_proxy_url: "http://{{ proxy['hostname'] }}:{{ proxy['port'] }}"
13
14 - name: Set helper fact for desired_version if needed
15 when: desired_version is defined
16 ansible.builtin.set_fact:
17 azure_arc_desired_version: "{{ desired_version }}"
18
19 - name: Set helper fact for altdownload if needed
20 when: altdownload is defined
21 ansible.builtin.set_fact:
22 azure_arc_altdownload: "{{ altdownload }}"
23
24 - name: Gather Resource Group info
25 azure.azcollection.azure_rm_resourcegroup_info:
26 name: "{{ azure_arc_resource_group }}"
27 register: __azure_arc_rg_info
28 delegate_to: localhost
29 when: azure_arc_location is not defined
30
31 - name: Set azure_location from resource_group
32 ansible.builtin.set_fact:
33 azure_arc_location: "{{ __azure_arc_rg_info.resourcegroups.0.location }}"
34 when: azure_arc_location is not defined
35
36 - name: Include install tasks for Linux
37 ansible.builtin.include_tasks: "linux_install.yml"
38 when: ansible_system == 'Linux'
39
40 - name: Include show tasks for Linux
41 ansible.builtin.include_tasks: "linux_show.yml"
42 when: ansible_system == 'Linux'
43
44 - name: Set helper fact for configuration
45 ansible.builtin.set_fact:
46 azure_arc_show: "{{ azure_arc_show_json.stdout | ansible.builtin.from_json }}"
47
48 - name: Set azcmagent proxy setting if not already set correctly
49 when: azure_arc_proxy_url is defined and azure_arc_show.httpsProxy != azure_arc_proxy_url
50 block:
51 - name: Include proxy tasks for Linux
52 ansible.builtin.include_tasks: "linux_proxy.yml"
53 when: ansible_system == 'Linux'
54
55 # When registered with Azure, validate current configuration is equal to expected configuration and set the resource id as ansible fact
56 - name: Assert that configuration is matching expected values and set resource id fact
57 when: azure_arc_show.resourceId | default('') != ''
58 block:
59 - name: Set resource id as variable for easy access in other roles (already connected to azure arc)
60 ansible.builtin.set_fact:
61 azure_arc_resource_id: "{{ azure_arc_show.resourceId }}"
62
63 - name: Verify configuration settings match expected values
64 ansible.builtin.assert:
65 that:
66 - azure_arc_show.cloud == azure_arc_cloud
67 - azure_arc_show.resourceGroup == azure_arc_resource_group
68 - azure_arc_show.location == azure_arc_location
69 - azure_arc_show.tenantId == azure_arc_tenant_id
70 - azure_arc_show.subscriptionId == azure_arc_subscription_id
71
72 - name: Connect if not already connected to azure
73 when: azure_arc_show.resourceId | default('') == ''
74 block:
75 - name: Get access token for arc onboarding
76 # Run on localhost, so that service principal secrets don't leave control node
77 delegate_to: localhost
78 # This command produces output that includes an access token
79 no_log: true
80 azure.azcollection.azure_rm_accesstoken_info:
81 client_id: "{{ azure_arc_application_id | default(omit) }}"
82 secret: "{{ azure_arc_client_secret | default(omit) }}"
83 tenant: "{{ azure_arc_tenant_id | default(omit) }}"
84 subscription_id: "{{ azure_arc_subscription_id | default(omit) }}"
85 scopes:
86 - https://management.azure.com/.default
87 auth_source: "{{ auth_source | default(omit) }}"
88 register: azure_arc_access_token
89
90 - name: Include Connect tasks for Linux
91 ansible.builtin.include_tasks: "linux_connect.yml"
92 when: ansible_system == 'Linux'
93
94 - name: Transform json stdout output to variable
95 ansible.builtin.set_fact:
96 azure_arc_azcmagent_connect: "{{ azure_arc_azcmagent_connect_json.stdout | ansible.builtin.from_json }}"
97
98 - name: Set resource id as variable for easy access in other roles (newly registered system in azure arc)
99 ansible.builtin.set_fact:
100 azure_arc_resource_id: "{{ azure_arc_azcmagent_connect.resourceId }}"