---

# INFRA-1109 -- We keep running into various issues with external connections
# including in this simple playbook. Since this role in particular isn't
# critical to anything in CI or on vehicles and is only used by devs directly
# we are now:
#  1. retrying downloads to try to get past intermittent network issues
#  2. ignoring all errors even if all retries fail so things like CI/deploy
#     don't fail completely.

- block:
  - name: "Clone tfenv"
    git:
      repo: "https://github.com/tfutils/tfenv.git"
      dest: ~/.tfenv
      clone: yes
      version: v2.0.0
      update: yes

  - name: "Configure tfenv to use GnuPG for sig verification"
    copy:
      dest: ~/.tfenv/use-gpgv
      content: "trust-tfenv: yes\n"

  # tfenv's auto-install feature (as of 2.0.0) won't
  # work unless at least one version of TF is installed.
  # Otherwise, these installations aren't necessary
  # as tfenv will install whatever version is declared in
  # a config's .terraform-version file.
  - name: "Install terraform version 0.12.20"
    shell: "~/.tfenv/bin/tfenv install 0.12.20"
    args:
      creates: "~/.tfenv/versions/0.12.20/terraform"

  tags:
  - tfenv
