Init: mediaserver

This commit is contained in:
2023-02-08 12:13:28 +01:00
parent 848bc9739c
commit f7c23d4ba9
31914 changed files with 6175775 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
---
- name: "Configure Auto Support Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/AutoSupportPolicies
query_params:
$filter: "Name eq '{{ hx_auto_support_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name": "{{ hx_auto_support_policy }}",
"AdminState":"{{ hx_auto_support_enable }}",
"ServiceTicketReceipient":"{{ hx_auto_support_receipient }}",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: auto_support_policy
- debug: msg="HyperFlex Autosupport Policy named {{ hx_auto_support_policy }} has been created successfully."

View File

@@ -0,0 +1,50 @@
---
- name: "Configure Cluster Network Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterNetworkPolicies
query_params:
$filter: "Name eq '{{ hx_cluster_network_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_cluster_network_policy }}",
"JumboFrame":"{{ hx_jumbo_frames }}",
"KvmIpRange":{
"StartAddr":"{{ ucs_kvm_start_ip }}",
"EndAddr":"{{ ucs_kvm_end_ip }}",
"Gateway":"{{ ucs_kvm_gateway }}",
"Netmask":"{{ ucs_kvm_netmask }}"
},
"MacPrefixRange":{
"StartAddr":"{{ hx_mac_start }}",
"EndAddr":"{{ hx_mac_end }}"
},
"MgmtVlan":{
"Name":"{{ hx_mgmt_vlan_name }}",
"VlanId":"{{ hx_mgmt_vlan_id }}"
},
"VmMigrationVlan":{
"Name":"{{ hx_migration_vlan_name }}",
"VlanId":"{{ hx_migration_vlan_id }}"
},
"VmNetworkVlans":"{{ hx_guest_vm_vlans }}",
"UplinkSpeed": "default",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: cluster_network
- debug: msg="HyperFlex Cluster Network Policy named {{ hx_cluster_network_policy }} has been created successfully."

View File

@@ -0,0 +1,8 @@
---
# Default variable values for HyperFlex Cluster Profiles
hx_mgmt_platform: FI
hx_hypervisor_type: ESXi
hx_replication_factor: 3
hx_vdi_optimization: false
hx_disk_cleanup: false
hx_laz_autoconfig: false

View File

@@ -0,0 +1,33 @@
---
- name: "Configure Cluster Profile"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterProfiles
query_params:
$filter: "Name eq '{{ hx_cluster_profile }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_cluster_profile }}",
"MgmtPlatform":"{{ hx_mgmt_platform }}",
"HypervisorType":"{{ hx_hypervisor_type }}",
"MgmtIpAddress":"{{ hx_mgmt_ip }}",
"MacAddressPrefix":"{{ hx_mgmt_mac_prefix }}",
"Replication":"{{ hx_replication_factor }}",
"StorageDataVlan":{
"Name":"{{ hx_data_vlan_name }}",
"VlanId":"{{ hx_data_vlan_id }}"
}
}
register: cluster_profile
- debug: msg="HyperFlex Cluster Profile named {{ hx_cluster_profile }} has been created successfully."

View File

@@ -0,0 +1,34 @@
---
- name: "Configure Cluster Storage Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterStoragePolicies
query_params:
$filter: "Name eq '{{ hx_cluster_storage_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_cluster_storage_policy }}",
"VdiOptimization":"{{ hx_vdi_optimization }}",
"DiskPartitionCleanup":"{{ hx_disk_cleanup }}",
"LogicalAvalabilityZoneConfig":{
"AutoConfig":"{{ hx_laz_autoconfig }}"
},
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: storage_setting
- debug: msg="HyperFlex Cluster Storage Policy named {{ hx_cluster_storage_policy }} has been created successfully."

View File

