Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OME Configuration Compliance Template #339

Closed
ImranJMughal opened this issue Nov 16, 2021 · 3 comments · Fixed by #351
Closed

OME Configuration Compliance Template #339

ImranJMughal opened this issue Nov 16, 2021 · 3 comments · Fixed by #351

Comments

@ImranJMughal
Copy link

ImranJMughal commented Nov 16, 2021

Question

Is there any playbook for configuration compliance templates. I want to import a template from an XML file to each of our OME instances. To confirm this isn't the same as ome_template.

Details

image

image

@anupamaloke
Copy link
Contributor

@ImranJMughal, you can use ome_template module to create the configuration compliance template. See below example playbook that uses a reference device to create a configuration compliance template. You can also choose to import a SCP XML file to create a compliance template. In order to create a compliance template, you will have to set the template_view_type to Compliance.

  tasks:
  - name: create a compliance template
    dellemc.openmanage.ome_template:
      hostname: "{{ inventory_hostname }}"
      username: "{{ ome_username }}"
      password: "{{ ome_password }}"
      command: "create"
      device_service_tag: "ABC1234"
      template_view_type: "Compliance"
      attributes:
        Name: "Ansible Demo Configuration Compliance"
        Description: "Ansible Demo Configuration Compliance Template"
        Fqdds: "BIOS"   <========= Default is "ALL". 
        TypeId: 2           <========= Server is "2", Chassis is "4" and IO Module is "3"
    register: result

  - name: get the job ID
    dellemc.openmanage.ome_template_info:
      hostname: "{{ inventory_hostname }}"
      username: "{{ ome_username }}"
      password: "{{ ome_password }}"
      template_id: "{{ result.return_id }}"
    register: template_info

  - name: Track job till completion
    dellemc.openmanage.ome_job_info:
      hostname: "{{ inventory_hostname }}"
      username: "{{ ome_username }}"
      password: "{{ ome_password }}"
      job_id: "{{ template_info.template_info[inventory_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: 25
    delay: 10

@anupamaloke
Copy link
Contributor

@sachin-apa, @jagadeeshnv it would be good to update the EXAMPLES section in the module documentation as well as the example playbooks on how to create configuration compliance templates from a reference device or by importing a SCP file.

@ImranJMughal
Copy link
Author

Hey thanks guys, i was just testing it with Anupam.

So this works for import from a reference device

  - name: create a compliance template
    dellemc.openmanage.ome_template:
      hostname: "{{ inventory_hostname }}"
      username: "{{ ome_username }}"
      password: "{{ ome_password }}"
      command: "create"
      device_service_tag: "ABC1234"
      template_view_type: "Compliance"
      attributes:
        Name: "Ansible Demo Configuration Compliance"
        Description: "Ansible Demo Configuration Compliance Template"
        Fqdds: "BIOS"   <========= Default is "ALL". 
        TypeId: 2           <========= Server is "2", Chassis is "4" and IO Module is "3"
    register: result

For import from XML you need to use Type instead of TypeId. This should be standardised to avoid confusion

  - name: create a compliance template
    dellemc.openmanage.ome_template:
      hostname: "{{ inventory_hostname }}"
      username: "{{ ome_username }}"
      password: "{{ ome_password }}"
      command: "import"
      template_view_type: "Compliance"
      attributes:
        Name: "Ansible Demo Configuration Compliance"
         Content: "{{ lookup('ansible.builtin.file', './test.xml') }}"
        Type: 2
    register: result

@anupamaloke anupamaloke added this to the v4.4.0 milestone Nov 29, 2021
@anupamaloke anupamaloke moved this from To do to In progress in OpenManage Ansible Collection Nov 30, 2021
@anupamaloke anupamaloke linked a pull request Jan 4, 2022 that will close this issue
@anupamaloke anupamaloke moved this from In progress to Done in OpenManage Ansible Collection Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants