| --- |
| - hosts: localhost |
| connection: local |
| |
| vars: |
| ansible_config: ~/.ansible |
| apigee_config: ~/.apigee |
| workspace: ~/apigee-workspace/opdk-workspace |
| |
| tasks: |
| - name: Create ansible configuration folders |
| file: |
| path: '{{ item }}' |
| state: directory |
| with_items: |
| - '{{ ansible_config }}/configurations' |
| - '{{ ansible_config }}/inventory' |
| - '{{ apigee_config }}' |
| |
| - name: Git checkout of sample configurations |
| ignore_errors: yes |
| git: |
| repo: https://github.com/carlosfrias/apigee-opdk-ansible-configuration-samples.git |
| dest: "{{ ansible_config }}/configurations-template-samples" |
| |
| - name: Git checkout of sample inventories |
| ignore_errors: yes |
| git: |
| repo: https://github.com/carlosfrias/apigee-opdk-ansible-inventory-samples.git |
| dest: "{{ ansible_config }}/inventory-template-samples" |
| |
| - name: Git checkout of sample playbooks |
| ignore_errors: yes |
| git: |
| repo: https://github.com/carlosfrias/apigee-opdk-playbook-samples.git |
| dest: "{{ workspace }}/apigee-opdk-playbook-samples" |
| |
| - name: Add empty credentials.yml file to .apigee |
| copy: |
| src: credentials.yml |
| dest: '{{ apigee_config }}/credentials.yml' |
| force: no |
| |
| - name: Create a template .boto config file |
| template: |
| src: boto.j2 |
| dest: ~/.boto |
| when: aws_access_key_id is defined and aws_secret_access_key is defined and secure_aws_region is defined |
| |
| - name: Create a template ec2.ini config file |
| template: |
| src: ec2.ini.j2 |
| dest: ~/.ansible/ec2.ini |
| when: aws_access_key_id is defined and aws_secret_access_key is defined and secure_aws_region is defined |
| |
| - name: Update EC2_INI_PATH |
| lineinfile: |
| backup: yes |
| dest: ~/.bashrc |
| state: present |
| line: 'export EC2_INI_PATH=~/.ansible/ec2.ini' |
| when: aws_access_key_id is defined and aws_secret_access_key is defined and secure_aws_region is defined |
| |
| - name: Update .bashrc with AWS_ACCESS_KEY_ID |
| lineinfile: |
| backup: yes |
| dest: ~/.bashrc |
| state: present |
| line: 'export AWS_ACCESS_KEY_ID={{ aws_access_key_id }}' |
| when: aws_access_key_id is defined |
| |
| - name: Update .bashrc with AWS_SECRET_ACCESS_KEY |
| lineinfile: |
| backup: yes |
| dest: ~/.bashrc |
| state: present |
| line: 'export AWS_SECRET_ACCESS_KEY={{ aws_secret_access_key }}' |
| when: aws_secret_access_key is defined |
| |