---
- name: upload certificates to AWS IAM
  iam_cert:
    state: present
    name: "{{ openshift_aws_iam_cert_name }}"
    cert: "{{ openshift_aws_iam_cert_path }}"
    key: "{{ openshift_aws_iam_cert_key_path }}"
    cert_chain: "{{ openshift_aws_iam_cert_chain_path | default(omit) }}"
    dup_ok: True
  register: elb_cert_chain
  when:
  - openshift_aws_create_iam_cert | bool
  - openshift_aws_iam_cert_path != ''
  - openshift_aws_iam_cert_key_path != ''
  - openshift_aws_elb_cert_arn == ''

- debug:
    msg: "{{ elb_cert_chain }}"
    verbosity: 1

- name: set_fact openshift_aws_elb_cert_arn
  set_fact:
    openshift_aws_elb_cert_arn: "{{ elb_cert_chain.arn }}"
  when:
  - openshift_aws_create_iam_cert | bool
  - openshift_aws_iam_cert_path != ''
  - openshift_aws_iam_cert_key_path != ''
  - openshift_aws_elb_cert_arn == ''
