Commit 2c4dabbd by Sef Kloninger

Merge pull request #854 from edx/sef/edx-west/parameterize-machines-in-playbooks

parameterize machine names in edx-west playbooks -- to edx-west/release
parents d02339a8 ddd57c4d
# Stanford Ansible Configuration Files
This directory has the live playbooks that we use here at Stanford to
maintain our instance of OpenEdX at [class.stanford.edu][c]. We check
it in to this public repo since we think that others might benefit from
seeing how we are configured.
[c]: https://class.stanford.edu/
That said, we haven't documented things in here well, so we have no
expectation that others will be able to make enough sense of this to
give us useful contributions back. Generally a PR affecting files in
here will be ignored / rejected.
This README is a useful proximate place to keep commands. But it is
a public repo so we shouldn't store anything confidential in here.
Other install docs:
- Giulio's install doc [here][1].
[1]: https://docs.google.com/document/d/1ZDx51Jxa-zffyeKvHmTp_tIskLW9D9NRg9NytPTbnrA/edit#heading=h.iggugvghbcpf
## Ansible Commands - Prod
Generally we do installs as the "ubuntu" user. You want to make
sure that the stanford-deploy-20130415 ssh key is in your ssh agent.
ANSIBLE_CONFIG=prod-ansible.cfg ANSIBLE_EC2_INI=prod-ec2.ini ansible-playbook prod-app.yml -e "machine=app4" -u ubuntu -c ssh -i ./ec2.py
Some specifics:
* To do database migrations, include this: ```-e "migrate_db=yes"```. The default
behavior is to not do migrations.
* To hit multiple machines the use this: ```-e "machine=app(1|2|4)"```.
Use multiple separate "-e" options to specify multiple vars on the
command line.
* Usually I do with the ```--list-hosts``` option first to verify that I'm
doing something sane before actually running.
* To install the utility machines, substitute ```prod-worker.yml```. Those
are also parameterized on the take the machine variable (util1, util(1|2),
and so forth).
## Ansible Commands - Stage
Command is:
ANSIBLE_CONFIG=stage-ansible.cfg ANSIBLE_EC2_INI=stage-ec2.ini ansible-playbook stage-app.yml -e "machine=app1" -u ubuntu -c ssh -i ./ec2.py
#- hosts: ~tag_Name_app(1|2)_carn # This uses variable expansion so you can select machine(s) from the command line
- hosts: ~tag_Name_app1_carn # using the -e flag. See README for instructions on how to use.
#- hosts: ~tag_Name_app2_carn - hosts: ~tag_Name_{{machine}}_carn
#- hosts: ~tag_Name_app1_carn_test pre_tasks:
- fail: msg="This playbook only runnable on 'app' machines"
when: "'app' not in machine"
sudo: True sudo: True
vars_prompt:
- name: "migrate_db"
prompt: "Should this playbook run database migrations? (Type 'yes' to run, anything else to skip migrations)"
default: "no"
private: no
vars: vars:
secure_dir: '../../../configuration-secure/ansible' secure_dir: '../../../configuration-secure/ansible'
# this indicates the path to site-specific (with precedence) # this indicates the path to site-specific (with precedence)
......
- name: Basic util setup on carnegie workers - name: Basic util setup on carnegie workers
# this gets all running prod webservers # This uses variable expansion so you can select machine(s) from the command line
# hosts: tag_environment_prod_carn:&tag_function_util # using the -e flag. See README for instructions on how to use.
# or we can get subsets of them by name hosts: ~tag_Name_{{machine}}_carn
# hosts: ~tag_Name_util(10)_carn pre_tasks:
hosts: ~tag_Name_util(1)_carn - fail: msg="This playbook only runnable on 'util' machines"
gather_facts: True when: "'util' not in machine"
sudo: True sudo: True
gather_facts: True
vars: vars:
secure_dir: '../../../edx-secret/ansible' secure_dir: '../../../edx-secret/ansible'
# this indicates the path to site-specific (with precedence) # this indicates the path to site-specific (with precedence)
......
...@@ -9,20 +9,13 @@ ...@@ -9,20 +9,13 @@
# - apt: pkg=libzmq-dev,python-zmq state=present # - apt: pkg=libzmq-dev,python-zmq state=present
# - action: fireball # - action: fireball
# This uses variable expansion so you can select machine(s) from the command line
# this gets all running prod webservers # using the -e flag. See README for instructions on how to use.
#- hosts: tag_environment_prod:&tag_function_webserver - hosts: ~tag_Name_{{machine}}_cme
# or we can get subsets of them by name pre_tasks:
#- hosts: ~tag_Name_app(1|2)_cme - fail: msg="This playbook only runnable on 'app' machines"
- hosts: ~tag_Name_app1_cme when: "'app' not in machine"
#- hosts: ~tag_Name_app2_cme
#- hosts: ~tag_Name_app(1|2)_cme
sudo: True sudo: True
vars_prompt:
- name: "migrate_db"
prompt: "Should this playbook run database migrations? (Type 'yes' to run, anything else to skip migrations)"
default: "no"
private: no
vars: vars:
secure_dir: '../../../edx-secret/ansible' secure_dir: '../../../edx-secret/ansible'
# this indicates the path to site-specific (with precedence) # this indicates the path to site-specific (with precedence)
......
- name: Basic util setup on cme hosts - name: Basic util setup on cme hosts
# this gets all running prod webservers # This uses variable expansion so you can select machine(s) from the command line
# hosts: tag_environment_prod_cme:&tag_function_util # using the -e flag. See README for instructions on how to use.
# or we can get subsets of them by name hosts: ~tag_Name_{{machine}}_cme
hosts: ~tag_Name_util(1)_cme pre_tasks:
- fail: msg="This playbook only runnable on 'util' machines"
when: "'util' not in machine"
sudo: True sudo: True
gather_facts: True gather_facts: True
vars: vars:
......
# this gets all running prod webservers # This uses variable expansion so you can select machine(s) from the command line
#- hosts: tag_environment_prod:&tag_function_webserver # using the -e flag. See README for instructions on how to use.
# or we can get subsets of them by name - hosts: ~tag_Name_{{machine}}_prod
#- hosts: ~tag_Name_app1_prod pre_tasks:
#- hosts: ~tag_Name_app2_prod - fail: msg="This playbook only runnable on 'app' machines"
## this is the test box when: "'app' not in machine"
- hosts: ~tag_Name_app4_prod
#- hosts: ~tag_Name_app(4|1|2)_prod
## you can also do security group, but don't do that
#- hosts: security_group_edx-prod-EdxappServerSecurityGroup-NSKCQTMZIPQB
sudo: True sudo: True
vars_prompt:
- name: "migrate_db"
prompt: "Should this playbook run database migrations? (Type 'yes' to run, anything else to skip migrations)"
default: "no"
private: no
vars: vars:
secure_dir: '../../../configuration-secure/ansible' secure_dir: '../../../configuration-secure/ansible'
# this indicates the path to site-specific (with precedence) # this indicates the path to site-specific (with precedence)
......
- name: Basic util setup on all hosts - name: Basic util setup on all hosts
# For all util machines # This uses variable expansion so you can select machine(s) from the command line
# hosts: tag_environment_prod:&tag_function_util # using the -e flag. See README for instructions on how to use.
# or we can get subsets of them by name hosts: ~tag_Name_{{machine}}_prod
hosts: ~tag_Name_util(1|2)_prod pre_tasks:
- fail: msg="This playbook only runnable on 'util' machines"
when: "'util' not in machine"
sudo: True sudo: True
gather_facts: True gather_facts: True
vars: vars:
......
#- hosts: tag_environment_stage:&tag_function_webserver # This uses variable expansion so you can select machine(s) from the command line
#- hosts: ~tag_Name_app10_stage # using the -e flag. See README for instructions on how to use.
- hosts: ~tag_Name_app1_stage - hosts: ~tag_Name_{{ machine }}_stage
pre_tasks:
- fail: msg="This playbook only runnable on 'app' machines"
when: "'app' not in machine"
sudo: True sudo: True
vars_prompt:
- name: "migrate_db"
prompt: "Should this playbook run database migrations? (Type 'yes' to run, anything else to skip migrations)"
default: "no"
private: no
vars: vars:
not_prod: true not_prod: true
secure_dir: "../../../edx-secret/ansible" secure_dir: "../../../edx-secret/ansible"
...@@ -49,4 +47,3 @@ ...@@ -49,4 +47,3 @@
#- datadog #- datadog
#- splunkforwarder #- splunkforwarder
--- ---
- name: Basic util setup on all hosts - name: Basic util setup on all hosts
#- hosts: tag_environment_stage:&tag_function_util # This uses variable expansion so you can select machine(s) from the command line
hosts: ~tag_Name_util1_stage # using the -e flag. See README for instructions on how to use.
hosts: ~tag_Name_{{machine}}_stage
pre_tasks:
- fail: msg="This playbook only runnable on 'util' machines"
when: "'util' not in machine"
sudo: True sudo: True
gather_facts: True gather_facts: True
vars: vars:
......
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