| --- |
| - hosts: localhost |
| connection: local |
| gather_facts: no |
| vars_files: |
| - ~/.apigee/credentials.yml |
| tasks: |
| - name: Validate that aws_secret_key is provided |
| fail: |
| msg: Please indicate the aws_secret_key |
| when: aws_secret_key is not defined |
| |
| - name: Validate that aws_access_key is provided |
| fail: |
| msg: Please indicate the aws_access_key |
| when: aws_access_key is not defined |
| |
| - name: Validate that aws_region is provided |
| fail: |
| msg: Please indicate the aws_region |
| when: aws_region is not defined |
| |
| - name: Install system packages |
| become: yes |
| ignore_errors: yes |
| yum: |
| name: '{{ item }}' |
| state: present |
| with_items: |
| - elasticache-auto-discovery |
| when: ansible_os_family | lower == 'redhat' |
| |
| - name: Update .bashrc with aws_access_key |
| become: no |
| lineinfile: |
| backup: yes |
| dest: ~/.bashrc |
| state: present |
| line: 'export AWS_SECRET_ACCESS_KEY={{ aws_secret_key }}' |
| when: aws_access_key is defined |
| |
| - name: Update .bashrc with aws_secret_key |
| become: no |
| lineinfile: |
| backup: yes |
| dest: ~/.bashrc |
| state: present |
| line: 'export AWS_ACCESS_KEY_ID={{ aws_access_key }}' |
| when: aws_secret_key is defined |
| |
| - name: Update .bashrc with aws_region |
| become: no |
| lineinfile: |
| backup: yes |
| dest: ~/.bashrc |
| state: present |
| line: 'export AWS_REGION={{ aws_region }}' |
| when: aws_secret_key is defined |
| |