Commit c7f6e474 by Sef Kloninger

Merge branch 'master' of github.com:edx/configuration into feature/sef/refarch-vpc-dns-ssh

parents ba33e2fb c728e47f
...@@ -39,6 +39,46 @@ version instead of the official v1.1 release._ ...@@ -39,6 +39,46 @@ version instead of the official v1.1 release._
## Organization ## Organization
### Secure vs. Insecure data
As a general policy we want to protect the following data:
* Usernames
* Public keys (keys are ok to be public, but can be used to figure out usernames)
* Hostnames
* Passwords, api keys
The folowing yml files and examples serve as templates that should be overridden with your own
environment specific configuration:
* vars in `secure_example/vars`
* files in `secure_example/files`
Directory structure for the secure repo:
```
ansible
├── files
├── keys
└── vars
```
The same directory structure, required yml files and files are
in the secure_example dir:
```
secure_example/
├── files
├── keys
└── vars
```
The default `secure\_dir` is set in `group\_vars/all` and can be overridden by
adding another file in group_vars that corresponds to a deploy group name.
The directory structure should follow Ansible best practices. The directory structure should follow Ansible best practices.
http://ansible.cc/docs/bestpractices.html http://ansible.cc/docs/bestpractices.html
...@@ -84,8 +124,9 @@ Example users are in the `vars/secure` directory: ...@@ -84,8 +124,9 @@ Example users are in the `vars/secure` directory:
``` ```
cloudformation_templates <-- official edX cloudformation templates cloudformation_templates <-- official edX cloudformation templates
│   └── examples <-- example templates    └── examples <-- example templates
└── playbooks playbooks
└──
edxapp_prod.yml <-- example production environment playbook edxapp_prod.yml <-- example production environment playbook
edxapp_stage.yml <-- example stage environment playbook edxapp_stage.yml <-- example stage environment playbook
edxapp_custom.yml <-- example custom environment playbook edxapp_custom.yml <-- example custom environment playbook
...@@ -108,7 +149,7 @@ cloudformation_templates <-- official edX cloudformation templates ...@@ -108,7 +149,7 @@ cloudformation_templates <-- official edX cloudformation templates
│   └── templates │   └── templates
│   (etc) │   (etc)
└── vars <-- public variable definitions └── vars <-- public variable definitions
└── secure <-- secure variables (example) └── secure_example <-- secure variables (example)
``` ```
......
- hosts: tag_Group_edxapp_custom - hosts: tag_Group_edxapp_custom
vars_files: vars_files:
# using conditional loading to override defaults for site-specific installs # using conditional loading to override defaults for site-specific installs
- ["{{ secure_file_dir }}/edxapp_stage_vars.yml", "vars/secure_default/edxapp_stage_vars.yml"] - "{{ secure_dir }}/vars/edxapp_stage_vars.yml"
- ["{{ secure_file_dir }}/edxapp_custom_vars.yml", "vars/secure_default/edxapp_custom_vars.yml"] - "{{ secure_dir }}/vars/edxapp_custom_vars.yml"
- ["{{ secure_file_dir }}/users.yml", "vars/secure_default/users.yml"] - "{{ secure_dir }}/vars/users.yml"
- ["{{ secure_file_dir }}/edxapp_stage_users.yml", "vars/secure_default/edxapp_stage_users.yml"] - "{{ secure_dir }}/vars/edxapp_stage_users.yml"
roles: roles:
- common - common
- nginx - nginx
......
- hosts: tag_Group_edxapp_prod - hosts: tag_Group_edxapp_prod
vars_files: vars_files:
- ["{{ secure_file_dir }}/edxapp_prod_vars.yml", "vars/secure_default/edxapp_prod_vars.yml"] - "{{ secure_dir }}/vars/edxapp_prod_vars.yml"
- ["{{ secure_file_dir }}/users.yml", "vars/secure_default/users.yml"] - "{{ secure_dir }}/vars/users.yml"
- ["{{ secure_file_dir }}/edxapp_prod_users.yml", "vars/secure_default/edxapp_prod_users.yml"] - "{{ secure_dir }}/vars/edxapp_prod_users.yml"
roles: roles:
- common - common
- nginx - nginx
......
# ansible-playbook -v --user=ubuntu edxapp_rolling_example.yml -i ./ec2.py --private-key=/path/to/deployment.pem # ansible-playbook -v --user=ubuntu edxapp_rolling_example.yml -i ./ec2.py --private-key=/path/to/deployment.pem
- hosts: tag_Group_anothermulti - hosts: tag_Group_anothermulti
serial: 1 serial: 2
vars_files: vars_files:
- ["{{ secure_file_dir }}/edxapp_stage_vars.yml", "vars/secure_default/edxapp_stage_vars.yml"] - "{{ secure_dir }}/vars/edxapp_stage_vars.yml"
- ["{{ secure_file_dir }}/users.yml", "vars/secure_default/users.yml"] - "{{ secure_dir }}/vars/users.yml"
- ["{{ secure_file_dir }}/edxapp_stage_users.yml", "vars/secure_default/edxapp_stage_users.yml"]
pre_tasks: pre_tasks:
- name: Gathering ec2 facts - name: Gathering ec2 facts
ec2_facts: ec2_facts:
...@@ -21,7 +20,7 @@ ...@@ -21,7 +20,7 @@
- common - common
- nginx - nginx
- lms - lms
- ruby # - ruby
post_tasks: post_tasks:
- local_action: command util/elb_reg.py -e {{ ",".join(elbs[ansible_ec2_instance_id]) }} -i {{ ansible_ec2_instance_id }} register - local_action: command util/elb_reg.py -e {{ ",".join(elbs[ansible_ec2_instance_id]) }} -i {{ ansible_ec2_instance_id }} register
# Register will pass in the same elb list and the same instance id # Register will pass in the same elb list and the same instance id
......
- hosts: tag_Group_edxapp_stage - hosts: tag_Group_edxapp_stage
vars_files: vars_files:
- ["{{ secure_file_dir }}/edxapp_stage_vars.yml", "vars/secure_default/edxapp_stage_vars.yml"] - "{{ secure_dir }}/vars/edxapp_stage_vars.yml"
- ["{{ secure_file_dir }}/users.yml", "vars/secure_default/users.yml"] - "{{ secure_dir }}/vars/users.yml"
- ["{{ secure_file_dir }}/edxapp_stage_users.yml", "vars/secure_default/edxapp_stage_users.yml"] - "{{ secure_dir }}/vars/edxapp_stage_users.yml"
roles: roles:
- common - common
- nginx - nginx
......
--- ---
app_base_dir: /opt/wwc app_base_dir: /opt/wwc
# this path is relative to the playbook dir
secure_dir: 'secure_example'
venv_dir: /opt/edx venv_dir: /opt/edx
#where are the secure files on the deploying machine?
secure_file_dir: ../../edx-secret/ansible/vars/
---
# this path is relative to the playbook dir
#secure_dir: '../../configuration-secure/ansible'
--- ---
edxapp_prod: true edxapp_prod: true
secure_dir: '../../configuration-secure/ansible'
\ No newline at end of file
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
user: name={{ item.user }} append=yes groups={{ "adm,edx,"+",".join(item.groups) }} shell=/bin/bash user: name={{ item.user }} append=yes groups={{ "adm,edx,"+",".join(item.groups) }} shell=/bin/bash
sudo: True sudo: True
with_items: admin_users with_items: admin_users
when: admin_users is defined
tags: tags:
- users - users
- admin_users - admin_users
- name: Copying ssh keys for admin users - name: Copying ssh keys for admin users
authorized_key: user={{ item.user }} key="{{ lookup('file', item.path) }}" authorized_key: user={{ item.user }} key="{{lookup('file', item.path)}}"
sudo: True sudo: True
with_items: admin_keys with_items: admin_keys
tags: tags:
...@@ -20,11 +21,13 @@ ...@@ -20,11 +21,13 @@
user: name={{ item.user }} groups={{ ",".join(item.groups) }} shell=/bin/bash user: name={{ item.user }} groups={{ ",".join(item.groups) }} shell=/bin/bash
sudo: True sudo: True
with_items: env_users with_items: env_users
when: env_users is defined
tags: tags:
- users - users
- name: Copying ssh keys for env users - name: Copying ssh keys for env users
authorized_key: user={{ item.user }} key="{{ lookup('file', item.path) }}" authorized_key: user={{ item.user }} key="{{lookup('file', item.path)}}"
sudo: True sudo: True
with_items: env_keys with_items: env_keys
when: env_keys is defined
tags: tags:
- users - users
#!/bin/sh
exec /usr/bin/ssh -o StrictHostKeyChecking=no -i /etc/git-identity "$@"
...@@ -20,18 +20,19 @@ ...@@ -20,18 +20,19 @@
# Install ssh keys for ubuntu account to be able to check out from mitx # Install ssh keys for ubuntu account to be able to check out from mitx
# Temprory behavior, not needed after June 1. Perhaps still useful as a recipe. # Temprory behavior, not needed after June 1. Perhaps still useful as a recipe.
# {{ secure_dir }} is relative to the top-level playbooks dir so there is some
# ugly relative pathing here
- name: install read-only ssh key for mitx repo (private) - name: install read-only ssh key for mitx repo (private)
copy: src={{ secure_file_dir }}/ssh_deploy_private dest=/home/ubuntu/.ssh/id_rsa force=yes owner=ubuntu group=ubuntu mode=600 copy: src=../../../{{ secure_dir }}/files/git-identity dest=/etc/git-identity force=yes owner=root group=root mode=644
tags: sudo: True
- lms
- cms
- name: install read-only ssh key for mitx repo (public)
copy: src={{ secure_file_dir }}/ssh_deploy_public dest=/home/ubuntu/.ssh/id_rsa.pub force=yes owner=ubuntu group=ubuntu mode=644
tags: tags:
- lms - lms
- cms - cms
- name: install read-only ssh key for mitx repo (host github known)
copy: src={{ secure_file_dir }}/ssh_deploy_known_hosts dest=/home/ubuntu/.ssh/known_hosts force=yes owner=ubuntu group=ubuntu mode=600 - name: upload ssh script
copy: src=git_ssh.sh dest=/tmp/git_ssh.sh force=yes owner=root group=root mode=755
sudo: True
tags: tags:
- lms - lms
- cms - cms
...@@ -39,7 +40,6 @@ ...@@ -39,7 +40,6 @@
# Check out mitx repo to $app_base_dir # Check out mitx repo to $app_base_dir
- name: set permissions on $app_base_dir sgid for edx - name: set permissions on $app_base_dir sgid for edx
file: path=$app_base_dir owner=root group=edx mode=2775 state=directory file: path=$app_base_dir owner=root group=edx mode=2775 state=directory
file: path=$app_base_dir owner=ubuntu group=edx mode=2775 state=directory
sudo: True sudo: True
tags: tags:
- lms - lms
...@@ -52,6 +52,8 @@ ...@@ -52,6 +52,8 @@
- cms - cms
- name: git checkout mitx repo into $app_base_dir - name: git checkout mitx repo into $app_base_dir
git: dest={{app_base_dir}}/mitx repo={{lms_source_repo}} git: dest={{app_base_dir}}/mitx repo={{lms_source_repo}}
environment:
GIT_SSH: /tmp/git_ssh.sh
tags: tags:
- lms - lms
- cms - cms
......
...@@ -10,4 +10,4 @@ admin_users: ...@@ -10,4 +10,4 @@ admin_users:
admin_keys: admin_keys:
- user: joe - user: joe
path: keys/joe.key path: "{{ secure_dir }}/keys/joe.key"
# Ignore git deployment ssh keys, which should never be checked into source
# control.
ssh_deploy*
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