---

- name: Make sure there is no existing file called {{ ansible_aws_config_file }}
  file:
    path: "{{ ansible_aws_config_file }}"
    state: absent


- name: Copy config file {{ ansible_aws_config_file }} from {{ ansible_aws_s3_url }}
  command: "{{ ansible_aws_paths.aws }} s3 cp {{ ansible_aws_s3_url }} {{ ansible_aws_config_file }}"
  register: result

- name: Check if the file exists
  stat:
    path: "{{ ansible_aws_config_file }}"
  register: ansible_aws_config_file_info

# If the file wasn't downloaded, this will fail. Good :-)
- name: Load the params from {{ ansible_aws_config_file }}
  include_vars: "{{ ansible_aws_config_file }}"
  when: ansible_aws_config_file_info.stat.exists

- debug: msg="{{ ansible_aws_config_file }} doesn't exist"
  when: not ansible_aws_config_file_info.stat.exists




---

- name: Make sure there is no existing file called {{ ansible_aws_config_file }}
  file:
    path: "{{ ansible_aws_config_file }}"
    state: absent


- name: Copy config file {{ ansible_aws_config_file }} from {{ ansible_aws_s3_url }}
  command: "{{ ansible_aws_paths.aws }} s3 cp {{ ansible_aws_s3_url }} {{ ansible_aws_config_file }}"
  register: result

- name: Check if the file exists
  stat:
    path: "{{ ansible_aws_config_file }}"
  register: ansible_aws_config_file_info

# If the file wasn't downloaded, this will fail. Good :-)
- name: Load the params from {{ ansible_aws_config_file }}
  include_vars: "{{ ansible_aws_config_file }}"
  when: ansible_aws_config_file_info.stat.exists

- fail: msg="{{ ansible_aws_config_file }} doesn't exist"
  when: not ansible_aws_config_file_info.stat.exists




Exit if the config file wasn't downloaded
Exit if the config file wasn't downloaded
