diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:03:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:03:42 +0000 |
commit | 66cec45960ce1d9c794e9399de15c138acb18aed (patch) | |
tree | 59cd19d69e9d56b7989b080da7c20ef1a3fe2a5a /ansible_collections/dellemc/openmanage/playbooks/ome/template | |
parent | Initial commit. (diff) | |
download | ansible-66cec45960ce1d9c794e9399de15c138acb18aed.tar.xz ansible-66cec45960ce1d9c794e9399de15c138acb18aed.zip |
Adding upstream version 7.3.0+dfsg.upstream/7.3.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/dellemc/openmanage/playbooks/ome/template')
7 files changed, 687 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template.yml b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template.yml new file mode 100644 index 00000000..58ac15ff --- /dev/null +++ b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template.yml @@ -0,0 +1,338 @@ +--- +- hosts: ome + connection: local + name: Dell OpenManage Ansible device Template service. + gather_facts: False + + collections: + - dellemc.openmanage + + tasks: + - name: "Create a template from a reference device." + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + device_id: 25123 + attributes: + Name: "New Template" + Description: "New Template description" + + - name: "Modify template name, description, and attribute value." + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "modify" + template_id: 12 + attributes: + Name: "New Custom Template" + Description: "Custom Template Description" + # Attributes to be modified in the template. + # For information on any attribute id, use API /TemplateService/Templates(Id)/Views(Id)/AttributeViewDetails + # This section is optional + Attributes: + - Id: 1234 + Value: "Test Attribute" + IsIgnored: false + + - name: Modify template name, description, and attribute using detailed view + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "modify" + template_id: 12 + attributes: + Name: "New Custom Template" + Description: "Custom Template Description" + Attributes: + # Enter the comma separated string as appearing in the Detailed view on GUI + # NIC -> NIC.Integrated.1-1-1 -> NIC Configuration -> Wake On LAN1 + - DisplayName: 'NIC, NIC.Integrated.1-1-1, NIC Configuration, Wake On LAN' + Value: Enabled + IsIgnored: false + # System -> LCD Configuration -> LCD 1 User Defined String for LCD + - DisplayName: 'System, LCD Configuration, LCD 1 User Defined String for LCD' + Value: LCD str by OMAM + IsIgnored: false + + - name: "Deploy template on multiple devices " + ome_template: + hostname: "192.168.0.1" + username: "username" + password: "password" + ca_path: "/path/to/ca_cert.pem" + command: "deploy" + template_id: 12 + device_id: + - 12765 + - 10173 + device_service_tag: + - 'SVTG123' + - 'SVTG456' + + - name: Deploy template on groups + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "deploy" + template_id: 12 + device_group_names: + - server_group_1 + - server_group_2 + + - name: "Deploy template on multiple devices along attributes modification for target device" + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "deploy" + template_id: 12 + device_id: + - 12765 + - 10173 + device_service_tag: + - 'SVTG123' + attributes: + # Device specific attributes to be modified during deployment. + # For information on any attribute id, use API /TemplateService/Templates(Id)/Views(Id)/AttributeViewDetails + # This section is optional + Attributes: + # specific device where attribute to be modified at deployment run-time. + # The DeviceId should be mentioned above in the 'device_id' section. + # Service tags not allowed. + - DeviceId: 12765 + Attributes: + - Id: 15645 + Value: "0.0.0.0" + IsIgnored: false + - DeviceId: 10173 + Attributes: + - Id: 18968, + Value: "hostname-1" + IsIgnored: false + + - name: "Deploy template and Operating System (OS) on multiple devices" + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "deploy" + template_id: 12 + device_id: + - 12765 + device_service_tag: + - 'SVTG123' + attributes: + # Include this to install OS on the devices. + # This section is optional + NetworkBootIsoModel: + BootToNetwork: true + ShareType: "NFS" + IsoTimeout: 1 # allowable values(1,2,4,8,16) in hours + IsoPath: "/home/iso_path/filename.iso" + ShareDetail: + IpAddress: "192.168.0.2" + ShareName: "sharename" + User: "share_user" + Password: "share_password" + Options: + EndHostPowerState: 1 + ShutdownType: 0 + TimeToWaitBeforeShutdown: 300 + Schedule: + RunLater: true + RunNow: false + + - name: "Deploy template on multiple devices and changes the device-level attributes. After the template is deployed, + install OS using its image." + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "deploy" + template_id: 12 + device_id: + - 12765 + - 10173 + device_service_tag: + - 'SVTG123' + - 'SVTG456' + attributes: + Attributes: + - DeviceId: 12765 + Attributes: + - Id: 15645 + Value: "0.0.0.0" + IsIgnored: false + - DeviceId: 10173 + Attributes: + - Id: 18968, + Value: "hostname-1" + IsIgnored: false + NetworkBootIsoModel: + BootToNetwork: true + ShareType: "NFS" + IsoTimeout: 1 # allowable values(1,2,4,8,16) in hours + IsoPath: "/home/iso_path/filename.iso" + ShareDetail: + IpAddress: "192.168.0.2" + ShareName: "sharename" + User: "share_user" + Password: "share_password" + Options: + EndHostPowerState: 1 + ShutdownType: 0 + TimeToWaitBeforeShutdown: 300 + Schedule: + RunLater: true + RunNow: false + + - name: "delete template" + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "delete" + template_id: 12 + + - name: "export a template" + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "export" + template_id: 12 + + # Start of example to export template to a local xml file + - name: "export template to a local xml file" + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "export" + template_name: "my_template" + register: result + tags: + - export_xml_to_file + - ansible.builtin.copy: + content: "{{ result.Content}}" + dest: "/path/to/exported_template.xml" + tags: + - export_xml_to_file + # End of example to export template to a local xml file + + - name: "clone a template" + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "clone" + template_id: 12 + attributes: + Name: "New Cloned Template Name" + + - name: "import template from XML content" + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "import" + attributes: + Name: "Imported Template Name" + # Template Type from TemplateService/TemplateTypes + Type: 2 + # xml string content + Content: "<SystemConfiguration Model=\"PowerEdge R940\" ServiceTag=\"SVCTAG1\" + TimeStamp=\"Tue Sep 24 09:20:57.872551 2019\">\n<Component FQDD=\"AHCI.Slot.6-1\">\n<Attribute + Name=\"RAIDresetConfig\">True</Attribute>\n<Attribute Name=\"RAIDforeignConfig\">Clear</Attribute>\n + </Component>\n<Component FQDD=\"Disk.Direct.0-0:AHCI.Slot.6-1\">\n<Attribute Name=\"RAIDPDState\">Ready + </Attribute>\n<Attribute Name=\"RAIDHotSpareStatus\">No</Attribute>\n</Component>\n + <Component FQDD=\"Disk.Direct.1-1:AHCI.Slot.6-1\">\n<Attribute Name=\"RAIDPDState\">Ready</Attribute>\n + <Attribute Name=\"RAIDHotSpareStatus\">No</Attribute>\n</Component>\n</SystemConfiguration>\n" + + - name: "import template from local XML file" + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "import" + attributes: + Name: "Imported Template Name" + Type: 2 + Content: "{{ lookup('ansible.builtin.file', '/path/to/xmlfile') }}" + + - name: "Deploy template and Operating System (OS) on multiple devices." + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "deploy" + template_id: 12 + device_id: + - 12765 + device_service_tag: + - 'SVTG123' + attributes: + # Include this to install OS on the devices. + # This section is optional + NetworkBootIsoModel: + BootToNetwork: true + ShareType: "CIFS" + IsoTimeout: 1 # allowable values(1,2,4,8,16) in hours + IsoPath: "/home/iso_path/filename.iso" + ShareDetail: + IpAddress: "192.168.0.2" + ShareName: "sharename" + User: "share_user" + Password: "share_password" + Options: + EndHostPowerState: 1 + ShutdownType: 0 + TimeToWaitBeforeShutdown: 300 + Schedule: + RunLater: true + RunNow: false + + - name: Create a compliance template from reference device + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "create" + device_service_tag: "SVTG123" + template_view_type: "Compliance" + attributes: + Name: "Configuration Compliance" + Description: "Configuration Compliance Template" + Fqdds: "BIOS" + + - name: Import a compliance template from XML file + ome_template: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + command: "import" + template_view_type: "Compliance" + attributes: + Name: "Configuration Compliance" + Content: "{{ lookup('ansible.builtin.file', './test.xml') }}" + Type: 2 diff --git a/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_create_modify_lcd_display.yml b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_create_modify_lcd_display.yml new file mode 100644 index 00000000..40f4c002 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_create_modify_lcd_display.yml @@ -0,0 +1,129 @@ +--- +- hosts: ome + connection: local + name: "Creates a new template from the provided reference server device. + Track the template creation job till completion. + Fetch the Attribute specific to LCD Configuration settings from the attribute view of the created template. + Modify the created template with the user defined LCD string." + gather_facts: False + vars: + retries_count: 50 + polling_interval: 5 + reference_device: "MXL4567" + template_name: "LCD String Deploy Template" + lcd_display_string: "LCD Custom Display Message" + + collections: + - dellemc.openmanage + + tasks: + - name: "create template from the reference server" + ome_template: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + device_service_tag: "{{ reference_device }}" + attributes: + Name: "{{ template_name }}" + Description: "LCD Template description" + register: result + + - name: "sleep for 30 seconds and continue with play" + wait_for: timeout=30 + + - name: "Fetch the Task ID from the Template Details using the Template ID" + ome_template_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + template_id: "{{ result.return_id }}" + register: template_result + + - name: "Track the Template Creation Job till Completion" + ome_job_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + job_id: "{{ template_result.template_info[hostname].TaskId }}" + register: job_result + failed_when: "'job_info' not in job_result" + until: job_result.job_info.LastRunStatus.Name == 'Completed' or job_result.job_info.LastRunStatus.Name == 'Failed' + retries: "{{ retries_count }}" + delay: "{{ polling_interval }}" + + - name: "Retrieve the Attribute ID specific to LCD Configuration" + uri: + url: "https://{{ hostname }}/api/TemplateService/Templates({{ result.return_id }})/Views(1)/AttributeViewDetails" + user: "{{ username }}" + password: "{{ password }}" + method: "GET" + use_proxy: yes + status_code: 200 + return_content: yes + validate_certs: no + force_basic_auth: yes + headers: + Content-Type: "application/json" + Accept: "application/json" + register: config_result + + - name: "System Attribute Groups" + set_fact: + lcd_fact: "{{ item }}" + when: + - item.DisplayName=='System' + with_items: + - "{{ config_result.json.AttributeGroups }}" + loop_control: + label: "{{ config_result.json.Name }}" + + - name: "LCD System Attributes Groups" + set_fact: + lcdconfig: "{{ item }}" + when: + - item.DisplayName=='LCD Configuration' + with_items: + - "{{ lcd_fact.SubAttributeGroups }}" + loop_control: + label: "{{ item.DisplayName }}" + + - name: "Retrieve LCD Display Attribute ID" + set_fact: + lcdattrid: "{{ item.AttributeId }}" + when: + - item.DisplayName=='LCD 1 User Defined String for LCD' + with_items: + - "{{ lcdconfig.Attributes }}" + loop_control: + label: "{{ item.DisplayName }}" + + - name: "Retrieve LCD Config Attribute ID" + set_fact: + lcdconfigattrid: "{{ item.AttributeId }}" + when: + - item.DisplayName=='LCD 1 LCD Configuration' + with_items: + - "{{ lcdconfig.Attributes }}" + loop_control: + label: "{{ item.DisplayName }}" + + - name: "Modify the created with Custom LCD String to be displayed" + ome_template: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + state: "modify" + template_id: "{{ result.return_id }}" + attributes: + Name: "{{ template_name }}" + Attributes: + - Id: "{{ lcdattrid }}" + Value: "{{ lcd_display_string }}" + IsIgnored: false + - Id: "{{ lcdconfigattrid }}" + Value: "User Defined" + IsIgnored: false
\ No newline at end of file diff --git a/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_info.yml b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_info.yml new file mode 100644 index 00000000..3fd200c0 --- /dev/null +++ b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_info.yml @@ -0,0 +1,33 @@ +--- +- hosts: ome + connection: local + name: Dell OpenManage Ansible template inventory details. + gather_facts: False + + collections: + - dellemc.openmanage + + tasks: + - name: Retrieve basic details of all templates. + ome_template_info: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + + - name: Retrieve details of a specific template identified by its template ID. + ome_template_info: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + template_id: "{{template_id}}" + + - name: Get filtered template info based on name. + ome_template_info: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + system_query_options: + filter: "Name eq 'new template'"
\ No newline at end of file diff --git a/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_info_with_filter.yml b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_info_with_filter.yml new file mode 100644 index 00000000..eb040c9c --- /dev/null +++ b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_info_with_filter.yml @@ -0,0 +1,27 @@ +--- +- hosts: ome + connection: local + name: Dell OpenManage Ansible device Template service. + gather_facts: False + + collections: + - dellemc.openmanage + + tasks: + - name: get template with filter option. + register: result + failed_when: "'template_info' not in result or result.template_info['{{hostname}}']['@odata.count'] == 0" + ome_template_info: + hostname: "{{hostname}}" + username: "{{username}}" + password: "{{password}}" + ca_path: "/path/to/ca_cert.pem" + system_query_options: + filter: "Name eq 'template_name'" + - name: get specific template from result + with_subelements: + - "{{ result.template_info }}" + - value + debug: + msg: "{{item.1}}" + when: item.1['Name']=='template_name' diff --git a/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_lcd_display_string_deploy.yml b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_lcd_display_string_deploy.yml new file mode 100644 index 00000000..afb472fa --- /dev/null +++ b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_lcd_display_string_deploy.yml @@ -0,0 +1,46 @@ +--- +- hosts: ome + connection: local + name: + - Deploy this template with desired LCD string on the target servers. + - Track the template deploy operation job till completion. + gather_facts: False + vars: + retries_count: 50 + polling_interval: 5 + template_name: "LCD Srting Deploy Template" + deployable_servicetag: + - 'MXL1234' + - 'MXL4567' + + collections: + - dellemc.openmanage + + tasks: + - name: "Deploy Previously created LCD Template " + ome_template: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + state: "deploy" + template_name: "{{ template_name }}" + device_service_tag: "{{ deployable_servicetag }}" + register: result + tags: + - deploy + + - name: "Track the deploy job till completion" + ome_job_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + job_id: "{{ result.return_id }}" + register: job_result + failed_when: "'job_info' not in job_result" + until: job_result.job_info.LastRunStatus.Name == 'Completed' or job_result.job_info.LastRunStatus.Name == 'Failed' + retries: "{{ retries_count }}" + delay: "{{ polling_interval }}" + tags: + - track_deploy
\ No newline at end of file diff --git a/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_network_vlan.yml b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_network_vlan.yml new file mode 100644 index 00000000..fee07b4e --- /dev/null +++ b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_network_vlan.yml @@ -0,0 +1,66 @@ +--- +- hosts: ome + connection: local + name: Dell OpenManage Ansible template tag and untag. + gather_facts: False + + collections: + - dellemc.openmanage + + tasks: + - name: Tag or untag vlans in template + ome_template_network_vlan: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + template_id: 78 + nic_identifier: NIC Slot 4 + untagged_networks: + - port: 1 + untagged_network_id: 12765 + - port: 2 + untagged_network_name: vlan2 + tagged_networks: + - port: 1 + tagged_network_ids: + - 12767 + - 12768 + - port: 4 + tagged_network_ids: + - 12767 + - 12768 + tagged_network_names: + - vlan3 + - port: 2 + tagged_network_names: + - vlan4 + - vlan1 + tags: + - tag_untag_vlan + + - name: Clear the tagged and untagged vLANs + ome_template_network_vlan: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + template_id: 78 + nic_identifier: NIC Slot 4 + untagged_networks: + # For removing the untagged vLANs for the port 1 and 2 + - port: 1 + untagged_network_id: 0 + - port: 2 + untagged_network_name: 0 + tagged_networks: + # For removing the tagged vLANs for port 1 and 4 + - port: 1 + tagged_network_ids: [] + - port: 4 + tagged_network_ids: [] + tagged_network_names: [] + - port: 2 + tagged_network_names: [] + tags: + - clear_tagged_untagged
\ No newline at end of file diff --git a/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_with_job_tracking.yml b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_with_job_tracking.yml new file mode 100644 index 00000000..9f93bbdf --- /dev/null +++ b/ansible_collections/dellemc/openmanage/playbooks/ome/template/ome_template_with_job_tracking.yml @@ -0,0 +1,48 @@ +--- +- hosts: ome + vars: + retries_count: 50 + polling_interval: 5 #in seconds + connection: local + name: "OME - Create Template details tracking" + gather_facts: False + + collections: + - dellemc.openmanage + + tasks: + - name: "Create template based on device id." + ome_template: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + device_id: 12475 + attributes: + Name: "New Template" + Description: "New Template description" + register: result + failed_when: "'return_id' not in result" + + - name: "Get the job id using return id from template." + ome_template_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + template_id: "{{ result.return_id }}" + register: facts_result + + - name: "Get job details using job id from template task." + ome_job_info: + hostname: "{{ hostname }}" + username: "{{ username }}" + password: "{{ password }}" + ca_path: "/path/to/ca_cert.pem" + job_id: "{{ facts_result.template_info[hostname].TaskId }}" + register: job_result + failed_when: job_result.job_info.LastRunStatus.Name == 'Failed' + changed_when: job_result.job_info.LastRunStatus.Name == 'Completed' + until: job_result.job_info.LastRunStatus.Name == 'Completed' or job_result.job_info.LastRunStatus.Name == 'Failed' + retries: "{{ retries_count }}" + delay: "{{ polling_interval }}" |