@@ -0,0 +1,43 @@
---
# Get cluster profile
- name: Get Cluster Profile
vars:
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterProfiles
query_params:
$filter: "Name eq '{{ hx_cluster_name }}'"
register: profile
# Prompt for cluster deployment action
- name: "Prompt for deployment action"
pause:
prompt: "Set the deployment action. Valid choices are Validate, Deploy, Continue or Retry."
echo: yes
register: hx_action
run_once: true
# Set cluster deployment action
- name: Set Cluster Action
vars:
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterProfiles
query_params:
$filter: "Name eq '{{ hx_cluster_name }}'"
api_body: {
"Action": "{{ hx_action.user_input }}"
}
when:
- profile.api_response.ConfigContext.ConfigState != 'Configuring'
- profile.api_response.ConfigContext.ConfigState != 'Associated'
# Can optionally wait for subsequent tasks if needed
# register: result
# until: result.api_response.config_context.config_state == 'Associated'
# retries: 20
# delay: 30
- debug: msg="HyperFlex Cluster Profile deployment action has been triggered successfully."

View File

@@ -0,0 +1,38 @@
---
- name: "Configure Cluster Network Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterNetworkPolicies
query_params:
$filter: "Name eq '{{ hx_cluster_network_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_cluster_network_policy }}",
"JumboFrame":"{{ hx_jumbo_frames }}",
"MacPrefixRange":{
"StartAddr":"{{ hx_mac_start }}",
"EndAddr":"{{ hx_mac_end }}"
},
"MgmtVlan":{
"VlanId":"{{ hx_mgmt_vlan_id }}"
},
"UplinkSpeed":"{{ hx_uplink_speed }}",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: cluster_network
- debug: msg="HyperFlex Cluster Network Policy named {{ hx_cluster_network_policy }} has been created successfully."

View File

@@ -0,0 +1,6 @@
---
# Default variable values for HyperFlex Cluster Profiles
hx_mgmt_platform: EDGE
hx_hypervisor_type: ESXi
hx_vdi_optimization: false
hx_disk_cleanup: false

View File

@@ -0,0 +1,31 @@
---
- name: "Configure Cluster Profile"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterProfiles
query_params:
$filter: "Name eq '{{ hx_cluster_profile }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_cluster_profile }}",
"MgmtPlatform":"{{ hx_mgmt_platform }}",
"HypervisorType":"{{ hx_hypervisor_type }}",
"MgmtIpAddress":"{{ hx_mgmt_ip }}",
"MacAddressPrefix":"{{ hx_mgmt_mac_prefix }}",
"StorageDataVlan":{
"VlanId":"{{ hx_data_vlan_id }}"
}
}
register: cluster_profile
- debug: msg="HyperFlex Cluster Profile named {{ hx_cluster_profile }} has been created successfully."

View File

@@ -0,0 +1,31 @@
---
- name: "Configure Cluster Storage Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterStoragePolicies
query_params:
$filter: "Name eq '{{ hx_cluster_storage_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_cluster_storage_policy }}",
"VdiOptimization":"{{ hx_vdi_optimization }}",
"DiskPartitionCleanup":"{{ hx_disk_cleanup }}",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: storage_setting
- debug: msg="HyperFlex Cluster Storage Policy named {{ hx_cluster_storage_policy }} has been created successfully."

View File

@@ -0,0 +1,30 @@
---
- name: "Configure Software Version Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/SoftwareVersionPolicies
query_params:
$filter: "Name eq '{{ hx_software_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_software_policy }}",
"HxdpVersion":"{{ hxdp_version }}",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: software_policy
- debug: msg="HyperFlex Software Version Policy named {{ hx_software_policy }} has been created successfully."

View File

@@ -0,0 +1,52 @@
---
- name: "Configure External FC Storage Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ExtFcStoragePolicies
query_params:
$filter: "Name eq '{{ hx_fc_setting_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"AdminState":"{{ hx_fc_setting_enable }}",
"Name":"{{ hx_fc_setting_policy }}",
"ExtaTraffic":{
"Name":"{{ hx_vsan_a_name }}",
"VsanId":"{{ hx_vsan_a_id }}"
},
"ExtbTraffic":{
"Name":"{{ hx_vsan_b_name }}",
"VsanId":"{{ hx_vsan_b_id }}"
},
"WwxnPrefixRange":{
"StartAddr":"{{ hx_fc_wwxn_range_start }}",
"EndAddr":"{{ hx_fc_wwxn_range_end }}"
},
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: fc_settings
# Set WWXN prefix for the cluster profile when additional FC HBAs are configured
- name: "Perform Action on {{ hx_profile_name }} Profile"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterProfiles
query_params:
$filter: "Name eq '{{ hx_cluster_name }}'"
api_body: {
"WwxnPrefix": "{{ hx_fc_wwxn_range_start }}"
}
- debug: msg="HyperFlex External FC Storage Policy named {{ hx_fc_setting_policy }} has been created successfully."

