| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 5 |
|
| 6 |
from __future__ import absolute_import, division, print_function |
| 7 |
__metaclass__ = type |
| 8 |
|
| 9 |
ANSIBLE_METADATA = {'metadata_version': '1.1', |
| 10 |
'status': ['preview'], |
| 11 |
'supported_by': 'community'} |
| 12 |
|
| 13 |
DOCUMENTATION = r''' |
| 14 |
--- |
| 15 |
module: intersight_unified_edge_profile |
| 16 |
short_description: Unified Edge server profile template for Cisco Intersight |
| 17 |
description: |
| 18 |
- Creates validated server profile templates for Cisco Unified Edge nodes |
| 19 |
used in AI Factory edge inference deployments. |
| 20 |
- Provides hardware-specific presets for supported Unified Edge platforms |
| 21 |
(UCS XE9305, XE130c M8, XE150c M8) with appropriate thermal limits, |
| 22 |
power budgets, and expansion constraints. |
| 23 |
- Attaches user-specified policies for BIOS, boot, storage, network, |
| 24 |
and other configuration via the PolicyBucket mechanism. |
| 25 |
- For generic server profile template management, use |
| 26 |
M(cisco.intersight.intersight_server_profile_template) instead. |
| 27 |
- For more information see L(Cisco Intersight,https://intersight.com/apidocs). |
| 28 |
extends_documentation_fragment: intersight |
| 29 |
options: |
| 30 |
state: |
| 31 |
description: |
| 32 |
- If C(present), will verify the resource is present and will create if needed. |
| 33 |
- If C(absent), will verify the resource is absent and will delete if needed. |
| 34 |
type: str |
| 35 |
choices: [present, absent] |
| 36 |
default: present |
| 37 |
organization: |
| 38 |
description: |
| 39 |
- The name of the Organization this resource is assigned to. |
| 40 |
type: str |
| 41 |
default: default |
| 42 |
name: |
| 43 |
description: |
| 44 |
- The name assigned to the server profile template. |
| 45 |
- The name must be between 1 and 62 alphanumeric characters, allowing special characters :-_. |
| 46 |
type: str |
| 47 |
required: true |
| 48 |
tags: |
| 49 |
description: |
| 50 |
- List of tags in Key:<user-defined key> Value:<user-defined value> format. |
| 51 |
type: list |
| 52 |
elements: dict |
| 53 |
description: |
| 54 |
description: |
| 55 |
- The user-defined description of the server profile template. |
| 56 |
type: str |
| 57 |
aliases: [descr] |
| 58 |
hardware_platform: |
| 59 |
description: |
| 60 |
- The Unified Edge hardware platform this template targets. |
| 61 |
- C(xe9305) targets the UCS XE9305 compact edge server. |
| 62 |
Designed for single-GPU or CPU-only inference at the edge with constrained |
| 63 |
thermal envelope and limited PCIe expansion. |
| 64 |
- C(xe130c_m8) targets the UCS XE130c M8 short-depth edge server. |
| 65 |
Supports up to 2 GPUs with moderate thermal headroom for inference workloads |
| 66 |
in ruggedized edge environments. |
| 67 |
- C(xe150c_m8) targets the UCS XE150c M8 edge compute server. |
| 68 |
Full-height edge server supporting up to 4 GPUs with higher power budget |
| 69 |
for demanding edge AI inference and light training workloads. |
| 70 |
type: str |
| 71 |
choices: [xe9305, xe130c_m8, xe150c_m8] |
| 72 |
required: true |
| 73 |
bios_policy: |
| 74 |
description: |
| 75 |
- Name of BIOS Policy to associate with this template. |
| 76 |
- Consider using a policy created by M(cisco.intersight.intersight_bios_ai_tuning) |
| 77 |
with the C(edge_ai) tuning profile. |
| 78 |
type: str |
| 79 |
boot_order_policy: |
| 80 |
description: |
| 81 |
- Name of Boot Order Policy to associate with this template. |
| 82 |
type: str |
| 83 |
firmware_policy: |
| 84 |
description: |
| 85 |
- Name of Firmware Policy to associate with this template. |
| 86 |
type: str |
| 87 |
storage_policy: |
| 88 |
description: |
| 89 |
- Name of Storage Policy to associate with this template. |
| 90 |
- Consider using a policy created by M(cisco.intersight.intersight_ai_storage_policy) |
| 91 |
with the C(edge_compact) storage profile. |
| 92 |
type: str |
| 93 |
thermal_policy: |
| 94 |
description: |
| 95 |
- Name of Thermal Policy to associate with this template. |
| 96 |
- If not specified, the hardware_platform preset will suggest an appropriate thermal mode. |
| 97 |
type: str |
| 98 |
power_policy: |
| 99 |
description: |
| 100 |
- Name of Power Policy to associate with this template. |
| 101 |
type: str |
| 102 |
lan_connectivity_policy: |
| 103 |
description: |
| 104 |
- Name of LAN Connectivity Policy to associate with this template. |
| 105 |
type: str |
| 106 |
ipmi_over_lan_policy: |
| 107 |
description: |
| 108 |
- Name of IPMI over LAN Policy to associate with this template. |
| 109 |
type: str |
| 110 |
kvm_policy: |
| 111 |
description: |
| 112 |
- Name of Virtual KVM Policy to associate with this template. |
| 113 |
type: str |
| 114 |
network_connectivity_policy: |
| 115 |
description: |
| 116 |
- Name of Network Connectivity Policy to associate with this template. |
| 117 |
type: str |
| 118 |
ntp_policy: |
| 119 |
description: |
| 120 |
- Name of NTP Policy to associate with this template. |
| 121 |
type: str |
| 122 |
snmp_policy: |
| 123 |
description: |
| 124 |
- Name of SNMP Policy to associate with this template. |
| 125 |
type: str |
| 126 |
ssh_policy: |
| 127 |
description: |
| 128 |
- Name of SSH Policy to associate with this template. |
| 129 |
type: str |
| 130 |
syslog_policy: |
| 131 |
description: |
| 132 |
- Name of Syslog Policy to associate with this template. |
| 133 |
type: str |
| 134 |
local_user_policy: |
| 135 |
description: |
| 136 |
- Name of Local User Policy to associate with this template. |
| 137 |
type: str |
| 138 |
author: |
| 139 |
- Steve Fulmer (@stevefulme1) |
| 140 |
''' |
| 141 |
|
| 142 |
EXAMPLES = r''' |
| 143 |
- name: Create XE9305 edge inference profile template |
| 144 |
cisco.intersight.intersight_unified_edge_profile: |
| 145 |
api_private_key: "{{ api_private_key }}" |
| 146 |
api_key_id: "{{ api_key_id }}" |
| 147 |
organization: Edge-Sites |
| 148 |
name: spt-xe9305-inference |
| 149 |
description: XE9305 compact edge inference server |
| 150 |
hardware_platform: xe9305 |
| 151 |
bios_policy: bios-edge-ai |
| 152 |
boot_order_policy: boot-uefi-nvme |
| 153 |
storage_policy: storage-edge-inference |
| 154 |
lan_connectivity_policy: lan-edge-mgmt |
| 155 |
|
| 156 |
- name: Create XE130c M8 edge GPU inference template |
| 157 |
cisco.intersight.intersight_unified_edge_profile: |
| 158 |
api_private_key: "{{ api_private_key }}" |
| 159 |
api_key_id: "{{ api_key_id }}" |
| 160 |
name: spt-xe130c-gpu-inference |
| 161 |
description: XE130c M8 with 2 GPUs for edge inference |
| 162 |
hardware_platform: xe130c_m8 |
| 163 |
bios_policy: bios-edge-ai |
| 164 |
storage_policy: storage-model-cache |
| 165 |
firmware_policy: fw-latest |
| 166 |
|
| 167 |
- name: Create XE150c M8 high-performance edge template |
| 168 |
cisco.intersight.intersight_unified_edge_profile: |
| 169 |
api_private_key: "{{ api_private_key }}" |
| 170 |
api_key_id: "{{ api_key_id }}" |
| 171 |
name: spt-xe150c-training |
| 172 |
description: XE150c M8 for edge training and inference |
| 173 |
hardware_platform: xe150c_m8 |
| 174 |
bios_policy: bios-gpu-inference-h100 |
| 175 |
storage_policy: storage-ai-inference |
| 176 |
|
| 177 |
- name: Delete edge profile template |
| 178 |
cisco.intersight.intersight_unified_edge_profile: |
| 179 |
api_private_key: "{{ api_private_key }}" |
| 180 |
api_key_id: "{{ api_key_id }}" |
| 181 |
name: spt-xe9305-inference |
| 182 |
hardware_platform: xe9305 |
| 183 |
state: absent |
| 184 |
''' |
| 185 |
|
| 186 |
RETURN = r''' |
| 187 |
api_response: |
| 188 |
description: The API response output returned by the specified resource. |
| 189 |
returned: always |
| 190 |
type: dict |
| 191 |
sample: |
| 192 |
"api_response": { |
| 193 |
"Name": "spt-xe9305-inference", |
| 194 |
"ObjectType": "server.ProfileTemplate", |
| 195 |
"TargetPlatform": "UnifiedEdgeServer" |
| 196 |
} |
| 197 |
hardware_constraints: |
| 198 |
description: Hardware constraints and recommendations for the selected platform. |
| 199 |
returned: when state is present |
| 200 |
type: dict |
| 201 |
''' |
| 202 |
|
| 203 |
|
| 204 |
from ansible.module_utils.basic import AnsibleModule |
| 205 |
from ansible_collections.cisco.intersight.plugins.module_utils.intersight import ( |
| 206 |
IntersightModule, |
| 207 |
intersight_argument_spec, |
| 208 |
resolve_policy_bucket, |
| 209 |
sync_policy_bucket, |
| 210 |
) |
| 211 |
|
| 212 |
|
| 213 |
# Hardware platform constraints and metadata |
| 214 |
HARDWARE_PLATFORMS = { |
| 215 |
'xe9305': { |
| 216 |
'description': 'UCS XE9305 compact edge server', |
| 217 |
'max_gpus': 0, |
| 218 |
'max_power_watts': 500, |
| 219 |
'thermal_recommendation': 'Acoustic', |
| 220 |
'form_factor': 'compact', |
| 221 |
'pcie_slots': 1, |
| 222 |
}, |
| 223 |
'xe130c_m8': { |
| 224 |
'description': 'UCS XE130c M8 short-depth edge server', |
| 225 |
'max_gpus': 2, |
| 226 |
'max_power_watts': 1200, |
| 227 |
'thermal_recommendation': 'Balanced', |
| 228 |
'form_factor': 'short-depth', |
| 229 |
'pcie_slots': 3, |
| 230 |
}, |
| 231 |
'xe150c_m8': { |
| 232 |
'description': 'UCS XE150c M8 edge compute server', |
| 233 |
'max_gpus': 4, |
| 234 |
'max_power_watts': 2400, |
| 235 |
'thermal_recommendation': 'HighPower', |
| 236 |
'form_factor': 'full-height', |
| 237 |
'pcie_slots': 6, |
| 238 |
}, |
| 239 |
} |
| 240 |
|
| 241 |
# Policy mapping for PolicyBucket resolution |
| 242 |
POLICY_MAPPING = { |
| 243 |
'bios_policy': {'resource_path': '/bios/Policies', 'object_type': 'bios.Policy'}, |
| 244 |
'boot_order_policy': {'resource_path': '/boot/PrecisionPolicies', 'object_type': 'boot.PrecisionPolicy'}, |
| 245 |
'firmware_policy': {'resource_path': '/firmware/Policies', 'object_type': 'firmware.Policy'}, |
| 246 |
'storage_policy': {'resource_path': '/storage/StoragePolicies', 'object_type': 'storage.StoragePolicy'}, |
| 247 |
'thermal_policy': {'resource_path': '/thermal/Policies', 'object_type': 'thermal.Policy'}, |
| 248 |
'power_policy': {'resource_path': '/power/Policies', 'object_type': 'power.Policy'}, |
| 249 |
'lan_connectivity_policy': {'resource_path': '/vnic/LanConnectivityPolicies', 'object_type': 'vnic.LanConnectivityPolicy'}, |
| 250 |
'ipmi_over_lan_policy': {'resource_path': '/ipmioverlan/Policies', 'object_type': 'ipmioverlan.Policy'}, |
| 251 |
'kvm_policy': {'resource_path': '/kvm/Policies', 'object_type': 'kvm.Policy'}, |
| 252 |
'network_connectivity_policy': {'resource_path': '/networkconfig/Policies', 'object_type': 'networkconfig.Policy'}, |
| 253 |
'ntp_policy': {'resource_path': '/ntp/Policies', 'object_type': 'ntp.Policy'}, |
| 254 |
'snmp_policy': {'resource_path': '/snmp/Policies', 'object_type': 'snmp.Policy'}, |
| 255 |
'ssh_policy': {'resource_path': '/ssh/Policies', 'object_type': 'ssh.Policy'}, |
| 256 |
'syslog_policy': {'resource_path': '/syslog/Policies', 'object_type': 'syslog.Policy'}, |
| 257 |
'local_user_policy': {'resource_path': '/iam/EndPointUserPolicies', 'object_type': 'iam.EndPointUserPolicy'}, |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
def main(): |
| 262 |
argument_spec = intersight_argument_spec.copy() |
| 263 |
argument_spec.update( |
| 264 |
state=dict(type='str', choices=['present', 'absent'], default='present'), |
| 265 |
organization=dict(type='str', default='default'), |
| 266 |
name=dict(type='str', required=True), |
| 267 |
description=dict(type='str', aliases=['descr']), |
| 268 |
tags=dict(type='list', elements='dict'), |
| 269 |
hardware_platform=dict(type='str', choices=['xe9305', 'xe130c_m8', 'xe150c_m8'], required=True), |
| 270 |
bios_policy=dict(type='str'), |
| 271 |
boot_order_policy=dict(type='str'), |
| 272 |
firmware_policy=dict(type='str'), |
| 273 |
storage_policy=dict(type='str'), |
| 274 |
thermal_policy=dict(type='str'), |
| 275 |
power_policy=dict(type='str'), |
| 276 |
lan_connectivity_policy=dict(type='str'), |
| 277 |
ipmi_over_lan_policy=dict(type='str'), |
| 278 |
kvm_policy=dict(type='str'), |
| 279 |
network_connectivity_policy=dict(type='str'), |
| 280 |
ntp_policy=dict(type='str'), |
| 281 |
snmp_policy=dict(type='str'), |
| 282 |
ssh_policy=dict(type='str'), |
| 283 |
syslog_policy=dict(type='str'), |
| 284 |
local_user_policy=dict(type='str'), |
| 285 |
) |
| 286 |
|
| 287 |
module = AnsibleModule( |
| 288 |
argument_spec, |
| 289 |
supports_check_mode=True, |
| 290 |
) |
| 291 |
|
| 292 |
intersight = IntersightModule(module) |
| 293 |
intersight.result['api_response'] = {} |
| 294 |
intersight.result['trace_id'] = '' |
| 295 |
|
| 296 |
resource_path = '/server/ProfileTemplates' |
| 297 |
|
| 298 |
intersight.api_body = { |
| 299 |
'Organization': { |
| 300 |
'Name': intersight.module.params['organization'], |
| 301 |
}, |
| 302 |
'Name': intersight.module.params['name'], |
| 303 |
} |
| 304 |
|
| 305 |
if module.params['state'] == 'present': |
| 306 |
intersight.set_tags_and_description() |
| 307 |
|
| 308 |
# Always set target platform to Unified Edge |
| 309 |
intersight.api_body['TargetPlatform'] = 'UnifiedEdgeServer' |
| 310 |
|
| 311 |
# Expose hardware constraints to the user |
| 312 |
platform = module.params['hardware_platform'] |
| 313 |
intersight.result['hardware_constraints'] = HARDWARE_PLATFORMS[platform] |
| 314 |
|
| 315 |
intersight.configure_policy_or_profile(resource_path=resource_path) |
| 316 |
template_response = intersight.result['api_response'] |
| 317 |
template_moid = template_response.get('Moid') if template_response else None |
| 318 |
|
| 319 |
# Sync PolicyBucket for attached policies |
| 320 |
if template_moid and module.params['state'] == 'present': |
| 321 |
organization_name = module.params['organization'] |
| 322 |
desired_bucket = resolve_policy_bucket(intersight, organization_name, POLICY_MAPPING) |
| 323 |
current_bucket = template_response.get('PolicyBucket') or [] |
| 324 |
bucket_path = '/server/ProfileTemplates/' + template_moid + '/PolicyBucket' |
| 325 |
sync_policy_bucket(intersight, bucket_path, desired_bucket, current_bucket) |
| 326 |
|
| 327 |
module.exit_json(**intersight.result) |
| 328 |
|
| 329 |
|
| 330 |
if __name__ == '__main__': |
| 331 |
main() |