updated to include setting up a control server and cleaning up directory of excess files
diff --git a/control-server.yml b/control-server.yml index 0120011..38f3d5d 100644 --- a/control-server.yml +++ b/control-server.yml
@@ -1,5 +1,4 @@ --- - - include: configuration/update-user.yml vars: hosts: 'control'
diff --git a/boto.j2 b/resources/boto.j2 similarity index 100% rename from boto.j2 rename to resources/boto.j2
diff --git a/credentials.yml b/resources/credentials.yml similarity index 100% rename from credentials.yml rename to resources/credentials.yml
diff --git a/ec2.ini.j2 b/resources/ec2.ini similarity index 83% rename from ec2.ini.j2 rename to resources/ec2.ini index 50e3c7e..e06299a 100644 --- a/ec2.ini.j2 +++ b/resources/ec2.ini
@@ -144,37 +144,37 @@ # Ansible EC2 external inventory script settings # -[ec2] - -# to talk to a private eucalyptus instance uncomment these lines -# and edit edit eucalyptus_host to be the host name of your cloud controller -#eucalyptus = True -#eucalyptus_host = clc.cloud.domain.org - -# AWS regions to make calls to. Set this to 'all' to make request to all regio -ns -# in AWS and merge the results together. Alternatively, set this to a comma -# separated list of regions. E.g. 'us-east-1,us-west-1,us-west-2' -regions = all -regions_exclude = us-gov-west-1,cn-north-1 - -# When generating inventory, Ansible needs to know how to address a server. -# Each EC2 instance has a lot of variables associated with it. Here is the lis -t: -# http://docs.pythonboto.org/en/latest/ref/ec2.html#module-boto.ec2.instance -# Below are 2 variables that are used as the address of a server: -# - destination_variable -# - vpc_destination_variable - -# This is the normal destination variable to use. If you are running Ansible -# from outside EC2, then 'public_dns_name' makes the most sense. If you are -# running Ansible from within EC2, then perhaps you want to use the internal -# address, and should set this to 'private_dns_name'. The key of an EC2 tag -...skipping... -# pattern_include = staging-* - -# If you want to exclude any hosts that match a certain regular expression -# pattern_exclude = staging-* +##[ec2] +## +### to talk to a private eucalyptus instance uncomment these lines +### and edit edit eucalyptus_host to be the host name of your cloud controller +###eucalyptus = True +###eucalyptus_host = clc.cloud.domain.org +## +### AWS regions to make calls to. Set this to 'all' to make request to all regio +##ns +### in AWS and merge the results together. Alternatively, set this to a comma +### separated list of regions. E.g. 'us-east-1,us-west-1,us-west-2' +##regions = all +##regions_exclude = us-gov-west-1,cn-north-1 +## +### When generating inventory, Ansible needs to know how to address a server. +### Each EC2 instance has a lot of variables associated with it. Here is the lis +##t: +### http://docs.pythonboto.org/en/latest/ref/ec2.html#module-boto.ec2.instance +### Below are 2 variables that are used as the address of a server: +### - destination_variable +### - vpc_destination_variable +## +### This is the normal destination variable to use. If you are running Ansible +### from outside EC2, then 'public_dns_name' makes the most sense. If you are +### running Ansible from within EC2, then perhaps you want to use the internal +### address, and should set this to 'private_dns_name'. The key of an EC2 tag +##...skipping... +### pattern_include = staging-* +## +### If you want to exclude any hosts that match a certain regular expression +### pattern_exclude = staging-* # Instance filters can be used to control which instances are retrieved for # inventory. For the full list of possible filters, please read the EC2 API
diff --git a/ec2.py b/resources/ec2.py similarity index 100% rename from ec2.py rename to resources/ec2.py
diff --git a/setup-base.yml b/setup-base.yml new file mode 100644 index 0000000..d507540 --- /dev/null +++ b/setup-base.yml
@@ -0,0 +1,49 @@ +--- +- hosts: control + 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: Yum packages + become: yes + yum: + name: '{{ item }}' + state: present + with_items: + - git + - tree + + - 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" + + - 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" + + - 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: resources/credentials.yml + dest: '{{ apigee_config }}/credentials.yml' + force: no
diff --git a/setup-ec2.yml b/setup-ec2.yml index 9e9f43e..003c323 100644 --- a/setup-ec2.yml +++ b/setup-ec2.yml
@@ -1,6 +1,5 @@ --- -- hosts: localhost - connection: local +- hosts: control vars: ansible_config: ~/.ansible @@ -8,15 +7,14 @@ tasks: - name: Create a template .boto config file template: - src: boto.j2 + src: resources/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 + copy: + src: resources/ec2.ini dest: '{{ ansible_config }}/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: @@ -26,10 +24,10 @@ line: 'export EC2_INI_PATH={{ ansible_config }}/ec2.ini' when: aws_access_key_id is defined and aws_secret_access_key is defined and secure_aws_region is defined - - name: Copy ec2.py script - copy: - src: ec2.py - dest: '{{ ansible_config }}/ec2.py' +# - name: Copy ec2.py script +# copy: +# src: resources/ec2.py +# dest: '{{ ansible_config }}/ec2.py' - name: Update .bashrc with AWS_ACCESS_KEY_ID lineinfile:
diff --git a/setup.yml b/setup.yml index 2b5ab1a..052b592 100644 --- a/setup.yml +++ b/setup.yml
@@ -1,79 +1,6 @@ --- -- hosts: localhost - connection: local +- include: control-server.yml - vars: - ansible_config: ~/.ansible - apigee_config: ~/.apigee - workspace: ~/apigee-workspace/opdk-workspace +- include: setup-base.yml - 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 - \ No newline at end of file +- include: setup-ec2.yml \ No newline at end of file