Ansible 플레이북을 사용하여 대규모로 머신 연결
Ansible 플레이북을 사용하여 대규모로 Ansible 관리 노드를 Azure Arc 지원 서버에 온보딩할 수 있습니다. 이렇게 하려면 적절한 플레이북을 다운로드, 수정 및 실행합니다.
시작하려면 먼저 사전 요구 사항을 검토하고 구독 및 리소스에서 요구 사항을 충족하는지 확인해야 합니다. 지원되는 지역 및 기타 관련 고려 사항에 대한 자세한 내용은 Azure 지원 지역을 참조하세요. 또한 확장 계획 지침을 검토하여 설계 및 배포 기준뿐만 아니라 관리 및 모니터링 권장 사항을 파악합니다.
Azure 구독이 없는 경우 시작하기 전에 체험 계정을 만듭니다.
SQL Server에 대한 자동 연결
Microsoft SQL Server가 설치된 Azure Arc에 Windows 또는 Linux 서버를 연결하면 SQL Server 인스턴스도 자동으로 Azure Arc에 연결됩니다. Azure Arc를 통해 지원되는 SQL Server는 SQL Server 인스턴스 및 데이터베이스에 대한 상세 인벤토리와 추가 관리 기능을 제공합니다. 연결 프로세스의 일부로 확장이 Azure Arc 지원 서버에 배포되고 새 역할이 SQL Server 및 데이터베이스에 적용됩니다. SQL Server를 Azure Arc에 자동으로 연결하지 않으려면 Azure Arc에 연결될 때 이름이 ArcSQLServerExtensionDeployment
이고 값이 Disabled
인 Windows 또는 Linux 서버에 태그를 추가하여 옵트아웃할 수 있습니다.
자세한 내용은 Azure Arc를 통해 지원되는 SQL Server의 자동 연결 관리를 참조하세요.
서비스 주체 생성 및 Azure 세부 정보 수집
스크립트를 실행하여 머신을 연결하려면 다음을 수행해야 합니다.
단계에 따라 대규모 온보딩을 위한 서비스 주체 만들기
- 서비스 주체에 Azure Connected Machine 온보딩 역할을 할당하고 역할 범위를 대상 Azure 구독 또는 리소스 그룹으로 제한합니다.
- 서비스 주체 비밀 및 서비스 주체 클라이언트 ID를 기록해 둡니다. 나중에 이러한 값이 필요합니다.
Azure Arc 지원 리소스가 온보딩되는 테넌트 ID, 구독 ID, 리소스 그룹 및 지역에 대한 세부 정보를 수집합니다.
Ansible 플레이북 다운로드
Azure Arc 지원 서버에 컴퓨터를 온보딩하는 경우 다음 Ansible 플레이북 템플릿을 복사하고 플레이북을 다음과 같이 arc-server-onboard-playbook.yml
저장합니다.
---
- 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 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: 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: 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 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)
- 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 }}"'
when: (ansible_os_family == 'Windows') and (azcmagent_win_connected.rc is defined and azcmagent_win_connected.rc != 0)
Ansible 플레이북 수정
Ansible 플레이북을 다운로드한 후 다음 단계를 완료합니다.
Ansible 플레이북 내에서 이전에 수집된 서비스 주체 및 Azure 세부 정보를 사용하여 vars 섹션 아래의 변수를 수정합니다.
- 서비스 주체 ID
- 서비스 주체 비밀
- 리소스 그룹
- 테넌트 ID
- 구독 ID
- 지역
Azure Arc에 온보딩할 대상 서버를 캡처하는 올바른 호스트 필드를 입력합니다. Ansible 패턴을 사용하여 온보딩할 하이브리드 머신을 선택적으로 대상으로 지정할 수 있습니다.
이 템플릿은 Ansible 플레이북의 변수로 서비스 주체 비밀을 전달합니다. Ansible 자격 증명 모음을 사용하여 이 비밀을 암호화할 수 있으며 구성 파일을 통해 변수를 전달할 수 있습니다.
Ansible 플레이북 실행
Ansible 컨트롤 노드에서 ansible-playbook
명령을 호출하여 Ansible 플레이북을 실행합니다.
ansible-playbook arc-server-onboard-playbook.yml
플레이북이 실행 된 후 PLAY RECAP 는 모든 작업이 성공적으로 완료되었음을 나타내고 작업이 실패한 노드를 표시합니다.
Azure Arc 연결 확인
에이전트를 설치하고 Azure Arc 지원 서버에 연결하도록 구성한 후 Azure Portal로 이동하여 대상 호스트의 서버가 성공적으로 연결되었는지 확인합니다. Azure Portal에서 머신을 확인합니다.
다음 단계
- 계획 및 배포 가이드를 검토하여 모든 규모의 Azure Arc 지원 서버 배포를 계획하고 중앙 집중식 관리와 모니터링을 구현합니다.
- Connected Machine 에이전트 문제 해결 가이드에서 연결 문제 해결 정보를 검토합니다.
- Azure Policy를 사용하여 컴퓨터를 관리하는 방법(예: VM 게스트 구성, 컴퓨터에서 예상되는 Log Analytics 작업 영역에 보고하는지 확인, VM 인사이트를 사용하는 모니터링 사용 등)을 알아봅니다.