Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
68e1fef0
Commit
68e1fef0
authored
Mar 31, 2016
by
Brian Beggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ansible playbook to launch an instance for the release-pipeline work.
parent
2fea6a16
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
0 deletions
+102
-0
playbooks/continuous_delivery/launch_instance.yml
+93
-0
playbooks/continuous_delivery/roles
+2
-0
playbooks/continuous_delivery/templates/local/key.pem.j2
+2
-0
playbooks/continuous_delivery/templates/local/launch_template.yml.j2
+5
-0
No files found.
playbooks/continuous_delivery/launch_instance.yml
0 → 100644
View file @
68e1fef0
# This playbook will launch an ec2 instance in a VPC.
# This instance will have an autogenerated key.
#
# required variables for this playbook:
# - ec2_subnet_id - Subnet to bring up the ec2 instance
# - base_ami_id - The base base AMI-ID
# - ec2_vpc_subnet_id - The Subnet ID to bring up the instance
# - ec2_security_group_id - The security group ID to use
#
# Other Variables:
# - ec2_region - The region the server should be brought up in
# - ec2_instance_type - The instance type to use
# - ebs_volume_size - Size in GB for the root volume
# - ec2_timeout - Time in seconds to wait for an ec2 instance become available
# - ec2_assign_public_ip - (yes/no) should the instance have a public IP address?
#
# This playbook generates a directory with 2 artifact files:
# - launch_template.yml - A yaml file with information such as the instance ID and internal IP address of the instance launched
# - key.pem - The private key file for the newly generated keypair
#
# Example command line to run this playbook:
# ansible-playbook -i "localhost," -c local -e @overrides.yml launch_instance.yml
#
-
hosts
:
all
vars
:
artifact_path
:
/tmp/ansible-runtime
ec2_region
:
us-east-1
ec2_instance_type
:
t2.medium
ebs_volume_size
:
8
ec2_timeout
:
500
ec2_assign_public_ip
:
no
gather_facts
:
False
connection
:
local
tasks
:
-
name
:
Generate UUID for keypair
command
:
cat /proc/sys/kernel/random/uuid
register
:
unique_key_name
-
name
:
Generate ec2 keypair to use for this instance
ec2_key
:
name
:
"
{{
unique_key_name.stdout
}}"
region
:
"
{{
ec2_region
}}"
register
:
ssh_key_register
-
name
:
Ensure artifact directory exists
file
:
path
:
"
{{
artifact_path
}}/{{
unique_key_name.stdout
}}/"
state
:
directory
force
:
yes
-
name
:
Launch EC2 instance
ec2
:
instance_tags
:
{
"
Name"
:
"
gocd
automation
run
--
{{
unique_key_name.stdout
}}"
}
region
:
"
{{
ec2_region
}}"
key_name
:
"
{{
unique_key_name.stdout
}}"
instance_type
:
"
{{
ec2_instance_type
}}"
image
:
"
{{
base_ami_id
}}"
wait
:
yes
group_id
:
"
{{
ec2_security_group_id
}}"
count
:
1
vpc_subnet_id
:
"
{{
ec2_vpc_subnet_id
}}"
assign_public_ip
:
"
{{
ec2_assign_public_ip
}}"
volumes
:
-
device_name
:
/dev/xvda
volume_type
:
standard
volume_size
:
"
{{
ebs_volume_size
}}"
wait
:
yes
wait_timeout
:
"
{{
ec2_timeout
}}"
register
:
ec2_instance_register
-
name
:
Wait for SSH to come up
wait_for
:
host
:
"
{{
ec2_instance_register.instances[0].private_ip
}}"
port
:
22
delay
:
60
timeout
:
"
{{
ec2_timeout
}}"
state
:
started
-
name
:
Generate artifact for jobs down stream
template
:
src
:
templates/local/launch_template.yml.j2
dest
:
"
{{
artifact_path
}}/{{
unique_key_name.stdout
}}/launch_info.yml"
mode
:
0600
-
name
:
Generate key material artifact for jobs down stream
template
:
src
:
templates/local/key.pem.j2
dest
:
"
{{
artifact_path
}}/{{
unique_key_name.stdout
}}/key.pem"
mode
:
0600
playbooks/continuous_delivery/roles
0 → 120000
View file @
68e1fef0
../roles
\ No newline at end of file
playbooks/continuous_delivery/templates/local/key.pem.j2
0 → 100644
View file @
68e1fef0
{{ ssh_key_register.key.private_key }}
\ No newline at end of file
playbooks/continuous_delivery/templates/local/launch_template.yml.j2
0 → 100644
View file @
68e1fef0
keypair_id: {{ unique_key_name.stdout }}
key_material_file: {{ artifact_path }}/{{ unique_key_name.stdout }}/key.pem
instance_id: {{ ec2_instance_register.instances[0].id }}
instance_ip: {{ ec2_instance_register.instances[0].private_ip }}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment