61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
---
|
|
- name: get resource group info
|
|
become: true
|
|
become_user: root
|
|
# become_method: runas
|
|
hosts: localhost
|
|
tasks:
|
|
- name: Get facts for one resource group
|
|
azure_rm_resourcegroup_info:
|
|
name: "ape-platform-management-arc-prd-rg"
|
|
list_resources: yes
|
|
register: rg_info
|
|
- name: create list
|
|
set_fact:
|
|
namen: []
|
|
|
|
- name: add to list
|
|
set_fact:
|
|
namen: "{{namen + (rg_info.resourcegroups[0].resources | selectattr('type', 'eq', 'Microsoft.HybridCompute/machines') | map(attribute='name') | list )}}"
|
|
|
|
- name:
|
|
debug:
|
|
var: namen
|
|
- name: Add inventory
|
|
awx.awx.inventory:
|
|
name: "Azure Arc enabled hosts (dynamic)"
|
|
description: "Hosts synced from the azure arc prd resource group"
|
|
organization: "Aperam"
|
|
state: present
|
|
controller_host: https://awx-prd.aperam.internal
|
|
controller_oauthtoken: "{{oauth}}"
|
|
validate_certs: false
|
|
|
|
- name: add hosts to inventory
|
|
awx.awx.host:
|
|
inventory: "Azure Arc enabled hosts (dynamic)"
|
|
name: "{{item}}"
|
|
state: present
|
|
controller_host: https://awx-prd.aperam.internal
|
|
controller_oauthtoken: "{{oauth}}"
|
|
validate_certs: false
|
|
enabled: true
|
|
with_items: "{{namen}}"
|
|
#roles:
|
|
# - role: linux_update
|
|
# - role: azure_get-rg-facts
|
|
# - role: awx_create-inventory-from-list
|
|
|
|
#environment:
|
|
#aperam.com
|
|
# - AZURE_CLIENT_ID: "{{AZURE_CLIENT_ID}}"
|
|
# - AZURE_SECRET: "{{AZURE_SECRET}}"
|
|
# - AZURE_SUBSCRIPTION_ID: "{{AZURE_SUBSCRIPTION_ID}}"
|
|
# - AZURE_TENANT: "{{AZURE_TENANT}}"
|
|
vars:
|
|
- RG_name: ape-platform-management-arc-prd-rg
|
|
|
|
|
|
|
|
|
|
|