View File

@@ -0,0 +1,17 @@
---
- name: "Retrieve Intersight Org"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /organization/Organizations
query_params:
$filter: "Name eq '{{ org_name }}'"
register: intersight_org

View File

@@ -0,0 +1,38 @@
---
- name: "Configure External iSCSI Storage Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ExtIscsiStoragePolicies
query_params:
$filter: "Name eq '{{ hx_iscsi_setting_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"AdminState":"{{ hx_iscsi_setting_enable }}",
"Name":"{{ hx_iscsi_setting_policy }}",
"ExtaTraffic":{
"Name":"{{ hx_iscsi_vlan_a_name }}",
"VlanId":"{{ hx_iscsi_vlan_a_id }}"
},
"ExtbTraffic":{
"Name":"{{ hx_iscsi_vlan_b_name }}",
"VlanId":"{{ hx_iscsi_vlan_b_id }}"
},
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: iscsi_settings
- debug: msg="HyperFlex External iSCSI Storage Policy named {{ hx_iscsi_setting_policy }} has been created successfully."

View File

@@ -0,0 +1,33 @@
---
- name: "Configure Local Credential Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/LocalCredentialPolicies
query_params:
$filter: "Name eq '{{ hx_local_credential_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name": "{{ hx_local_credential_policy }}",
"HypervisorAdmin":"{{ hx_hypervisor_admin }}",
"FactoryHypervisorPassword":"{{ hx_hypervisor_factory_password }}",
"HypervisorAdminPwd":"{{ hx_hypervisor_password | default(omit) }}",
"HxdpRootPwd":"{{ hx_dp_root_password | default(omit) }}",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: local_credential
- debug: msg="HyperFlex Local Credential Policy named {{ hx_local_credential_policy }} has been created successfully."

View File

@@ -0,0 +1,42 @@
---
- name: "Configure Node Configuration Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/NodeConfigPolicies
query_params:
$filter: "Name eq '{{ hx_node_config_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_node_config_policy }}",
"NodeNamePrefix":"{{ hx_node_profile_prefix }}",
"MgmtIpRange":{
"StartAddr":"{{ esx_mgmt_ip_start }}",
"EndAddr":"{{ esx_mgmt_ip_end }}",
"Netmask":"{{ hx_mgmt_netmask }}",
"Gateway":"{{ hx_mgmt_gateway }}"
},
"HxdpIpRange":{
"StartAddr":"{{ hx_mgmt_vm_ip_start }}",
"EndAddr":"{{ hx_mgmt_vm_ip_end }}",
"Netmask":"{{ hx_mgmt_netmask }}",
"Gateway":"{{ hx_mgmt_gateway }}"
},
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: node_config
- debug: msg="HyperFlex Node Configuration Policy named {{ hx_node_config_policy }} has been created successfully."

View File

@@ -0,0 +1,49 @@
---
# Get server Moids
- name: Get server Moid
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
cisco.intersight.intersight_info:
<<: *api_info
server_names:
- "{{ item }}"
loop: "{{ hx_servers }}"
register: inventory
# Get Cluster Profile Attributes
- name: "Get HyperFlex Cluster Profile"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ClusterProfiles
query_params:
$filter: "Name eq '{{ hx_cluster_name }}'"
register: profile
# Assign servers and profile to node profile
- name: "Configure Node Profile"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/NodeProfiles
query_params:
$filter: "Name eq '{{ hx_node_profile_prefix }}-{{ '%02d' % (idx + 1) }}'"
api_body: {
"Name":"{{ hx_node_profile_prefix }}-{{ '%02d' % (idx + 1) }}",
"AssignedServer": {
"Moid": "{{ item.intersight_servers[0].Moid }}",
"ObjectType": "compute.RackUnit"
},
"ClusterProfile": {
"Moid": "{{ profile.api_response.Moid }}"
}
}
when: item.intersight_servers is not none
loop: "{{ inventory.results }}"
loop_control:
index_var: idx
label: "{{ item.intersight_servers[0].Name }}"
- debug: msg="HyperFlex Node Profiles have been created successfully."

View File

