Skip to content

Instantly share code, notes, and snippets.

@russmckendrick
Last active August 29, 2015 14:11
Show Gist options
  • Save russmckendrick/874b67126f2564be64e8 to your computer and use it in GitHub Desktop.
Save russmckendrick/874b67126f2564be64e8 to your computer and use it in GitHub Desktop.
- name: install ntp
yum: pkg=ntp state=installed
- name: check ntpd service is stopped
shell: "service ntpd status | grep -q stopped; echo $?"
register: result
- name: ntpdate
command: ntpdate 0.uk.pool.ntp.org
when: result.stdout == "0"
- name: ntp config file
template: src=roles/common/templates/ntp.conf.j2 dest=/etc/ntp.conf owner=root group=root mode=0644
notify:
- restart ntpd
- name: start ntpd service
service: name=ntpd state=started enabled=yes
---
#Create and configure the VPC
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- group_vars/aws-creds.yml
- group_vars/all.yml
tasks:
- name: Include the variables specific to the vpc
include_vars: envs/{{ environ| default("dev") }}.yml
- name: Create the VPC
local_action:
module: ec2_vpc
state: present
region: "{{ ec2_region }}"
ec2_access_key: "{{ ec2_access_key }}"
ec2_secret_key: "{{ ec2_secret_key }}"
cidr_block: "{{ vpc_cidr_block }}"
subnets: "{{ vpc_subnets }}"
internet_gateway: "{{ vpc_internet_gateway|string }}"
route_tables: "{{ vpc_route_tables }}"
resource_tags: { "Environment":"dev", "Name":"Testing" }
wait: true
register: vpc
- name: Create a list subnet IDs
template: src=templates/subnet_id.j2 dest=/tmp/subnet_id
- name: Get the contents of subnet mapping file and set it as a fact
set_fact:
subnet_maps: "{{ lookup('file', '/tmp/subnet_id') }}"
- name: Create the security group for the VPC
ec2_group:
name: "{{ item.name }}"
description: "{{ item.desc }}"
vpc_id: "{{ vpc.vpc_id }}"
region: "{{ ec2_region }}"
ec2_access_key: "{{ ec2_access_key }}"
ec2_secret_key: "{{ ec2_secret_key }}"
rules: "{{ item.rules }}"
with_items: security_groups
- name: Create the Load Balancer
local_action:
module: ec2_elb_lb
state: present
name: "{{ elb_name }}"
region: "{{ ec2_region }}"
subnets: "{{ subnet_maps | list }}"
cross_az_load_balancing: "yes"
purge_subnets: yes
listeners:
- protocol: http
load_balancer_port: 80
instance_port: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment