---
- hosts: all
  connection: local
  become: True

  pre_tasks:
    - name: Update APT cache
      apt: update_cache=yes cache_valid_time=3600

  roles:
    - role: "raster-foundry.docker"
    - role: "raster-foundry.aws-cli"

  tasks:
    - name: Change directory on login
      lineinfile: dest=/home/vagrant/.bashrc regexp=^raster-foundry_PROFILE line="cd /opt/raster-foundry/"

    - name: Set Environment variable for AWS profile
      lineinfile: dest=/etc/environment regexp=^AWS_PROFILE line="AWS_PROFILE={{aws_profile}}"
      when: aws_profile is defined

    - name: Set Environment variable for Raster Foundry AWS Config Bucket
      lineinfile: dest=/etc/environment regexp=^RF_SETTINGS_BUCKET line="RF_SETTINGS_BUCKET={{rf_settings_bucket}}"
      when: rf_aws_settings_bucket is defined

    - name: Set Environment variable for Raster Foundry AWS Artifacts Bucket
      lineinfile: dest=/etc/environment regexp=^RF_ARTIFACTS_BUCKET
                  line="RF_ARTIFACTS_BUCKET={{rf_artifacts_bucket}}"
      when: rf_aws_artifacts_bucket is defined

    - name: Set Environment variable for host user (used to namespace jars and other artifacts in development)
      lineinfile: dest=/etc/environment regexp=^RF_HOST_USER line="RF_HOST_USER={{host_user}}"
      when: host_user is defined

---
- hosts: all
  connection: local
  become: True

  pre_tasks:
    - name: Update APT cache
      apt: update_cache=yes cache_valid_time=3600

  roles:
    - role: "raster-foundry.docker"
    - role: "raster-foundry.aws-cli"

  tasks:
    - name: Change directory on login
      lineinfile: dest=/home/vagrant/.bashrc regexp=^raster-foundry_PROFILE line="cd /opt/raster-foundry/"

    - name: Set Environment variable for AWS profile
      lineinfile: dest=/etc/environment regexp=^AWS_PROFILE line="AWS_PROFILE={{ aws_profile }}"
      when: aws_profile is defined

    - name: Set Environment variable for Raster Foundry AWS Config Bucket
      lineinfile: dest=/etc/environment regexp=^RF_SETTINGS_BUCKET line="RF_SETTINGS_BUCKET={{ rf_settings_bucket }}"
      when: rf_settings_bucket is defined

    - name: Set Environment variable for Raster Foundry AWS Artifacts Bucket
      lineinfile: dest=/etc/environment regexp=^RF_ARTIFACTS_BUCKET
                  line="RF_ARTIFACTS_BUCKET={{ rf_artifacts_bucket }}"
      when: rf_artifacts_bucket is defined

    - name: Set Environment variable for host user (used to namespace jars and other artifacts in development)
      lineinfile: dest=/etc/environment regexp=^RF_HOST_USER line="RF_HOST_USER={{ host_user }}"
      when: host_user is defined

Set environment variables within the VM
Set environment variables within the VM

Update the `when` clauses so that they use the same variable name we intend to
template into `/etc/environment`.
