diff options
author | Thomas Wiest <twiest@users.noreply.github.com> | 2015-04-20 17:25:57 -0400 |
---|---|---|
committer | Thomas Wiest <twiest@users.noreply.github.com> | 2015-04-20 17:25:57 -0400 |
commit | 96dd0ab929b7f391eee9b23209aa377537114b72 (patch) | |
tree | d1f9aa5becd04097213fe56aa4982bd35830df10 /playbooks/aws/openshift-cluster/tasks | |
parent | 0722304b2f9c94a2f70054e0a3c7feceaedb195c (diff) | |
parent | dbb252bc04a6488c1fde05dbc325b246fd4a651e (diff) | |
download | openshift-96dd0ab929b7f391eee9b23209aa377537114b72.tar.gz openshift-96dd0ab929b7f391eee9b23209aa377537114b72.tar.bz2 openshift-96dd0ab929b7f391eee9b23209aa377537114b72.tar.xz openshift-96dd0ab929b7f391eee9b23209aa377537114b72.zip |
Merge pull request #139 from detiber/configUpdatesMaster
Massive refactor, deployment-type support, config updates, reduce duplication
Diffstat (limited to 'playbooks/aws/openshift-cluster/tasks')
-rw-r--r-- | playbooks/aws/openshift-cluster/tasks/launch_instances.yml | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/playbooks/aws/openshift-cluster/tasks/launch_instances.yml b/playbooks/aws/openshift-cluster/tasks/launch_instances.yml new file mode 100644 index 000000000..58b4082df --- /dev/null +++ b/playbooks/aws/openshift-cluster/tasks/launch_instances.yml @@ -0,0 +1,69 @@ +--- +# TODO: modify machine_image based on deployment_type +- set_fact: + machine_type: "{{ lookup('env', 'ec2_instance_type') | default('m3.large', true) }}" + machine_image: "{{ lookup('env', 'ec2_ami') | default(deployment_vars[deployment_type].image, true) }}" + machine_region: "{{ lookup('env', 'ec2_region') | default(deployment_vars[deployment_type].region, true) }}" + machine_keypair: "{{ lookup('env', 'ec2_keypair')|default('libra', true) }}" + created_by: "{{ lookup('env', 'LOGNAME')|default(cluster, true) }}" + security_group: "{{ lookup('env', 'ec2_security_group')|default('public', true) }}" + env: "{{ cluster }}" + host_type: "{{ type }}" + env_host_type: "{{ cluster }}-openshift-{{ type }}" + +- name: Launch instance(s) + ec2: + state: present + region: "{{ machine_region }}" + keypair: "{{ machine_keypair }}" + group: "{{ security_group }}" + instance_type: "{{ machine_type }}" + image: "{{ machine_image }}" + count: "{{ instances | oo_len }}" + wait: yes + instance_tags: + created-by: "{{ created_by }}" + env: "{{ env }}" + host-type: "{{ host_type }}" + env-host-type: "{{ env_host_type }}" + deployment-type: "{{ deployment_type }}" + register: ec2 + +- name: Add Name tag to instances + ec2_tag: resource={{ item.1.id }} region={{ machine_region }} state=present + with_together: + - instances + - ec2.instances + args: + tags: + Name: "{{ item.0 }}" + +- set_fact: + instance_groups: tag_created-by_{{ created_by }}, tag_env_{{ env }}, tag_host-type_{{ host_type }}, tag_env-host-type_{{ env_host_type }}, tag_deployment-type_{{ deployment_type }} + +- name: Add new instances groups and variables + add_host: + hostname: "{{ item.0 }}" + ansible_ssh_host: "{{ item.1.dns_name }}" + ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}" + ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}" + groups: "{{ instance_groups }}" + ec2_private_ip_address: "{{ item.1.private_ip }}" + ec2_ip_address: "{{ item.1.public_ip }}" + with_together: + - instances + - ec2.instances + +- name: Wait for ssh + wait_for: "port=22 host={{ item.dns_name }}" + with_items: ec2.instances + +- name: Wait for user setup + command: "ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no -o ConnectTimeout=10 -o UserKnownHostsFile=/dev/null {{ hostvars[item.0].ansible_ssh_user }}@{{ item.1.dns_name }} echo {{ hostvars[item.0].ansible_ssh_user }} user is setup" + register: result + until: result.rc == 0 + retries: 20 + delay: 10 + with_together: + - instances + - ec2.instances |