Commit 94699a64 by Ben Patterson

harprofiler ami creation via packer.

TE-583
parent 49b3882e
......@@ -11,3 +11,4 @@ harprofiler_github_url: https://github.com/edx/harprofiler
harprofiler_version: master
harprofiler_dir: /edx/app/harprofiler
harprofiler_venv_dir: "{{ harprofiler_dir }}/venvs/harprofiler"
harprofiler_validation_script: validate_harprofiler_install.sh
......@@ -38,3 +38,17 @@
regexp="browsermob_dir"
line="browsermob_dir: /usr/local"
state=present
- name: create validation shell script
template:
owner: "{{ harprofiler_user }}"
src: validate_harprofiler_install.sh.j2
dest: "{{ harprofiler_dir }}/{{ harprofiler_validation_script }}"
mode: 0755
sudo_user: "{{ harprofiler_user }}"
- name: test install
shell: >
./{{ harprofiler_validation_script }} chdir={{ harprofiler_dir }}
sudo_user: "{{ harprofiler_user }}"
#!/usr/bin/env bash
# This script confirms that harprofiler can successfully run on the
# target machine.
source {{ harprofiler_venv_dir }}/bin/activate
cd {{ harprofiler_dir }}
python harprofiler.py
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"playbook_remote_dir": "/tmp/packer-edx-playbooks",
"ami": "{{env `HARPROFILER_BASE_AMI`}}"
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "{{user `ami`}}",
"instance_type": "m1.small",
"ssh_username": "ubuntu",
"ami_name": "harprofiler-{{isotime | clean_ami_name}}"
}],
"provisioners": [{
"type": "shell",
"inline": ["rm -rf {{user `playbook_remote_dir`}}"]
}, {
"type": "file",
"source": "../../playbooks",
"destination": "{{user `playbook_remote_dir`}}"
}, {
"type": "file",
"source": "../../requirements.txt",
"destination": "{{user `playbook_remote_dir`}}/requirements.txt"
}, {
"type": "shell",
"inline": ["cd {{user `playbook_remote_dir`}}",
"virtualenv packer-venv",
". packer-venv/bin/activate",
"pip install -q -r requirements.txt",
"echo 'localhost' > inventory.ini",
"ansible-playbook run_role.yml -i inventory.ini -c local -e role=harprofiler -vvvv"]
}]
}
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