summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/intersight/playbooks
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/cisco/intersight/playbooks')
-rw-r--r--ansible_collections/cisco/intersight/playbooks/claim_device.yml3
-rw-r--r--ansible_collections/cisco/intersight/playbooks/cos_server_policies_and_profiles.yml25
-rw-r--r--ansible_collections/cisco/intersight/playbooks/deploy_server_profiles.yml31
-rw-r--r--ansible_collections/cisco/intersight/playbooks/firmware_direct_download.yml24
-rw-r--r--ansible_collections/cisco/intersight/playbooks/hcl_status.yml30
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_bios_policy.yml31
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_boot_order_policy.yml11
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_domain_profile.yml37
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_eth_network.yml20
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_imc_access_policy.yml18
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_lan_connectivity_policy.yml37
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_local_user_policy.yml10
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_ntp_policy.yml7
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_oob_imc_access_policy.yml31
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_port_policy.yml19
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_server_profile.yml30
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_server_profile_template.yml31
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_virtual_media_policy.yml19
-rw-r--r--ansible_collections/cisco/intersight/playbooks/intersight_vm_hosts.yml23
-rw-r--r--ansible_collections/cisco/intersight/playbooks/only_new_server_profiles.yml31
-rw-r--r--ansible_collections/cisco/intersight/playbooks/os_install.yml51
-rw-r--r--ansible_collections/cisco/intersight/playbooks/ova_workflow.yml14
-rw-r--r--ansible_collections/cisco/intersight/playbooks/profile_with_buckets.yml6
-rw-r--r--ansible_collections/cisco/intersight/playbooks/pxe_boot.yml7
-rw-r--r--ansible_collections/cisco/intersight/playbooks/roles/policies/server_policies/tasks/main.yml22
-rw-r--r--ansible_collections/cisco/intersight/playbooks/server_firmware.yml31
-rw-r--r--ansible_collections/cisco/intersight/playbooks/update_all_inventory.yml30
-rw-r--r--ansible_collections/cisco/intersight/playbooks/update_standalone_inventory.yml30
-rw-r--r--ansible_collections/cisco/intersight/playbooks/vault_intersight_server_profile.yml28
29 files changed, 427 insertions, 260 deletions
diff --git a/ansible_collections/cisco/intersight/playbooks/claim_device.yml b/ansible_collections/cisco/intersight/playbooks/claim_device.yml
index 06d397c6c..1b50e7258 100644
--- a/ansible_collections/cisco/intersight/playbooks/claim_device.yml
+++ b/ansible_collections/cisco/intersight/playbooks/claim_device.yml
@@ -5,7 +5,8 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
+- name: Claim device
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
gather_facts: false
vars:
diff --git a/ansible_collections/cisco/intersight/playbooks/cos_server_policies_and_profiles.yml b/ansible_collections/cisco/intersight/playbooks/cos_server_policies_and_profiles.yml
index 9adc3ebd0..c1d9b0b44 100644
--- a/ansible_collections/cisco/intersight/playbooks/cos_server_policies_and_profiles.yml
+++ b/ansible_collections/cisco/intersight/playbooks/cos_server_policies_and_profiles.yml
@@ -7,10 +7,9 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
+- name: "Configure Server Profiles and Policies for Cloud Object Storage Solution"
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -26,8 +25,8 @@
org_name: DevNet
tasks:
# Get the Organization Moid used by all profiles and policies
- - name: "Get Organization {{ org_name }} Moid"
- intersight_rest_api:
+ - name: "Get Organization Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /organization/Organizations
query_params:
@@ -39,8 +38,8 @@
# Configure profiles specific to server (run for each server in the inventory)
# Server Profiles role will register a profile_resp and profile_resp list (from all hosts) can be used by policy tasks
#
- - name: "Configure {{ profile_name }} Server Profile"
- intersight_rest_api:
+ - name: "Configure Server Profile"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /server/Profiles
query_params:
@@ -119,7 +118,7 @@
- block:
# Ethernet Adapter
- name: "Configure Ethernet Adapter Policy"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthAdapterPolicies
query_params:
@@ -150,7 +149,7 @@
register: eth_adapter_resp
# Ethernet Network
- name: "Configure Ethernet Network Policy"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthNetworkPolicies
query_params:
@@ -168,7 +167,7 @@
register: eth_network_resp
# Ethernet QoS
- name: "Configure Ethernet QoS Policy"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthQosPolicies
query_params:
@@ -195,7 +194,7 @@
# vNIC configuration
# Ideally this would be in a loop, but Uplink is converted to a string (instead of the required int) when in a loop
- name: "Configure eth0"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthIfs
query_params:
@@ -224,7 +223,7 @@
}
}
- name: "Configure eth1"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthIfs
query_params:
@@ -273,7 +272,7 @@
- block:
# Disk Group policy
- name: "Configure Disk Group Policy"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /storage/DiskGroupPolicies
query_params:
diff --git a/ansible_collections/cisco/intersight/playbooks/deploy_server_profiles.yml b/ansible_collections/cisco/intersight/playbooks/deploy_server_profiles.yml
index 6e9a3892e..5e48397f1 100644
--- a/ansible_collections/cisco/intersight/playbooks/deploy_server_profiles.yml
+++ b/ansible_collections/cisco/intersight/playbooks/deploy_server_profiles.yml
@@ -7,7 +7,8 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
+- name: Deploy Server Profiles
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
gather_facts: false
vars:
@@ -22,11 +23,12 @@
state: "{{ state | default(omit) }}"
# Server Profile name default
profile_name: "SP-{{ inventory_hostname }}"
+ profile_action: Deploy
tasks:
# Deploy (or perform other action)
- # action can be given on the command line if needed, e.g., ansible-playbook ... -e action=Unassign
- # to delete a profile (profile must 1st be unassigned): ansible-playbook ... -e state=absent -e action=No-op
- - name: Deploy (or user defined action) Server Profile
+ # action can be given on the command line if needed, e.g., ansible-playbook ... -e profile_action=Unassign
+ # to delete a profile (profile must 1st be unassigned): ansible-playbook ... -e state=absent -e profile_action=No-op
+ - name: Deploy Server Profile
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /server/Profiles
@@ -36,3 +38,24 @@
"Action": "{{ profile_action | default('Deploy') }}"
}
delegate_to: localhost
+ when: profile_action == 'Deploy'
+ - name: Unassign Server Profile
+ cisco.intersight.intersight_rest_api:
+ <<: *api_info
+ resource_path: /server/Profiles
+ query_params:
+ $filter: "Name eq '{{ profile_name }}'"
+ api_body: {
+ "AssignedServer":null,
+ "ServerAssignmentMode":"None"
+ }
+ delegate_to: localhost
+ when: profile_action == 'Unassign'
+ - name: Delete Server Profile
+ cisco.intersight.intersight_rest_api:
+ <<: *api_info
+ resource_path: /server/Profiles
+ query_params:
+ $filter: "Name eq '{{ profile_name }}'"
+ delegate_to: localhost
+ when: profile_action == 'No-op' and state == 'absent'
diff --git a/ansible_collections/cisco/intersight/playbooks/firmware_direct_download.yml b/ansible_collections/cisco/intersight/playbooks/firmware_direct_download.yml
index 4277f930a..c46326059 100644
--- a/ansible_collections/cisco/intersight/playbooks/firmware_direct_download.yml
+++ b/ansible_collections/cisco/intersight/playbooks/firmware_direct_download.yml
@@ -5,10 +5,9 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
+- name: Firmware update using direct download
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -23,27 +22,32 @@
fw_version: 4.2(2d)
tasks:
# Set the distributable type based on the management mode and server type
- - set_fact:
+ - name: Set distributable type to IMMHOST
+ ansible.builtin.set_fact:
dist_type: IMMHOST
when: mode == 'Intersight' or mode == 'IntersightStandalone'
- - set_fact:
+ - name: Set distributable type to UMMBLADE
+ ansible.builtin.set_fact:
dist_type: UMMBLADE
when: mode == 'UCSM' and object_type == 'Blade'
- - set_fact:
+ - name: Set distributable type to UMMRACK
+ ansible.builtin.set_fact:
dist_type: UMMRACK
when: mode == 'UCSM' and object_type == 'RackUnit'
# Get a user defined FW version
- name: Get Moid of user defined FW version
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /firmware/Distributables
query_params:
- $filter: "SupportedModels eq '{{ model }}' and Version eq '{{ fw_version }}' and Tags.Key eq 'cisco.meta.distributabletype' and Tags.Value eq '{{ dist_type }}' and Tags.Key eq 'cisco.meta.repositorytype' and Tags.Value eq 'IntersightCloud'"
+ $filter: >-
+ SupportedModels eq '{{ model }}' and Version eq '{{ fw_version }}' and Tags.Key eq 'cisco.meta.distributabletype' and Tags.Value eq
+ '{{ dist_type }}' and Tags.Key eq 'cisco.meta.repositorytype' and Tags.Value eq 'IntersightCloud'"
delegate_to: localhost
register: fw_resp
# Update server firmware with a post based on server moid
- name: Update server firmware
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /firmware/Upgrades
query_params:
@@ -70,7 +74,7 @@
- fw_resp.api_response.Moid is defined
# Wait for download/update to complete
- name: Check firmware download/update status
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /firmware/UpgradeStatuses
query_params:
diff --git a/ansible_collections/cisco/intersight/playbooks/hcl_status.yml b/ansible_collections/cisco/intersight/playbooks/hcl_status.yml
index 7281c2595..ede236a3b 100644
--- a/ansible_collections/cisco/intersight/playbooks/hcl_status.yml
+++ b/ansible_collections/cisco/intersight/playbooks/hcl_status.yml
@@ -5,23 +5,23 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
- collections:
- - cisco.intersight
+- name: Get HCL status and write to file
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
gather_facts: false
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 }}"
+ # if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
+ # and INTERSIGHT_API_URI environment variables used for API key data
+ api_private_key: "{{ api_private_key | default(omit) }}"
+ api_key_id: "{{ api_key_id | default(omit) }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
- state: "{{ state | default(omit) }}"
tasks:
# Get HclStatus
- name: Get HCL Status for Server
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /cond/HclStatuses
query_params:
@@ -31,16 +31,22 @@
when:
- server_moid is defined
# Create .csv file with version and status information
- - copy:
- content: |
- Name, FW version, OS vendor, OS version, HW status, SW status, Overall Status
+ - name: Create .csv file with version and status information
+ ansible.builtin.copy:
+ content: 'Name, FW version, OS vendor, OS version, HW status, SW status, Overall Status
+
{% for host in hostvars %}
- {% set vars = hostvars[host|string] %}
+ {% set vars = hostvars[host | string] %}
{% if vars.hcl_resp.api_response is defined %}
- {{ vars.inventory_hostname }}, {{ vars.hcl_resp.api_response.HclFirmwareVersion }}, {{ vars.hcl_resp.api_response.HclOsVendor }}, {{ vars.hcl_resp.api_response.HclOsVersion }}, {{ vars.hcl_resp.api_response.HardwareStatus }}, {{ vars.hcl_resp.api_response.SoftwareStatus }}, {{ vars.hcl_resp.api_response.Status }} {{ vars.hcl_resp.api_response.ServerReason }}
+ {{ vars.inventory_hostname }}, {{ vars.hcl_resp.api_response.HclFirmwareVersion }}, {{ vars.hcl_resp.api_response.HclOsVendor }},
+ {{ vars.hcl_resp.api_response.HclOsVersion }}, {{ vars.hcl_resp.api_response.HardwareStatus }},
+ {{ vars.hcl_resp.api_response.SoftwareStatus }}, {{ vars.hcl_resp.api_response.Status }} {{ vars.hcl_resp.api_response.ServerReason }}
+
{% endif %}
{% endfor %}
+ '
dest: /tmp/hcl_status.csv
backup: false
+ mode: '0644'
run_once: true
delegate_to: localhost
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_bios_policy.yml b/ansible_collections/cisco/intersight/playbooks/intersight_bios_policy.yml
new file mode 100644
index 000000000..6eb7c812c
--- /dev/null
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_bios_policy.yml
@@ -0,0 +1,31 @@
+---
+# Example Playbook: cisco.intersight.intersight_bios_policy
+# Runs on localhost since policies are only configured once
+# Author: Surendra Ramarao (@CRSurendra)
+- name: Configure BIOS Policy
+ hosts: localhost
+ connection: local
+ gather_facts: false
+ vars:
+ # Create an anchor for api_info that can be used throughout the file
+ api_info: &api_info
+ # if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
+ # and INTERSIGHT_API_URI environment variables used for API key data
+ api_private_key: "{{ api_private_key | default(omit) }}"
+ api_key_id: "{{ api_key_id | default(omit) }}"
+ api_uri: "{{ api_uri | default(omit) }}"
+ validate_certs: "{{ validate_certs | default(omit) }}"
+ state: "{{ state | default('present') }}"
+ # Organization name
+ org_name: Cloudera-SZR-Org
+ tasks:
+ - name: Configure BIOS Policy
+ cisco.intersight.intersight_bios_policy:
+ <<: *api_info
+ organization: "{{ org_name }}"
+ name: SUR_BIOS
+ description: BIOS policy for lab use
+ tags:
+ - Key: Site
+ Value: RCDN
+ cpu_energy_performance: performance
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_boot_order_policy.yml b/ansible_collections/cisco/intersight/playbooks/intersight_boot_order_policy.yml
index d2d07af42..c235fee89 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_boot_order_policy.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_boot_order_policy.yml
@@ -2,10 +2,9 @@
# Example Playbook: cisco.intersight.intersight_boot_order_policy
# Runs on localhost since policies are only configured once
# Author: Tse Kai "Kevin" Chan (@BrightScale)
-- hosts: localhost
+- name: Configure Boot Order Policy
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -21,7 +20,7 @@
org_name: dsoper-DevNet
tasks:
- name: Configure Boot Order Policy
- intersight_boot_order_policy:
+ cisco.intersight.intersight_boot_order_policy:
<<: *api_info
organization: "{{ org_name }}"
name: COS-Boot
@@ -29,11 +28,13 @@
tags:
- Key: Site
Value: RCDN
- configured_boot_mode: Legacy
+ configured_boot_mode: Uefi
boot_devices:
- device_type: Local Disk
device_name: Boot-Lun
controller_slot: MRAID
+ - device_type: NVMe
+ device_name: NVMe
- device_type: Virtual Media
device_name: vmedia
- device_type: Local CDD
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_domain_profile.yml b/ansible_collections/cisco/intersight/playbooks/intersight_domain_profile.yml
index 205bc517f..f5a76f426 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_domain_profile.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_domain_profile.yml
@@ -2,10 +2,9 @@
#
# Configure UCS Domain Profiles
#
-- hosts: localhost
+- name: Configure UCS Domain Profiles
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -26,48 +25,48 @@
fib_sn: FDO23480DAL
tasks:
# Get the Organization Moid
- - name: "Get {{ org_name }} Organization Moid"
- intersight_rest_api:
+ - name: "Get Organization Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /organization/Organizations
query_params:
$filter: "Name eq '{{ org_name }}'"
register: org_resp
# Get the Port Policy
- - name: "Get {{ port_policy }} Port Policy Moid"
- intersight_rest_api:
+ - name: "Get Port Policy Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/PortPolicies
query_params:
$filter: "Name eq '{{ port_policy }}'"
register: port_resp
# Get the QoS Policy
- - name: "Get {{ qos_policy }} Qos Policy Moid"
- intersight_rest_api:
+ - name: "Get Qos Policy Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/SystemQosPolicies
query_params:
$filter: "Name eq '{{ qos_policy }}'"
register: qos_resp
# Get FI A Moid
- - name: "Get FI A {{ fia_sn }} Moid"
- intersight_rest_api:
+ - name: "Get FI A Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /network/Elements
query_params:
$filter: "Serial eq '{{ fia_sn }}'"
register: fia_resp
# Get FI B Moid
- - name: "Get FI B {{ fib_sn }} Moid"
- intersight_rest_api:
+ - name: "Get FI B Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /network/Elements
query_params:
$filter: "Serial eq '{{ fib_sn }}'"
register: fib_resp
# Config Domain (SwitchCluster) Profile
- - name: "Configure {{ profile_name }} Domain Profile"
- intersight_rest_api:
+ - name: "Configure Domain Profile"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
state: "{{ state | default('present') }}"
resource_path: /fabric/SwitchClusterProfiles
@@ -83,8 +82,8 @@
# Config Switch Profile A with Policy Bucket
# Command line arg -e profile_action=Unassign can be used to unassign the profile
# Command line arg -e profile_action=Deploy can be used to deploy the profile
- - name: "Configure {{ profile_name }}-A Switch Profile"
- intersight_rest_api:
+ - name: "Configure A Switch Profile"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/SwitchProfiles
query_params:
@@ -111,8 +110,8 @@
}
when: profile_resp.api_response is defined and profile_resp.api_response
# Config Switch Profile B with Policy Bucket
- - name: "Configure {{ profile_name }}-B Switch Profile"
- intersight_rest_api:
+ - name: "Configure B Switch Profile"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/SwitchProfiles
query_params:
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_eth_network.yml b/ansible_collections/cisco/intersight/playbooks/intersight_eth_network.yml
index 912048759..b50215c15 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_eth_network.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_eth_network.yml
@@ -2,10 +2,9 @@
#
# Get VLANs for each Ethernet Network Policy
#
-- hosts: localhost
+- name: Get VLANs for each Ethernet Network Policy
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -20,7 +19,7 @@
tasks:
# Get Ethernet Network Policies
- name: "Get Ethernet Network Policies"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/EthNetworkPolicies
query_params:
@@ -29,7 +28,7 @@
register: eth_net_resp
# Get the VLANs used by each Eth Policy
- name: "Get VLANs in each EthNetworkPolicy"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/Vlans
query_params:
@@ -41,15 +40,18 @@
label: "{{ item.Name }}"
register: vlan_resp
# Create file and write results
- - name: "Create {{ filename }} and write results"
- file:
+ - name: "Create file and write results"
+ ansible.builtin.file:
path: "{{ filename }}"
state: absent
- - lineinfile:
+ - name: Write headers to file
+ ansible.builtin.lineinfile:
path: "{{ filename }}"
line: EthNetworkPolicy,IsNative,VlanName,VlanId
create: true
- - include_tasks: vlans_to_file.yml
+ mode: '0644'
+ - name: Write results to file
+ ansible.builtin.include_tasks: vlans_to_file.yml
loop: "{{ vlan_resp.results }}"
loop_control:
loop_var: outer_item
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_imc_access_policy.yml b/ansible_collections/cisco/intersight/playbooks/intersight_imc_access_policy.yml
index 070d00278..51865c7bd 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_imc_access_policy.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_imc_access_policy.yml
@@ -1,21 +1,27 @@
---
# Example Playbook: cisco.intersight.intersight_..._policy
# Runs on localhost since policies are only configured once
-- hosts: localhost
+- name: Configure IMC Access policy
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
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 }}"
+ # if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
+ # and INTERSIGHT_API_URI environment variables used for API key data
+ api_private_key: "{{ api_private_key | default(omit) }}"
+ api_key_id: "{{ api_key_id | default(omit) }}"
api_uri: "{{ api_uri | default(omit) }}"
+ validate_certs: "{{ validate_certs | default(omit) }}"
+ state: "{{ state | default('present') }}"
+ # Organization name
+ org_name: dsoper-DevNet
tasks:
- name: Configure IMC Access policy
- intersight_imc_access_policy:
+ cisco.intersight.intersight_imc_access_policy:
<<: *api_info
+ organization: "{{ org_name }}"
name: "{{ imc_access_name | default('sjc02-d23-access') }}"
tags:
- Key: Site
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_lan_connectivity_policy.yml b/ansible_collections/cisco/intersight/playbooks/intersight_lan_connectivity_policy.yml
index 91c1446ee..8b990dcb4 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_lan_connectivity_policy.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_lan_connectivity_policy.yml
@@ -2,10 +2,9 @@
#
# Configure LAN Connectivity Policy
#
-- hosts: localhost
+- name: Configure LAN Connectivity Policy
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -27,56 +26,56 @@
org_name: dsoper-DevNet
tasks:
# Get the Organization Moid
- - name: "Get {{ org_name }} Organization Moid"
- intersight_rest_api:
+ - name: "Get Organization Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /organization/Organizations
query_params:
$filter: "Name eq '{{ org_name }}'"
register: org_resp
# Get the Ethernet Network Group Policy
- - name: "Get {{ eth_net_group }} Ethernet Network Group Policy Moid"
- intersight_rest_api:
+ - name: "Get Ethernet Network Group Policy Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/EthNetworkGroupPolicies
query_params:
$filter: "Name eq '{{ eth_net_group }}'"
register: eth_net_group_resp
# Get the Ethernet Network Control Policy
- - name: "Get {{ eth_net_control }} Ethernet Network Control Policy Moid"
- intersight_rest_api:
+ - name: "Get Ethernet Network Control Policy Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/EthNetworkControlPolicies
query_params:
$filter: "Name eq '{{ eth_net_control }}'"
register: eth_net_control_resp
# Get the Ethernet QoS Policy
- - name: "Get {{ eth_qos }} Ethernet QoS Policy Moid"
- intersight_rest_api:
+ - name: "Get Ethernet QoS Policy Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthQosPolicies
query_params:
$filter: "Name eq '{{ eth_qos }}'"
register: eth_qos_resp
# Get the Ethernet Network Group Policy
- - name: "Get {{ eth_adapter }} Ethernet Adapter Policy Moid"
- intersight_rest_api:
+ - name: "Get Ethernet Adapter Policy Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthAdapterPolicies
query_params:
$filter: "Name eq '{{ eth_adapter }}'"
register: eth_adapter_resp
# Get MAC Address Pool
- - name: "Get {{ mac_pool }} MAC Address Pool Moid"
- intersight_rest_api:
+ - name: "Get MAC Address Pool Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /macpool/Pools
query_params:
$filter: "Name eq '{{ mac_pool }}'"
register: mac_resp
# Config LAN Connectivity Policy
- - name: "Configure {{ lcp_name }} LAN Connectivity Policy"
- intersight_rest_api:
+ - name: "Configure LAN Connectivity Policy"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
state: "{{ state | default('present') }}"
resource_path: /vnic/LanConnectivityPolicies
@@ -92,8 +91,8 @@
}
register: lcp_resp
# Config vNIC with LAN Connectivity Policy
- - name: "Configure {{ vnic_name }} vNIC"
- intersight_rest_api:
+ - name: "Configure vNIC"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /vnic/EthIfs
query_params:
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_local_user_policy.yml b/ansible_collections/cisco/intersight/playbooks/intersight_local_user_policy.yml
index a387a95ce..a2c3c5df8 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_local_user_policy.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_local_user_policy.yml
@@ -1,10 +1,9 @@
---
# Example Playbook: cisco.intersight.intersight_..._policy
# Runs on localhost since policies are only configured once
-- hosts: localhost
+- name: Configure Local User policy
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -16,6 +15,8 @@
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
+ # Organization name
+ org_name: dsoper-DevNet
#
# Example using vault:
# 1. Place the vault password into a plain text file (this is the password for vault access - do not check this into any repos!)
@@ -37,8 +38,9 @@
3538
tasks:
- name: Configure Local User policy
- intersight_local_user_policy:
+ cisco.intersight.intersight_local_user_policy:
<<: *api_info
+ organization: "{{ org_name }}"
name: "{{ local_user_policy | default('guest-admin') }}"
tags:
- Key: username
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_ntp_policy.yml b/ansible_collections/cisco/intersight/playbooks/intersight_ntp_policy.yml
index 91abf725a..4c07896bb 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_ntp_policy.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_ntp_policy.yml
@@ -1,10 +1,9 @@
---
# Example Playbook: cisco.intersight.intersight_ntp_policy
# Runs on localhost since policies are only configured once
-- hosts: localhost
+- name: Configure NTP Policy
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -19,7 +18,7 @@
org_name: DCP-X-Sandbox
tasks:
- name: Configure NTP Policy
- intersight_ntp_policy:
+ cisco.intersight.intersight_ntp_policy:
<<: *api_info
organization: "{{ org_name }}"
name: lab-ntp
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_oob_imc_access_policy.yml b/ansible_collections/cisco/intersight/playbooks/intersight_oob_imc_access_policy.yml
new file mode 100644
index 000000000..7080c50d7
--- /dev/null
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_oob_imc_access_policy.yml
@@ -0,0 +1,31 @@
+---
+# Example Playbook: cisco.intersight.intersight_..._policy
+# Runs on localhost since policies are only configured once
+- name: Configure Out of Band IMC Access policy
+ hosts: localhost
+ connection: local
+ gather_facts: false
+ vars:
+ # Create an anchor for api_info that can be used throughout the file
+ api_info: &api_info
+ # if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
+ # and INTERSIGHT_API_URI environment variables used for API key data
+ api_private_key: "{{ api_private_key | default(omit) }}"
+ api_key_id: "{{ api_key_id | default(omit) }}"
+ api_uri: "{{ api_uri | default(omit) }}"
+ validate_certs: "{{ validate_certs | default(omit) }}"
+ state: "{{ state | default('present') }}"
+ # Organization name
+ org_name: Demo-DevNet
+ tasks:
+ - name: Configure Out of Band IMC Access policy
+ cisco.intersight.intersight_imc_access_policy:
+ <<: *api_info
+ organization: "{{ org_name }}"
+ name: "{{ imc_access_name | default('sjc07-imc-access') }}"
+ tags:
+ - Key: Site
+ Value: SJC07
+ description: Updated OOB IMC access for SJC labs
+ out_of_band: true
+ ip_pool: "{{ ip_pool | default('DevNet-SJC07-R14-IPPool') }}"
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_port_policy.yml b/ansible_collections/cisco/intersight/playbooks/intersight_port_policy.yml
index 83ba5a57a..b9fb8f5a8 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_port_policy.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_port_policy.yml
@@ -2,10 +2,9 @@
#
# Configure Fabric Port Policies
#
-- hosts: localhost
+- name: Configure Fabric Port Policies
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -21,16 +20,16 @@
org_name: dsoper-DevNet
tasks:
# Get the Organization Moid
- - name: "Get {{ org_name }} Organization Moid"
- intersight_rest_api:
+ - name: "Get Organization Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /organization/Organizations
query_params:
$filter: "Name eq '{{ org_name }}'"
register: org_resp
# Config Port Policy
- - name: "Configure {{ port_name }} Port Policy"
- intersight_rest_api:
+ - name: "Configure Port Policy"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
state: "{{ state | default('present') }}"
resource_path: /fabric/PortPolicies
@@ -46,7 +45,7 @@
register: port_resp
# Config Server Roles
- name: "Configure Server Roles"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/ServerRoles
query_params:
@@ -59,11 +58,11 @@
},
"SlotId": 1
}
- loop: "{{ range(1, 6+1) | list }}"
+ loop: "{{ range(1, 6 + 1) | list }}"
when: port_resp.api_response is defined and port_resp.api_response
# Config Uplink Port Channel Roles
- name: "Configure Uplink Port Channel Roles"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /fabric/UplinkPcRoles
query_params:
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_server_profile.yml b/ansible_collections/cisco/intersight/playbooks/intersight_server_profile.yml
index 27787344e..0fda01ef3 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_server_profile.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_server_profile.yml
@@ -7,10 +7,9 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
+- name: Configure Server Profiles
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -28,24 +27,41 @@
#
# Configure profiles specific to server (run for each server in the inventory)
#
- - set_fact:
+ - name: Set management mode to Standalone
+ ansible.builtin.set_fact:
mode: Standalone
when: mode is not defined or mode == 'IntersightStandalone'
- - set_fact:
+ - name: Set management mode to FIAttached
+ ansible.builtin.set_fact:
mode: FIAttached
when: mode == 'Intersight'
- - name: "Configure {{ profile_name }} Server Profile"
- intersight_server_profile:
+ - name: "Configure Server Profile"
+ cisco.intersight.intersight_server_profile:
<<: *api_info
organization: "{{ organization | default(omit) }}"
name: "{{ profile_name }}"
target_platform: "{{ mode | default(omit) }}"
description: "Updated Profile for server name {{ inventory_hostname }}"
+ tags:
+ - Key: Site
+ Value: RCDN
assigned_server: "{{ server_moid | default(omit) }}"
+ bios_policy: "{{ bios_policy | default(omit) }}"
boot_order_policy: "{{ boot_order_policy | default(omit) }}"
+ certificate_policy: "{{ certificate_policy | default(omit) }}"
+ drive_security_policy: "{{ drive_security_policy | default(omit) }}"
+ firmware_policy: "{{ firmware_policy | default(omit) }}"
imc_access_policy: "{{ imc_access_policy | default(omit) }}"
+ ipmi_over_lan_policy: "{{ ipmi_over_lan_policy | default(omit) }}"
lan_connectivity_policy: "{{ lan_connectivity_policy | default(omit) }}"
local_user_policy: "{{ local_user_policy | default(omit) }}"
ntp_policy: "{{ ntp_policy | default(omit) }}"
+ san_connectivity_policy: "{{ san_connectivity_policy | default(omit) }}"
+ serial_over_lan_policy: "{{ serial_over_lan_policy | default(omit) }}"
+ snmp_policy: "{{ snmp_policy | default(omit) }}"
+ storage_policy: "{{ storage_policy | default(omit) }}"
+ syslog_policy: "{{ syslog_policy | default(omit) }}"
+ thermal_policy: "{{ thermal_policy | default(omit) }}"
+ virtual_kvm_policy: "{{ virtual_kvm_policy | default(omit) }}"
virtual_media_policy: "{{ virtual_media_policy | default(omit) }}"
delegate_to: localhost
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_server_profile_template.yml b/ansible_collections/cisco/intersight/playbooks/intersight_server_profile_template.yml
index b64d60d40..49e2d15d9 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_server_profile_template.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_server_profile_template.yml
@@ -2,10 +2,9 @@
#
# Configure Server Profile Templates
#
-- hosts: localhost
+- name: "Configure Server Profile Template"
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -26,40 +25,40 @@
num_profiles: 3
tasks:
# Get the Organization Moid
- - name: "Get {{ org_name }} Organization Moid"
- intersight_rest_api:
+ - name: "Get Organization Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /organization/Organizations
query_params:
$filter: "Name eq '{{ org_name }}'"
register: org_resp
# Get the Access Policy
- - name: "Get {{ imc_access_policy }} Access Policy Moid"
- intersight_rest_api:
+ - name: "Get Access Policy Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /access/Policies
query_params:
$filter: "Name eq '{{ imc_access_policy }}'"
register: access_resp
# Get the NTP Policy
- - name: "Get {{ ntp_policy }} NTP Policy Moid"
- intersight_rest_api:
+ - name: "Get NTP Policy Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /ntp/Policies
query_params:
$filter: "Name eq '{{ ntp_policy }}'"
register: ntp_resp
# Get the UUID Pool
- - name: "Get {{ uuid_pool }} UUID Pool Moid"
- intersight_rest_api:
+ - name: "Get UUID Pool Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /uuidpool/Pools
query_params:
$filter: "Name eq '{{ uuid_pool }}'"
register: uuid_resp
# Config SP Template using Policy Buckets
- - name: "Configure {{ template_name }} Server Profile Template"
- intersight_rest_api:
+ - name: "Configure Server Profile Template"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /server/ProfileTemplates
query_params:
@@ -89,6 +88,6 @@
}
register: template_resp
# Derive profiles from template (if profiles don't already exist)
- - name: "Derive Profiles from {{ template_name}}"
- include_tasks: derive_profiles.yml
- loop: "{{ range(1, num_profiles+1) | list }}"
+ - name: "Derive Profiles from {{ template_name }}"
+ ansible.builtin.include_tasks: derive_profiles.yml
+ loop: "{{ range(1, num_profiles + 1) | list }}"
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_virtual_media_policy.yml b/ansible_collections/cisco/intersight/playbooks/intersight_virtual_media_policy.yml
index 7064a06d0..e75ff9591 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_virtual_media_policy.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_virtual_media_policy.yml
@@ -1,22 +1,27 @@
---
# Example Playbook: cisco.intersight.intersight_virtual_media_policy
# Runs on localhost since policies are only configured once
-- hosts: localhost
+- name: Configure Virtual Media Policy
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
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 }}"
+ # if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
+ # and INTERSIGHT_API_URI environment variables used for API key data
+ api_private_key: "{{ api_private_key | default(omit) }}"
+ api_key_id: "{{ api_key_id | default(omit) }}"
api_uri: "{{ api_uri | default(omit) }}"
+ validate_certs: "{{ validate_certs | default(omit) }}"
+ state: "{{ state | default('present') }}"
+ # Organization name
+ org_name: dsoper-DevNet
tasks:
- name: Configure Virtual Media Policy
- intersight_virtual_media_policy:
+ cisco.intersight.intersight_virtual_media_policy:
<<: *api_info
- organization: DevNet
+ organization: "{{ org_name }}"
name: COS-VM
description: Virtual Media policy for lab use
tags:
diff --git a/ansible_collections/cisco/intersight/playbooks/intersight_vm_hosts.yml b/ansible_collections/cisco/intersight/playbooks/intersight_vm_hosts.yml
index 21e019b21..8bc35c14b 100644
--- a/ansible_collections/cisco/intersight/playbooks/intersight_vm_hosts.yml
+++ b/ansible_collections/cisco/intersight/playbooks/intersight_vm_hosts.yml
@@ -2,10 +2,9 @@
#
# Get VM hosts and write information to a .csv file
#
-- hosts: localhost
+- name: Get VM hosts and write information to a .csv file
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -20,7 +19,7 @@
tasks:
# Get the VM hosts
- name: "Get VM Hosts"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /virtualization/VirtualMachines
query_params:
@@ -30,18 +29,24 @@
return_list: true
register: vm_resp
# Create file and write results
- - name: "Create {{ filename }} and write results"
- file:
+ - name: "Create and write results"
+ ansible.builtin.file:
path: "{{ filename }}"
state: absent
- - lineinfile:
+ mode: '0644'
+ - name: Write headers to file
+ ansible.builtin.lineinfile:
path: "{{ filename }}"
line: VM,Hypervisor,Model,Hostname,Serial
create: true
+ mode: '0644'
# Only write VMs that have Host information to the .csv file
- - lineinfile:
+ - name: Write VM info to file
+ ansible.builtin.lineinfile:
path: "{{ filename }}"
- line: "{{ item.Name }},{{ item.Inventory.Host.HypervisorType }},{{ item.Inventory.Host.Model }},{{ item.Inventory.Host.Name }},{{ item.Inventory.Host.Serial }}"
+ line: >-
+ {{ item.Name }},{{ item.Inventory.Host.HypervisorType }},{{ item.Inventory.Host.Model }},{{ item.Inventory.Host.Name }},
+ {{ item.Inventory.Host.Serial }}
loop: "{{ vm_resp.api_response }}"
loop_control:
label: "{{ item.Name }}"
diff --git a/ansible_collections/cisco/intersight/playbooks/only_new_server_profiles.yml b/ansible_collections/cisco/intersight/playbooks/only_new_server_profiles.yml
index e3b0d1d8a..ce07f93f0 100644
--- a/ansible_collections/cisco/intersight/playbooks/only_new_server_profiles.yml
+++ b/ansible_collections/cisco/intersight/playbooks/only_new_server_profiles.yml
@@ -7,10 +7,9 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
+- name: Configure server profiles without assignment
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -32,25 +31,29 @@
#
# Configure profiles specific to server (run for each server in the inventory)
#
- - set_fact:
+ - name: Set Standalone Management Mode
+ ansible.builtin.set_fact:
mode: Standalone
when: mode is not defined or mode == 'IntersightStandalone'
- - set_fact:
+ - name: Set FIAttached Management Mode
+ ansible.builtin.set_fact:
mode: FIAttached
when: mode == 'Intersight'
# Get server moid when not defined in inventory
- - block:
- - name: "Get {{ inventory_hostname }} Server Moid"
- intersight_info:
+ - name: Get server moid
+ when: server_moid is not defined
+ delegate_to: localhost
+ block:
+ - name: "Get Server Moid"
+ cisco.intersight.intersight_info:
<<: *api_info
server_names: "{{ inventory_hostname }}"
register: server
- - set_fact:
+ - name: Set server moid
+ ansible.builtin.set_fact:
server_moid: "{{ server.intersight_servers[0].Moid }}"
- when: server_moid is not defined
- delegate_to: localhost
- name: "Get current profile assignment"
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /server/Profiles
query_params:
@@ -58,8 +61,8 @@
when: server_moid is defined
register: profile
delegate_to: localhost
- - name: "Configure {{ profile_name }} Server Profile"
- intersight_server_profile:
+ - name: "Configure Server Profile"
+ cisco.intersight.intersight_server_profile:
<<: *api_info
organization: "{{ organization | default(omit) }}"
name: "{{ profile_name }}"
diff --git a/ansible_collections/cisco/intersight/playbooks/os_install.yml b/ansible_collections/cisco/intersight/playbooks/os_install.yml
index b151a98cf..c50323505 100644
--- a/ansible_collections/cisco/intersight/playbooks/os_install.yml
+++ b/ansible_collections/cisco/intersight/playbooks/os_install.yml
@@ -5,10 +5,9 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
+- name: Install OS
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -22,7 +21,7 @@
# OS and SCU Versions
os_version: ESXi 7.0 U3
os_config: ESXi7.0ConfigFile
- scu_version: 6.2.2a
+ scu_version: 6.2.3b
org_name: default
#
# Example using vault:
@@ -45,8 +44,8 @@
3538
tasks:
# Get the Organization Moid
- - name: "Get {{ org_name }} Organization Moid"
- intersight_rest_api:
+ - name: "Get Organization Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /organization/Organizations
query_params:
@@ -54,8 +53,8 @@
register: org_resp
delegate_to: localhost
# Get the OS File Moid
- - name: "Get {{ os_version }} OS File Moid"
- intersight_rest_api:
+ - name: "Get OS File Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /softwarerepository/OperatingSystemFiles
query_params:
@@ -63,8 +62,8 @@
register: os_resp
delegate_to: localhost
# Get the SCU File Moid
- - name: "Get {{ scu_version }} SCU File Moid"
- intersight_rest_api:
+ - name: "Get SCU File Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /firmware/ServerConfigurationUtilityDistributables
query_params:
@@ -72,8 +71,8 @@
register: scu_resp
delegate_to: localhost
# Get the OS Config File Moid
- - name: "Get {{ os_config }} OS Config File Moid"
- intersight_rest_api:
+ - name: "Get OS Config File Moid"
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /os/ConfigurationFiles
query_params:
@@ -82,7 +81,7 @@
delegate_to: localhost
# Install OS
- name: Install OS
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /bulk/Requests
update_method: post
@@ -107,14 +106,20 @@
"Moid": "{{ org_resp.api_response.Moid }}"
},
"Answers": {
- "Hostname": "sjc07-r14-1-1-6",
- "IpConfigType": "DHCP",
- "RootPassword": "{{ vault_password }}",
- "IsRootPasswordCrypted": false,
- "Source": "Template",
+ "Hostname": "localhost",
+ "IpConfigType": "static",
"IpConfiguration": {
+ "IpV4Config": {
+ "Gateway": "172.22.248.1",
+ "IpAddress": "172.22.248.230",
+ "Netmask": "255.255.252.0"
+ },
"ObjectType": "os.Ipv4Configuration"
- }
+ },
+ "IsRootPasswordCrypted": false,
+ "Nameserver": "170.70.168.183",
+ "RootPassword": "{{ vault_password }}",
+ "Source": "Template"
},
"ConfigurationFile": {
"Moid": "{{ os_config_resp.api_response.Moid }}",
@@ -122,10 +127,10 @@
},
"AdditionalParameters": null,
"InstallTarget": {
- "ObjectType": "os.PhysicalDisk",
- "Name": "Disk 1",
- "StorageControllerSlotId": "1",
- "SerialNumber": "99B0A05NFJXF"
+ "Id": "0",
+ "Name": "DevNet-RAID1",
+ "ObjectType": "os.VirtualDrive",
+ "StorageControllerSlotId": "1"
},
"Server": {
"ObjectType": "compute.{{ object_type }}",
diff --git a/ansible_collections/cisco/intersight/playbooks/ova_workflow.yml b/ansible_collections/cisco/intersight/playbooks/ova_workflow.yml
index 3f4eea66d..6a2165481 100644
--- a/ansible_collections/cisco/intersight/playbooks/ova_workflow.yml
+++ b/ansible_collections/cisco/intersight/playbooks/ova_workflow.yml
@@ -1,8 +1,7 @@
---
# Execute Orchestration Workflow
-- hosts: localhost
- collections:
- - cisco.intersight
+- name: Execute orchestration workflow
+ hosts: localhost
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -13,14 +12,14 @@
vm_name: "{{ vm_name | default('ucspe-4-0-4e-orch') }}"
tasks:
- name: Get vCenter Moid
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /asset/DeviceRegistrations
query_params:
$filter: DeviceIpAddress eq '172.28.225.220'
register: vcenter
- name: Execute OVA deploy workflow
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /workflow/WorkflowInfos
update_method: post
@@ -57,7 +56,7 @@
}
register: workflow
- name: Get status of OVA deploy workflow
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /workflow/WorkflowInfos
query_params:
@@ -68,5 +67,6 @@
retries: 10
delay: 60
ignore_errors: true
- - debug:
+ - name: Print final workflow status
+ ansible.builtin.debug:
msg: "Final workflow status: {{ status.api_response.Status }}"
diff --git a/ansible_collections/cisco/intersight/playbooks/profile_with_buckets.yml b/ansible_collections/cisco/intersight/playbooks/profile_with_buckets.yml
index 4fde5991e..37aa66619 100644
--- a/ansible_collections/cisco/intersight/playbooks/profile_with_buckets.yml
+++ b/ansible_collections/cisco/intersight/playbooks/profile_with_buckets.yml
@@ -1,6 +1,7 @@
---
# Server profile config using policy buckets
-- hosts: localhost
+- name: Server profile config using policy buckets
+ hosts: localhost
gather_facts: false
vars:
profile_name: SP-SJC07-R14-FI-1-1-6
@@ -11,7 +12,8 @@
query_params:
$filter: "Name eq '{{ profile_name }}'"
register: results
- - debug:
+ - name: Print policy bucket info
+ ansible.builtin.debug:
msg: "{{ results.api_response.PolicyBucket | selectattr('ObjectType', 'eq', 'access.Policy') }}"
- name: "Config {{ profile_name }}"
cisco.intersight.intersight_rest_api:
diff --git a/ansible_collections/cisco/intersight/playbooks/pxe_boot.yml b/ansible_collections/cisco/intersight/playbooks/pxe_boot.yml
index d60874f42..1303f91a2 100644
--- a/ansible_collections/cisco/intersight/playbooks/pxe_boot.yml
+++ b/ansible_collections/cisco/intersight/playbooks/pxe_boot.yml
@@ -2,10 +2,9 @@
# Example Playbook: cisco.intersight.intersight_boot_order_policy
# Runs on localhost since policies are only configured once
# Author: Tse Kai "Kevin" Chan (@BrightScale)
-- hosts: localhost
+- name: Example PXE boot policy
+ hosts: localhost
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -21,7 +20,7 @@
org_name: dsoper-DevNet
tasks:
- name: Configure Boot Order Policy with PXE
- intersight_boot_order_policy:
+ cisco.intersight.intersight_boot_order_policy:
<<: *api_info
organization: "{{ org_name }}"
name: PXE-Boot
diff --git a/ansible_collections/cisco/intersight/playbooks/roles/policies/server_policies/tasks/main.yml b/ansible_collections/cisco/intersight/playbooks/roles/policies/server_policies/tasks/main.yml
index 427b45d57..7867ca6bd 100644
--- a/ansible_collections/cisco/intersight/playbooks/roles/policies/server_policies/tasks/main.yml
+++ b/ansible_collections/cisco/intersight/playbooks/roles/policies/server_policies/tasks/main.yml
@@ -1,5 +1,5 @@
---
-- name: "Configure {{ api_body.Name }} Server Policy"
+- name: "Configure Server Policy"
vars:
# Create an anchor for api_info that can be used throughout the file
api_info: &api_info
@@ -16,14 +16,22 @@
api_body: "{{ api_body }}"
register: policy_resp
# Append profile_resp list to policy
-- block:
+- name: "Append Profile list to Policy"
+ # 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
+ block:
# Create a list of all host's profile Moids
- - set_fact:
+ - name: "Create list of profile Moids"
+ ansible.builtin.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)"
+ - name: "Update Server Profiles used by Server Policy (change may always be reported)"
cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: "{{ resource_path }}"
@@ -32,9 +40,3 @@
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
diff --git a/ansible_collections/cisco/intersight/playbooks/server_firmware.yml b/ansible_collections/cisco/intersight/playbooks/server_firmware.yml
index 6888fa781..f07bcb3e2 100644
--- a/ansible_collections/cisco/intersight/playbooks/server_firmware.yml
+++ b/ansible_collections/cisco/intersight/playbooks/server_firmware.yml
@@ -5,7 +5,8 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
+- name: Update server firmware
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
gather_facts: false
vars:
@@ -20,14 +21,16 @@
file_share: 172.28.224.77/mnt/SHARE/ISOS/HUU
tasks:
# Edit FW to be used as needed for server type below
- - set_fact:
- file_name: "ucs-c220m4-huu-{{ fw_version | replace('(','.') | replace(')','') }}.iso"
+ - name: Set file name
+ ansible.builtin.set_fact:
+ file_name: "ucs-c220m4-huu-{{ fw_version | replace('(', '.') | replace(')', '') }}.iso"
supported_models:
- UCSC-C220-M4L
- UCSC-C220-M4S
when: model is search("UCSC-C220-M4.*")
- - set_fact:
- file_name: "ucs-c240m4-huu-{{ fw_version | replace('(','.') | replace(')','') }}.iso"
+ - name: Set file name
+ ansible.builtin.set_fact:
+ file_name: "ucs-c240m4-huu-{{ fw_version | replace('(', '.') | replace(')', '') }}.iso"
supported_models:
- UCSC-C240-M4L
- UCSC-C240-M4S
@@ -35,8 +38,9 @@
- UCSC-C240-M4SNEBS
- UCSC-C240-M4S2
when: model is search("UCSC-C240-M4.*")
- - set_fact:
- file_name: "ucs-c240m5-huu-{{ fw_version | replace('(','.') | replace(')','') }}.iso"
+ - name: Set file name
+ ansible.builtin.set_fact:
+ file_name: "ucs-c240m5-huu-{{ fw_version | replace('(', '.') | replace(')', '') }}.iso"
supported_models:
- UCSC-C240-M5S
- UCSC-C240-M5L
@@ -49,8 +53,9 @@
- HX240C-M5SD
- HXAF240C-M5SD
when: model is search("UCSC-C240-M5.*")
- - set_fact:
- file_name: "ucs-c220m5-huu-{{ fw_version | replace('(','.') | replace(')','') }}.iso"
+ - name: Set file name
+ ansible.builtin.set_fact:
+ file_name: "ucs-c220m5-huu-{{ fw_version | replace('(', '.') | replace(')', '') }}.iso"
supported_models:
- UCSC-C220-M5SX
- UCSC-C220-M5L
@@ -58,15 +63,17 @@
- HX220C-M5SX
- HXAF220C-M5SX
when: model is search("UCSC-C220-M5.*")
- - set_fact:
+ - name: Set file location
+ ansible.builtin.set_fact:
file_location: "{{ file_share }}/{{ file_name }}"
# Set the distributable type based on the management mode and server type
- - set_fact:
+ - name: Set firmware distributable type
+ ansible.builtin.set_fact:
dist_type: STANDALONE
when: mode == 'Intersight' or mode == 'IntersightStandalone'
# Get a user defined FW version
- name: Get Moid of user defined FW version
- intersight_rest_api:
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /firmware/Distributables
query_params:
diff --git a/ansible_collections/cisco/intersight/playbooks/update_all_inventory.yml b/ansible_collections/cisco/intersight/playbooks/update_all_inventory.yml
index f2b59349e..d10f58ba0 100644
--- a/ansible_collections/cisco/intersight/playbooks/update_all_inventory.yml
+++ b/ansible_collections/cisco/intersight/playbooks/update_all_inventory.yml
@@ -9,7 +9,8 @@
#
# This playbook only runs once (and not for each server in the inventory), but the hosts group is used to get API key info
#
-- hosts: "{{ group | default('Intersight') }}"
+- name: Auto generate (or update) the Ansible inventory file with all servers
+ hosts: "{{ group | default('Intersight') }}"
connection: local
gather_facts: false
vars:
@@ -18,7 +19,7 @@
# if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
# and INTERSIGHT_API_URI environment variables used for API key data
api_private_key: "{{ api_private_key | default(omit) }}"
- api_key_id: "{{ api_key_id | default(omit) }}"
+ api_key_id: "{{ api_key_id | default(omit) }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
@@ -28,30 +29,39 @@
host_group: Intersight_Servers
tasks:
# Enclose tasks in a block that is only run once
- - block:
+ - name: Get servers and place in inventory file
+ delegate_to: localhost
+ run_once: true
+ block:
# Find all servers
- - cisco.intersight.intersight_info:
+ - name: Get all servers
+ cisco.intersight.intersight_info:
<<: *api_info
server_names:
register: all_results
# Place the servers in a group in the file
- - debug:
+ - name: Print inventory filepath
+ ansible.builtin.debug:
msg: Inventory filepath "{{ filepath }}"
- - lineinfile:
+ - name: Add host group to file
+ ansible.builtin.lineinfile:
path: "{{ filepath }}"
line: "[{{ host_group }}]"
+ mode: '0644'
create: true
# Update servers in the file
- - lineinfile:
+ - name: Update servers in the file
+ ansible.builtin.lineinfile:
path: "{{ filepath }}"
insertafter: "^\\[{{ host_group }}\\]"
regexp: "^{{ item.Name }} serial={{ item.Serial }} "
# Each line of the inventory has the following:
- line: "{{ item.Name }} serial={{ item.Serial }} server_moid={{ item.Moid }} model={{ item.Model }} mode={{ item.ManagementMode }} object_type={{ item.SourceObjectType | regex_replace('compute.')}}"
+ line: >-
+ {{ item.Name }} serial={{ item.Serial }} server_moid={{ item.Moid }} model={{ item.Model }} mode={{ item.ManagementMode }}
+ object_type={{ item.SourceObjectType | regex_replace('compute.') }}
+ mode: '0644'
create: true
loop: "{{ all_results.intersight_servers }}"
loop_control:
label: "{{ item.Name }}"
when: all_results.intersight_servers is defined
- delegate_to: localhost
- run_once: true
diff --git a/ansible_collections/cisco/intersight/playbooks/update_standalone_inventory.yml b/ansible_collections/cisco/intersight/playbooks/update_standalone_inventory.yml
index bd0bc166e..68e5133eb 100644
--- a/ansible_collections/cisco/intersight/playbooks/update_standalone_inventory.yml
+++ b/ansible_collections/cisco/intersight/playbooks/update_standalone_inventory.yml
@@ -9,7 +9,8 @@
#
# This playbook only runs once (and not for each server in the inventory), but the hosts group is used to get API key info
#
-- hosts: "{{ group | default('Intersight') }}"
+- name: Auto generate (or update) the Ansible inventory file with Standalone C-Series servers
+ hosts: "{{ group | default('Intersight') }}"
connection: local
gather_facts: false
vars:
@@ -18,7 +19,7 @@
# if api_key vars are omitted, INTERSIGHT_API_KEY_ID, INTERSIGHT_API_PRIVATE_KEY,
# and INTERSIGHT_API_URI environment variables used for API key data
api_private_key: "{{ api_private_key | default(omit) }}"
- api_key_id: "{{ api_key_id | default(omit) }}"
+ api_key_id: "{{ api_key_id | default(omit) }}"
api_uri: "{{ api_uri | default(omit) }}"
validate_certs: "{{ validate_certs | default(omit) }}"
state: "{{ state | default(omit) }}"
@@ -32,15 +33,20 @@
host_group: Intersight_Servers
tasks:
# Enclose tasks in a block that is only run once
- - block:
+ - name: Get servers and add to inventory file
+ delegate_to: localhost
+ run_once: true
+ block:
# Set an api response for the 1st loop iteration
- - set_fact:
+ - name: Set api_response
+ ansible.builtin.set_fact:
servers:
api_response:
- Moid: fake
run_once: true
# Find all servers
- - cisco.intersight.intersight_rest_api:
+ - name: Get servers
+ cisco.intersight.intersight_rest_api:
<<: *api_info
resource_path: /compute/PhysicalSummaries
query_params:
@@ -49,19 +55,21 @@
$top: "{{ per_page }}"
$skip: "{{ item }}"
return_list: true
- loop: "{{ range(0, max_servers|int, per_page|int) | list }}"
+ loop: "{{ range(0, max_servers | int, per_page | int) | list }}"
register: servers
when: servers.api_response
# Place the servers in a group in the file
- - debug:
+ - name: Print inventory filename
+ ansible.builtin.debug:
msg: Inventory filepath "{{ filepath }}"
- - lineinfile:
+ - name: Add host_group to file
+ ansible.builtin.lineinfile:
path: "{{ filepath }}"
line: "[{{ host_group }}]"
+ mode: '0644'
create: true
- - include_tasks: servers_to_file.yml
+ - name: Write servers to file
+ ansible.builtin.include_tasks: servers_to_file.yml
loop: "{{ servers.results }}"
loop_control:
loop_var: outer_item
- delegate_to: localhost
- run_once: true
diff --git a/ansible_collections/cisco/intersight/playbooks/vault_intersight_server_profile.yml b/ansible_collections/cisco/intersight/playbooks/vault_intersight_server_profile.yml
index 7a9fd5557..f6f3539d7 100644
--- a/ansible_collections/cisco/intersight/playbooks/vault_intersight_server_profile.yml
+++ b/ansible_collections/cisco/intersight/playbooks/vault_intersight_server_profile.yml
@@ -7,10 +7,9 @@
# ansible-playbook ... -e group=<your host group>
# e.g., ansible-playbook server_profiles.yml -e group=TME_Demo
#
-- hosts: "{{ group | default('Intersight_Servers') }}"
+- name: Configure profiles specific to server (run for each server in the inventory)
+ hosts: "{{ group | default('Intersight_Servers') }}"
connection: local
- collections:
- - cisco.intersight
gather_facts: false
vars:
# Create an anchor for api_info that can be used throughout the file
@@ -50,25 +49,30 @@
#
# Configure profiles specific to server (run for each server in the inventory)
#
- - set_fact:
+ # Set mode to Standalone if not defined or set to IntersightStandalone
+ - name: Set Management Mode to Standalone or FIAttached
+ ansible.builtin.set_fact:
mode: Standalone
when: mode is not defined or mode == 'IntersightStandalone'
- - set_fact:
+ - name: Set Management Mode to Standalone or FIAttached
+ ansible.builtin.set_fact:
mode: FIAttached
when: mode == 'Intersight'
# Get server moid when not defined in inventory
- - block:
- - name: "Get {{ inventory_hostname }} Server Moid"
+ - name: Get server moid when not defined in inventory
+ when: server_moid is not defined
+ delegate_to: localhost
+ block:
+ - name: "Get Server Moid"
cisco.intersight.intersight_info:
<<: *api_info
server_names: "{{ inventory_hostname }}"
register: server
- - set_fact:
+ - name: "Set Server Moid"
+ ansible.builtin.set_fact:
server_moid: "{{ server.intersight_servers[0].Moid }}"
- when: server_moid is not defined
- delegate_to: localhost
- - name: "Configure {{ profile_name }} Server Profile"
- intersight_server_profile:
+ - name: "Configure Server Profile"
+ cisco.intersight.intersight_server_profile:
<<: *api_info
organization: "{{ organization | default(omit) }}"
name: "{{ profile_name }}"