---
- name: Dell OpenManage Ansible configuration compliance baseline.
  hosts: ome
  gather_facts: false

  tasks:
    - name: Create a configuration compliance baseline using device IDs
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        ca_path: "/path/to/ca_cert.pem"
        command: create
        template_name: "template 1"
        description: "description of baseline"
        names: "baseline1"
        device_ids:
          - 1111
          - 2222
      tags:
        - create_compliance_baseline_device_id
      delegate_to: localhost

    - name: Create a configuration compliance baseline using device service tags
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        ca_path: "/path/to/ca_cert.pem"
        command: create
        template_name: "template 1"
        names: "baseline1"
        description: "description of baseline"
        device_service_tags:
          - "SVCTAG1"
          - "SVCTAG2"
      tags:
        - create_compliance_baseline_tags
      delegate_to: localhost

    - name: Create a configuration compliance baseline using group names
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        ca_path: "/path/to/ca_cert.pem"
        command: create
        template_name: "template 1"
        job_wait_timeout: 1000
        names: "baseline1"
        description: "description of baseline"
        device_group_names:
          - "Group1"
          - "Group2"
      tags:
        - create_compliance_baseline_group_id
      delegate_to: localhost

    - name: Delete the configuration compliance baselines
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        ca_path: "/path/to/ca_cert.pem"
        command: delete
        names:
          - baseline1
          - baseline2
      tags:
        - delete_compliance_baseline
      delegate_to: localhost

    - name: Modify a configuration compliance baseline using group names
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "192.168.0.1"
        username: "username"
        password: "password"
        ca_path: "/path/to/ca_cert.pem"
        names: "baseline1"
        new_name: "baseline_update"
        template_name: "template2"
        description: "new description of baseline"
        job_wait_timeout: 1000
        device_group_names:
          - Group1
      delegate_to: localhost

    - name: Remediate specific non-compliant devices to a configuration compliance baseline using device IDs
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "192.168.0.1"
        username: "username"
        password: "password"
        ca_path: "/path/to/ca_cert.pem"
        command: "remediate"
        names: "baseline1"
        device_ids:
          - 1111
      delegate_to: localhost

    - name: Remediate specific non-compliant devices to a configuration compliance baseline using device service tags
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "192.168.0.1"
        username: "username"
        password: "password"
        ca_path: "/path/to/ca_cert.pem"
        command: "remediate"
        names: "baseline1"
        job_wait_timeout: 2000
        device_service_tags:
          - "SVCTAG1"
          - "SVCTAG2"
      delegate_to: localhost

    - name: Remediate all the non-compliant devices to a configuration compliance baseline
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "192.168.0.1"
        username: "username"
        password: "password"
        ca_path: "/path/to/ca_cert.pem"
        command: "remediate"
        job_wait_timeout: 2000
        names: "baseline1"
      delegate_to: localhost

    - name: Remediate specific non-compliant devices to a configuration
       compliance baseline using device IDs at scheduled time
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "192.168.0.1"
        username: "username"
        password: "password"
        ca_path: "/path/to/ca_cert.pem"
        command: "remediate"
        names: "baseline1"
        device_ids:
          - 1111
        run_later: true
        cron: "0 00 11 14 02 ? 2032"  # Feb 14,2032 4:30:00 PM
      delegate_to: localhost

    - name: Remediate specific non-compliant devices to a configuration
       compliance baseline using device service tags on next reboot
      dellemc.openmanage.ome_configuration_compliance_baseline:
        hostname: "192.168.0.1"
        username: "username"
        password: "password"
        ca_path: "/path/to/ca_cert.pem"
        command: "remediate"
        names: "baseline1"
        device_service_tags:
          - "SVCTAG1"
          - "SVCTAG2"
        staged_at_reboot: true
      delegate_to: localhost