@@ -0,0 +1,31 @@
---
- name: "Configure Proxy Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/ProxySettingPolicies
query_params:
$filter: "Name eq '{{ hx_proxy_setting_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_proxy_setting_policy }}",
"Hostname":"{{ hx_proxy_setting_hostname }}",
"Port":"{{ hx_proxy_setting_port }}",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: proxy_setting
- debug: msg="HyperFlex Proxy Policy named {{ hx_proxy_setting_policy }} has been created successfully."

View File

@@ -0,0 +1,31 @@
---
- name: "Configure Software Version Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/SoftwareVersionPolicies
query_params:
$filter: "Name eq '{{ hx_software_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_software_policy }}",
"HxdpVersion":"{{ hxdp_version }}",
"ServerFirmwareVersion":"{{ ucs_firmware_version }}",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: software_policy
- debug: msg="HyperFlex Software Version Policy named {{ hx_software_policy }} has been created successfully."

View File

@@ -0,0 +1,33 @@
---
- name: "Configure System Config Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/SysConfigPolicies
query_params:
$filter: "Name eq '{{ hx_sys_config_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name": "{{ hx_sys_config_policy }}",
"Timezone":"{{ hx_sys_config_timezone }}",
"DnsServers":"{{ hx_sys_config_dns_servers }}",
"NtpServers":"{{ hx_sys_config_ntp_servers }}",
"DnsDomainName":"{{ hx_sys_config_dns_domain }}",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: sys_config
- debug: msg="HyperFlex System Config Policy named {{ hx_sys_config_policy }} has been created successfully."

View File

@@ -0,0 +1,33 @@
---
- name: "Configure vCenter Config Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
intersight_rest_api:
<<: *api_info
resource_path: /hyperflex/VcenterConfigPolicies
query_params:
$filter: "Name eq '{{ hx_vcenter_config_policy }}'"
api_body: {
"Organization": {
"Moid": "{{ intersight_org.api_response.Moid }}"
},
"Name":"{{ hx_vcenter_config_policy }}",
"Hostname":"{{ hx_vcenter_hostname }}",
"Username":"{{ hx_vcenter_username }}",
"Password":"{{ hx_vcenter_password | default(omit) }}",
"DataCenter":"{{ hx_vcenter_datacenter }}",
"ClusterProfiles": [
{
"Moid": "{{ cluster_profile.api_response.Moid }}"
}
]
}
register: vcenter
- debug: msg="HyperFlex vCenter Config Policy named {{ hx_vcenter_config_policy }} has been created successfully."

View File

@@ -0,0 +1,40 @@
---
- name: "Configure {{ api_body.Name }} Server Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: "{{ resource_path }}"
query_params:
$filter: "Name eq '{{ api_body.Name }}'"
api_body: "{{ api_body }}"
register: policy_resp
# Append profile_resp list to policy
- block:
# Create a list of all host's profile Moids
- set_fact:
# See the Ansible docs on json_query for info on how the Moid data is being extracted
profile_list: "{{ ansible_play_hosts | map('extract', hostvars, 'profile_resp') | list | json_query(moid_query) }}"
vars:
moid_query: "[*].api_response.{Moid: Moid, ObjectType: 'server.Profile'}"
- name: "Update Server Profiles used by {{ api_body.Name }} Server Policy (change may always be reported)"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: "{{ resource_path }}"
query_params:
$filter: "Name eq '{{ api_body.Name }}'"
api_body: {
"Profiles": "{{ profile_list + policy_resp.api_response.Profiles }}"
}
# Do not update if the profile isn't available
when:
- profile_resp is defined
- profile_resp.api_response.Moid is defined
- policy_resp is defined
- policy_resp.api_response.Profiles is defined

View File

@@ -0,0 +1,30 @@
---
- name: "Configure {{ inventory_hostname }} power state"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /compute/ServerSettings
query_params:
$filter: "Server.Moid eq '{{ server_moid }}'"
api_body: {
"AdminPowerState": "{{ power_state }}"
}
when: power_state is defined
# Configure LED locator state
- name: "Configure {{ inventory_hostname }} locator state"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /compute/ServerSettings
query_params:
$filter: "Server.Moid eq '{{ server_moid }}'"
api_body: {
"AdminLocatorLedState": "{{ locator_state }}"
}
when: locator_state is defined