--- - name: Converge hosts: all gather_facts: false vars: ca_cert_path: "{{ lookup('env', 'ca_cert_path') }}" csc_cert_name: "{{ lookup('env', 'csc_certificate') }}" csc_cert_pass_name: "{{ lookup('env', 'csc_passphrase_certificate') }}" import_cert_path: "{{ lookup('env', 'path_for_import_cert') }}" export_cert_path: "{{ lookup('env', 'path_for_export_cert') }}" tasks: - name: Fetching CSC certificates from share ansible.builtin.include_tasks: file: ../__get_helper.yml vars: idrac_cert_name: - "{{ csc_cert_name }}" - name: Import CSC certificate without passphrase ansible.builtin.import_role: name: dellemc.openmanage.idrac_certificate vars: hostname: "{{ lookup('env', 'IDRAC_IP') }}" username: "{{ lookup('env', 'IDRAC_USER') }}" password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" validate_certs: false command: "import" certificate_type: "CSC" passphrase: "" certificate_path: "{{ import_cert_path }}{{ csc_cert_name }}" - name: Waiting for idrac readiness ansible.builtin.wait_for: timeout: 30 when: - not ansible_check_mode - idrac_certificate_out is defined - idrac_certificate_out.changed - name: Asserting operation with check mode. ansible.builtin.assert: that: idrac_certificate_out.msg == "Changes found to be applied." when: ansible_check_mode - name: Asserting operation with Normal/Idempotence mode (Import certificate). ansible.builtin.assert: that: idrac_certificate_out.msg == "Successfully performed the 'import' certificate operation.iDRAC has been reset successfully." when: not ansible_check_mode and idrac_certificate_out.changed - name: Export CSC certificate without passphrase ansible.builtin.import_role: name: dellemc.openmanage.idrac_certificate vars: hostname: "{{ lookup('env', 'IDRAC_IP') }}" username: "{{ lookup('env', 'IDRAC_USER') }}" password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" validate_certs: false command: "export" certificate_type: "CSC" certificate_path: "{{ export_cert_path }}" when: not ansible_check_mode - name: Setting up CSC certificate path for exported file when: idrac_certificate_out is defined and idrac_certificate_out.certificate_path is defined ansible.builtin.stat: path: "{{ idrac_certificate_out.certificate_path }}" register: csc_cert_file no_log: true - name: Asserting operation with Normal/Idempotence mode (Export certificate). ansible.builtin.assert: that: - csc_cert_file.stat.exists - not idrac_certificate_out.changed - not idrac_certificate_out.failed - idrac_certificate_out.msg == "Successfully performed the 'export' certificate operation." when: not ansible_check_mode and not idrac_certificate_out.changed - name: Fetching CSC certificates from share. ansible.builtin.include_tasks: file: ../__get_helper.yml vars: idrac_cert_name: - "{{ csc_cert_pass_name }}" - name: Import CSC certificate with passphrase ansible.builtin.import_role: name: dellemc.openmanage.idrac_certificate vars: hostname: "{{ lookup('env', 'IDRAC_IP') }}" username: "{{ lookup('env', 'IDRAC_USER') }}" password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" validate_certs: false command: "import" certificate_type: "CSC" passphrase: "{{ lookup('env', 'passphrase') }}" certificate_path: "{{ import_cert_path }}{{ csc_cert_pass_name }}" - name: Waiting for idrac readiness. ansible.builtin.wait_for: timeout: 30 when: - not ansible_check_mode - idrac_certificate_out is defined - idrac_certificate_out.changed - name: Asserting operation with check mode ansible.builtin.assert: that: idrac_certificate_out.msg == "Changes found to be applied." when: ansible_check_mode - name: Asserting operation with Normal/Idempotence mode. ansible.builtin.assert: that: idrac_certificate_out.msg == "Successfully performed the 'import' certificate operation.iDRAC has been reset successfully." when: not ansible_check_mode and idrac_certificate_out.changed - name: Export CSC certificate with passphrase ansible.builtin.import_role: name: dellemc.openmanage.idrac_certificate vars: hostname: "{{ lookup('env', 'IDRAC_IP') }}" username: "{{ lookup('env', 'IDRAC_USER') }}" password: "{{ lookup('env', 'IDRAC_PASSWORD') }}" validate_certs: false command: "export" certificate_type: "CSC" certificate_path: "{{ export_cert_path }}" when: not ansible_check_mode - name: Setting up CSC certificate path for exported file. when: idrac_certificate_out is defined and idrac_certificate_out.certificate_path is defined ansible.builtin.stat: path: "{{ idrac_certificate_out.certificate_path }}" register: csc_cert_file no_log: true - name: Asserting operation with Normal/Idempotence mode ansible.builtin.assert: that: - csc_cert_file.stat.exists - not idrac_certificate_out.changed - not idrac_certificate_out.failed - idrac_certificate_out.msg == "Successfully performed the 'export' certificate operation." when: not ansible_check_mode and not idrac_certificate_out.changed - name: Deleting the directory ansible.builtin.include_tasks: file: ../__delete_directory.yml