Commit 84661512 by Feanil Patel

Merge pull request #227 from edx/feanil/provision-vpc

Feanil/provision vpc
parents 365c8e33 8889fd91
...@@ -1506,17 +1506,11 @@ ...@@ -1506,17 +1506,11 @@
"SourceDestCheck":"false", "SourceDestCheck":"false",
"ImageId":{ "ImageId":{
"Fn::FindInMap":[ "Fn::FindInMap":[
"AWSRegionArch2AMI", "AWSNATAMI",
{ {
"Ref":"AWS::Region" "Ref":"AWS::Region"
}, },
{ "AMI"
"Fn::FindInMap":[
"AWSInstanceType2Arch",
"t1.micro",
"Arch"
]
}
] ]
}, },
"SecurityGroupIds":[ "SecurityGroupIds":[
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
- hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_edxapp - hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_edxapp
sudo: True sudo: True
vars_files: vars_files:
- "{{ secure_dir }}/vars/edx_continuous_integration_vars.yml"
- "{{ secure_dir }}/vars/users.yml" - "{{ secure_dir }}/vars/users.yml"
roles: roles:
- common - common
...@@ -13,7 +12,6 @@ ...@@ -13,7 +12,6 @@
- hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_xserver - hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_xserver
sudo: True sudo: True
vars_files: vars_files:
- "{{ secure_dir }}/vars/edx_continuous_integration_vars.yml"
- "{{ secure_dir }}/vars/users.yml" - "{{ secure_dir }}/vars/users.yml"
roles: roles:
- common - common
...@@ -23,7 +21,6 @@ ...@@ -23,7 +21,6 @@
serial: 1 serial: 1
sudo: True sudo: True
vars_files: vars_files:
- "{{ secure_dir }}/vars/edx_continuous_integration_vars.yml"
- "{{ secure_dir }}/vars/users.yml" - "{{ secure_dir }}/vars/users.yml"
roles: roles:
- common - common
...@@ -31,7 +28,6 @@ ...@@ -31,7 +28,6 @@
- hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_xqueue - hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_xqueue
sudo: True sudo: True
vars_files: vars_files:
- "{{ secure_dir }}/vars/edx_continuous_integration_vars.yml"
- "{{ secure_dir }}/vars/users.yml" - "{{ secure_dir }}/vars/users.yml"
roles: roles:
- common - common
......
...@@ -53,3 +53,13 @@ ...@@ -53,3 +53,13 @@
#- maven-plugin.hpi #- maven-plugin.hpi
notify: notify:
- restart Jenkins - restart Jenkins
- name: jenkins | install ssh key for private git repos
copy: >
src="{{jenkins_git_identity_path}}"
dest="{{jenkins_user_home}}/.ssh/id_rsa"
force=yes
owner="{{jenkins_user}}"
group="{{jenkins_user}}"
mode=600
when: c_install_ssh_key is defined
...@@ -6,6 +6,8 @@ jenkins_phantomjs_folder: phantomjs-1.9.1-linux-x86_64 ...@@ -6,6 +6,8 @@ jenkins_phantomjs_folder: phantomjs-1.9.1-linux-x86_64
jenkins_user: "jenkins" jenkins_user: "jenkins"
jenkins_user_home: /home/jenkins jenkins_user_home: /home/jenkins
jenkins_ruby_version: "1.9.3-p448" jenkins_ruby_version: "1.9.3-p448"
jenkins_git_identity_path: "{{secure_dir}}/files/git-identity"
jenkins_debian_pkgs: jenkins_debian_pkgs:
- ruby-bundler - ruby-bundler
- rubygems - rubygems
...@@ -62,4 +64,6 @@ jenkins_plugins: ...@@ -62,4 +64,6 @@ jenkins_plugins:
- tmpcleaner.hpi - tmpcleaner.hpi
- token-macro.hpi - token-macro.hpi
- translation.hpi - translation.hpi
- violations.hpi - violations.hpi
\ No newline at end of file - multiple-scms.hpi
- timestamper.hpi
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
owner={{ rbenv_user }} owner={{ rbenv_user }}
group={{ rbenv_user }} group={{ rbenv_user }}
state=directory state=directory
recurse=yes
- name: rbenv | install build depends - name: rbenv | install build depends
apt: pkg={{ item }} state=present install_recommends=no apt: pkg={{ item }} state=present install_recommends=no
...@@ -179,7 +180,7 @@ ...@@ -179,7 +180,7 @@
- install - install
- name: rbenv | install ruby {{ rbenv_ruby_version }} - name: rbenv | install ruby {{ rbenv_ruby_version }}
shell: "{{ rbenv_user_home }}/.rbenv/bin/rbenv install {{ rbenv_ruby_version }}" shell: "{{ rbenv_user_home }}/.rbenv/bin/rbenv install {{ rbenv_ruby_version }} creates={{rbenv_user_home}}/.rbenv/versions/{{rbenv_ruby_version}}"
when: ruby_installed|failed when: ruby_installed|failed
sudo: true sudo: true
sudo_user: "{{ rbenv_user }}" sudo_user: "{{ rbenv_user }}"
...@@ -191,7 +192,6 @@ ...@@ -191,7 +192,6 @@
shell: "{{rbenv_user_home }}/.rbenv/bin/rbenv global {{ rbenv_ruby_version }}" shell: "{{rbenv_user_home }}/.rbenv/bin/rbenv global {{ rbenv_ruby_version }}"
sudo: true sudo: true
sudo_user: "{{ rbenv_user }}" sudo_user: "{{ rbenv_user }}"
when: ruby_installed|failed
tags: tags:
- ruby - ruby
- install - install
...@@ -208,7 +208,6 @@ ...@@ -208,7 +208,6 @@
shell: "{{rbenv_user_home}}/.rbenv/bin/rbenv rehash" shell: "{{rbenv_user_home}}/.rbenv/bin/rbenv rehash"
sudo: true sudo: true
sudo_user: "{{ rbenv_user }}" sudo_user: "{{ rbenv_user }}"
when: ruby_installed|failed
tags: tags:
- ruby - ruby
- install - install
"""VPC Tools. """VPC Tools.
Usage: Usage:
vpc-tools.py ssh-config vpc <vpc_id> identity-file <identity_file> user <user> vpc-tools.py ssh-config vpc <vpc_id> identity-file <identity_file> user <user> [config-file <config_file>] [strict-host-check <strict_host_check>]
vpc-tools.py (-h --help) vpc-tools.py (-h --help)
vpc-tools.py (-v --version) vpc-tools.py (-v --version)
...@@ -16,6 +16,7 @@ from docopt import docopt ...@@ -16,6 +16,7 @@ from docopt import docopt
VERSION="vpc tools 0.1" VERSION="vpc tools 0.1"
DEFAULT_USER="ubuntu" DEFAULT_USER="ubuntu"
DEFAULT_HOST_CHECK="yes"
JUMPBOX_CONFIG = """ JUMPBOX_CONFIG = """
Host {jump_box} Host {jump_box}
...@@ -23,15 +24,17 @@ JUMPBOX_CONFIG = """ ...@@ -23,15 +24,17 @@ JUMPBOX_CONFIG = """
IdentityFile {identity_file} IdentityFile {identity_file}
ForwardAgent yes ForwardAgent yes
User {user} User {user}
StrictHostKeyChecking {strict_host_check}
""" """
HOST_CONFIG = """ HOST_CONFIG = """
Host {name} Host {name}
ProxyCommand ssh -W %h:%p {jump_box} ProxyCommand ssh {config_file} -W %h:%p {jump_box}
HostName {ip} HostName {ip}
IdentityFile {identity_file} IdentityFile {identity_file}
ForwardAgent yes ForwardAgent yes
User {user} User {user}
StrictHostKeyChecking {strict_host_check}
""" """
...@@ -45,8 +48,21 @@ def _ssh_config(args): ...@@ -45,8 +48,21 @@ def _ssh_config(args):
vpc = boto.connect_vpc() vpc = boto.connect_vpc()
identity_file = args.get("<identity_file>") identity_file = args.get("<identity_file>")
user = args.get("<user>",DEFAULT_USER) user = args.get("<user>")
vpc_id = args.get("<vpc_id>") vpc_id = args.get("<vpc_id>")
config_file = args.get("<config_file>")
strict_host_check = args.get("<strict_host_check>")
if not user:
user = DEFAULT_USER
if not strict_host_check:
strict_host_check = DEFAULT_HOST_CHECK
if config_file:
config_file = "-F {}".format(config_file)
else:
config_file = "nothing"
jump_box = "{vpc_id}-jumpbox".format(vpc_id=vpc_id) jump_box = "{vpc_id}-jumpbox".format(vpc_id=vpc_id)
friendly = "{vpc_id}-{logical_id}-{instance_id}" friendly = "{vpc_id}-{logical_id}-{instance_id}"
...@@ -64,7 +80,8 @@ def _ssh_config(args): ...@@ -64,7 +80,8 @@ def _ssh_config(args):
jump_box=jump_box, jump_box=jump_box,
ip=instance.ip_address, ip=instance.ip_address,
user=user, user=user,
identity_file=identity_file) identity_file=identity_file,
strict_host_check=strict_host_check)
else: else:
print HOST_CONFIG.format( print HOST_CONFIG.format(
...@@ -74,7 +91,9 @@ def _ssh_config(args): ...@@ -74,7 +91,9 @@ def _ssh_config(args):
ip=instance.private_ip_address, ip=instance.private_ip_address,
user=user, user=user,
logical_id=logical_id, logical_id=logical_id,
identity_file=identity_file) identity_file=identity_file,
config_file=config_file,
strict_host_check=strict_host_check)
#duplicating for convenience with ansible #duplicating for convenience with ansible
name = friendly.format(vpc_id=vpc_id, name = friendly.format(vpc_id=vpc_id,
...@@ -87,9 +106,11 @@ def _ssh_config(args): ...@@ -87,9 +106,11 @@ def _ssh_config(args):
ip=instance.private_ip_address, ip=instance.private_ip_address,
user=user, user=user,
logical_id=logical_id, logical_id=logical_id,
identity_file=identity_file) identity_file=identity_file,
config_file=config_file,
strict_host_check=strict_host_check)
if __name__ == '__main__': if __name__ == '__main__':
args = docopt(__doc__, version=VERSION) args = docopt(__doc__, version=VERSION)
dispatch(args) dispatch(args)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment