---
- hosts: idrac
  connection: local
  name: Server Configuration Profile
  gather_facts: False

  collections:
    - dellemc.openmanage

  tasks:
  - name: Export Server Configuration Profile
    idrac_server_config_profile:
      idrac_ip:        "{{ idracip }}"
      idrac_user:      "{{ username }}"
      idrac_password:       "{{ password }}"
      share_name:      "/tmp/"
      job_wait:        "False"
    tags:
        - scp_components_export

  - name: Export Server Configuration Profile for iDRAC to local path
    idrac_server_config_profile:
      idrac_ip:        "{{ idracip }}"
      idrac_user:      "{{ username }}"
      idrac_password:       "{{ password }}"
      idrac_port:      "443"
      share_name:      "/tmp/"
      scp_components:  "IDRAC"
      job_wait:        "False"
      export_format:   "JSON"
    tags:
      - scp_components_idrac_export_json_format
  
  - name: Export Server Configuration Profile to a network share
    idrac_server_config_profile:
      idrac_ip: "{{ idracip }}"
      idrac_user: "{{ username }}"
      idrac_password: "{{ password }}"
      share_name: "192.168.0.2:/share"
      share_user: "share_user_name"
      share_password: "share_user_pwd"
      job_wait: False
    tags:
      - scp_components_idrac_export_network_share

  - name: Import SCP from a local path and wait for this job to get completed
    idrac_server_config_profile:
      idrac_ip:        "{{ idracip }}"
      idrac_user:      "{{ username }}"
      idrac_pwd:       "{{ password }}"
      idrac_port:      "443"
      share_name:      "/tmp/"
      command:           "import"
      scp_file:        "testscp.json"
      scp_components:  "IDRAC"
      shutdown_type:   "Graceful"
      job_wait:        "True"
    tags:
      - scp_components_idrac_import_local_path

  - name: Import SCP from a network share and wait for this job to get completed
    idrac_server_config_profile:
      idrac_ip: "{{ idracip }}"
      idrac_user: "{{ username }}"
      idrac_password: "{{ password }}"
      command: "import"
      share_name: "192.168.0.2:/share"
      share_user: "share_user_name"
      share_password: "share_user_pwd"
      scp_file:   "scp_filename.xml"
      scp_components: "ALL"
      job_wait: True
    tags:
      - scp_components_idrac_import_network_share

  - name: Export SCP to a local path with explicit name for file
    idrac_server_config_profile:
      idrac_ip: "192.168.0.1"
      idrac_user: "user_name"
      idrac_password: "user_password"
      share_name: "/scp_folder"
      # extension for filename is considered if provided
      scp_file: "exported_scp_filename"
      export_format: "JSON"
      job_wait: False
    tags:
      - scp_export_local_filename