Skip to content

Instantly share code, notes, and snippets.

@electroniceagle
Created October 18, 2013 18:05
Show Gist options
  • Save electroniceagle/7045599 to your computer and use it in GitHub Desktop.
Save electroniceagle/7045599 to your computer and use it in GitHub Desktop.
setting up a master slave configuration on ec2, lineinfile currently failing
#!/usr/bin/env ansible-playbook
# Borrowed heavily from:
# https://github.com/64BitsPerMinute/ansible-elasticsearch-ec2-example/blob/master/deploy_elasticsearch.yml
---
- name: Provision the system modeler grid
hosts: localhost
gather_facts: False
connection: local
vars:
ec2_access_key: '{{ nimbis_wolfram_aws_access_key }}'
ec2_secret_key: '{{ nimbis_wolfram_aws_secret_key }}'
keypair: wolfram
region: us-east-1
head_ami: ami-71772518
head_count: 1
head_group: system-modeler-head
head_tag: system-modeler-head
head_type: c1.medium
worker_ami: ami-71772518
worker_count: 3
worker_group: system-modeler-grid
worker_tag: system-modeler-worker
worker_type: t1.micro
tasks:
- name: Launch worker instances
ec2: >
ec2_access_key={{ ec2_access_key }}
ec2_secret_key={{ ec2_secret_key }}
count={{ worker_count }}
group={{ worker_group }}
image={{ worker_ami }}
instance_type={{ worker_type }}
keypair={{ keypair }}
region={{ region }}
wait=yes
register: workers
- name: Launch head instance
ec2: >
ec2_access_key={{ ec2_access_key }}
ec2_secret_key={{ ec2_secret_key }}
count=1
group={{ head_group }}
image={{ head_ami }}
instance_type={{ head_type }}
keypair={{ keypair }}
region={{ region }}
wait=yes
register: heads
- name: Tag worker instances
ec2_tag: >
ec2_access_key={{ ec2_access_key }}
ec2_secret_key={{ ec2_secret_key }}
region={{ region }}
resource={{ item.id }}
state=present
with_items: workers.instances
args:
tags:
Name: '{{ worker_tag }}'
GridMathematica: True
SystemModeler: True
Ansible: True
- name: Tag head instance
ec2_tag: >
ec2_access_key={{ ec2_access_key }}
ec2_secret_key={{ ec2_secret_key }}
region={{ region }}
resource={{ item.id }}
state=present
with_items: heads.instances
args:
tags:
Name: '{{ head_tag }}'
GridMathematica: True
SystemModeler: True
Ansible: True
- name: Add workers to worker_hosts group
add_host: >
groups=worker_hosts
name={{ item.public_dns_name }}
private_dns_name={{ item.private_dns_name }}
with_items: workers.instances
- name: Add head to head_hosts group
add_host: >
groups=head_hosts
name={{ item.public_dns_name }}
ec2={{ item }}
with_items: heads.instances
- name: Wait for SSH to be available
wait_for: >
host={{ item.public_dns_name }} port=22
with_items: workers.instances + heads.instances
- name: setup worker host file on head host
hosts: head_hosts
sudo: True
tasks:
- name: create a host file on the login nodes
lineinfile: >
dest=/etc/grid
line={{ item.private_dns_name }}
with_items: groups.worker_hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment