Commit 1907f9f1 by Stu Young Committed by GitHub

Merge pull request #3441 from edx/estute/add-bootstrap-script-to-jenkins-packer-scripts

update packer scripts to use ansible bootstrap script
parents 3bf0219d 5d0c2216
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}", "aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}", "aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"playbook_remote_dir": "/tmp/packer-edx-playbooks", "playbook_remote_dir": "/tmp/packer-edx-playbooks",
"ami": "{{env `HARPROFILER_BASE_AMI`}}" "venv_dir": "/edx/app/edx_ansible/venvs/edx_ansible",
"ami": "{{env `HARPROFILER_BASE_AMI`}}",
"delete_or_keep": "{{env `DELETE_OR_KEEP_AMI`}}"
}, },
"builders": [{ "builders": [{
"type": "amazon-ebs", "type": "amazon-ebs",
...@@ -13,30 +15,32 @@ ...@@ -13,30 +15,32 @@
"source_ami": "{{user `ami`}}", "source_ami": "{{user `ami`}}",
"instance_type": "m1.small", "instance_type": "m1.small",
"ssh_username": "ubuntu", "ssh_username": "ubuntu",
"ami_name": "harprofiler-{{isotime | clean_ami_name}}" "ami_name": "harprofiler-{{isotime | clean_ami_name}}",
"tags": {
"delete_or_keep": "{{user `delete_or_keep`}}"
}
}], }],
"provisioners": [{ "provisioners": [{
"type": "shell", "type": "shell",
"inline": ["rm -rf {{user `playbook_remote_dir`}}"] "inline": ["rm -rf {{user `playbook_remote_dir`}}",
"mkdir {{user `playbook_remote_dir`}}"]
}, { }, {
"type": "file", "type": "file",
"source": "../../playbooks", "source": "../../util/install/ansible-bootstrap.sh",
"destination": "{{user `playbook_remote_dir`}}" "destination": "{{user `playbook_remote_dir`}}/ansible-bootstrap.sh"
}, {
"type": "file",
"source": "../../requirements.txt",
"destination": "{{user `playbook_remote_dir`}}/requirements.txt"
}, {
"type": "file",
"source": "../../github.txt",
"destination": "{{user `playbook_remote_dir`}}/github.txt"
}, { }, {
"type": "shell", "type": "shell",
"inline": ["cd {{user `playbook_remote_dir`}}", "inline": ["cd {{user `playbook_remote_dir`}}",
"virtualenv packer-venv", "export CONFIGURATION_VERSION='{{user `remote_branch`}}'",
". packer-venv/bin/activate", "sudo bash ./ansible-bootstrap.sh" ]
"pip install -q -r requirements.txt", }, {
"echo 'localhost' > inventory.ini", "type": "ansible-local",
"ansible-playbook run_role.yml -i inventory.ini -c local -e role=harprofiler -vvvv"] "playbook_file": "../../playbooks/edx-east/harprofiler.yml",
"playbook_dir": "../../playbooks",
"command": ". {{user `venv_dir`}}/bin/activate && ansible-playbook",
"inventory_groups": "harprofiler_worker",
"extra_arguments": [
"-vvv"
]
}] }]
} }
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}", "aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}", "aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"playbook_remote_dir": "/tmp/packer-edx-playbooks", "playbook_remote_dir": "/tmp/packer-edx-playbooks",
"venv_dir": "/edx/app/edx_ansible/venvs/edx_ansible",
"ami": "{{env `JENKINS_WORKER_AMI`}}", "ami": "{{env `JENKINS_WORKER_AMI`}}",
"test_platform_version": "{{env `TEST_PLATFORM_VERSION`}}", "test_platform_version": "{{env `TEST_PLATFORM_VERSION`}}",
"delete_or_keep": "{{env `DELETE_OR_KEEP_AMI`}}" "delete_or_keep": "{{env `DELETE_OR_KEEP_AMI`}}",
"remote_branch": "{{env `REMOTE_BRANCH`}}"
}, },
"builders": [{ "builders": [{
"type": "amazon-ebs", "type": "amazon-ebs",
...@@ -28,65 +30,29 @@ ...@@ -28,65 +30,29 @@
"inline": ["rm -rf {{user `playbook_remote_dir`}}", "inline": ["rm -rf {{user `playbook_remote_dir`}}",
"mkdir {{user `playbook_remote_dir`}}"] "mkdir {{user `playbook_remote_dir`}}"]
}, { }, {
"type": "file",
"source": "../../playbooks/run_role.yml",
"destination": "{{user `playbook_remote_dir`}}/run_role.yml"
}, {
"type": "file", "type": "file",
"source": "../../playbooks/roles", "source": "../../util/install/ansible-bootstrap.sh",
"destination": "{{user `playbook_remote_dir`}}/roles" "destination": "{{user `playbook_remote_dir`}}/ansible-bootstrap.sh"
}, {
"type": "file",
"source": "../../playbooks/edx-east",
"destination": "{{user `playbook_remote_dir`}}/edx-east"
}, {
"type": "file",
"source": "../../requirements.txt",
"destination": "{{user `playbook_remote_dir`}}/requirements.txt"
}, {
"type": "file",
"source": "../../github.txt",
"destination": "{{user `playbook_remote_dir`}}/github.txt"
}, {
"type": "shell",
"inline": ["sudo add-apt-repository ppa:git-core/ppa -y"]
}, {
"type": "shell",
"inline": ["sudo apt-get update"]
}, {
"type": "shell",
"inline": ["sudo apt-get -y install git-core"]
}, {
"type": "shell",
"inline": ["sudo apt-get -y install libmysqlclient-dev"]
}, { }, {
"type": "shell", "type": "shell",
"inline": ["cd {{user `playbook_remote_dir`}}", "inline": ["cd {{user `playbook_remote_dir`}}",
"virtualenv packer-venv", "export CONFIGURATION_VERSION='{{user `remote_branch`}}'",
". packer-venv/bin/activate", "sudo bash ./ansible-bootstrap.sh" ]
"pip install -q -r requirements.txt"]
}, { }, {
"type": "ansible-local", "type": "ansible-local",
"playbook_file": "../../playbooks/edx-east/jenkins_worker.yml", "playbook_file": "../../playbooks/edx-east/jenkins_worker.yml",
"playbook_dir": "../../playbooks", "playbook_dir": "../../playbooks",
"command": "source {{user `playbook_remote_dir`}}/packer-venv/bin/activate && ansible-playbook", "command": ". {{user `venv_dir`}}/bin/activate && ansible-playbook",
"inventory_groups": "jenkins_worker", "inventory_groups": "jenkins_worker",
"extra_arguments": [ "extra_arguments": [
"-e \"jenkins_edx_platform_version={{user `test_platform_version`}}\"", "-e \"jenkins_edx_platform_version={{user `test_platform_version`}}\"",
"-vvv" "-vvv"
] ]
}, { }, {
"type": "shell",
"inline": ["cd {{user `playbook_remote_dir`}}",
"rm -rf packer-venv",
"virtualenv packer-venv",
". packer-venv/bin/activate",
"pip install -q -r requirements.txt"]
}, {
"type": "ansible-local", "type": "ansible-local",
"playbook_file": "../../playbooks/run_role.yml", "playbook_file": "../../playbooks/run_role.yml",
"playbook_dir": "../../playbooks", "playbook_dir": "../../playbooks",
"command": "source {{user `playbook_remote_dir`}}/packer-venv/bin/activate && ansible-playbook", "command": ". {{user `venv_dir`}}/bin/activate && ansible-playbook",
"inventory_groups": "jenkins_worker", "inventory_groups": "jenkins_worker",
"extra_arguments": [ "extra_arguments": [
"-e \"role=test_build_server test_edx_platform_version={{user `test_platform_version`}}\"", "-e \"role=test_build_server test_edx_platform_version={{user `test_platform_version`}}\"",
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}", "aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}", "aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"playbook_remote_dir": "/tmp/packer-edx-playbooks", "playbook_remote_dir": "/tmp/packer-edx-playbooks",
"venv_dir": "/edx/app/edx_ansible/venvs/edx_ansible",
"ami": "{{env `JENKINS_WORKER_AMI`}}", "ami": "{{env `JENKINS_WORKER_AMI`}}",
"delete_or_keep": "{{env `DELETE_OR_KEEP_AMI`}}", "delete_or_keep": "{{env `DELETE_OR_KEEP_AMI`}}",
"remote_branch": "{{env `REMOTE_BRANCH`}}" "remote_branch": "{{env `REMOTE_BRANCH`}}"
...@@ -29,18 +30,6 @@ ...@@ -29,18 +30,6 @@
"mkdir {{user `playbook_remote_dir`}}"] "mkdir {{user `playbook_remote_dir`}}"]
}, { }, {
"type": "file", "type": "file",
"source": "../../playbooks/run_role.yml",
"destination": "{{user `playbook_remote_dir`}}/run_role.yml"
}, {
"type": "file",
"source": "../../playbooks/roles",
"destination": "{{user `playbook_remote_dir`}}/roles"
}, {
"type": "file",
"source": "../../playbooks/edx-east",
"destination": "{{user `playbook_remote_dir`}}/edx-east"
}, {
"type": "file",
"source": "../../util/install/ansible-bootstrap.sh", "source": "../../util/install/ansible-bootstrap.sh",
"destination": "{{user `playbook_remote_dir`}}/ansible-bootstrap.sh" "destination": "{{user `playbook_remote_dir`}}/ansible-bootstrap.sh"
}, { }, {
...@@ -52,7 +41,7 @@ ...@@ -52,7 +41,7 @@
"type": "ansible-local", "type": "ansible-local",
"playbook_file": "../../playbooks/edx-east/jenkins_worker_android.yml", "playbook_file": "../../playbooks/edx-east/jenkins_worker_android.yml",
"playbook_dir": "../../playbooks", "playbook_dir": "../../playbooks",
"command": "source /edx/app/edx_ansible/venvs/edx_ansible/bin/activate && ansible-playbook", "command": ". {{user `venv_dir`}}/bin/activate && ansible-playbook",
"inventory_groups": "jenkins_worker", "inventory_groups": "jenkins_worker",
"extra_arguments": [ "-vvv" ] "extra_arguments": [ "-vvv" ]
}] }]
......
...@@ -3,8 +3,11 @@ ...@@ -3,8 +3,11 @@
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}", "aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}", "aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"playbook_remote_dir": "/tmp/packer-edx-playbooks", "playbook_remote_dir": "/tmp/packer-edx-playbooks",
"venv_dir": "/edx/app/edx_ansible/venvs/edx_ansible",
"ami": "{{env `JENKINS_WORKER_AMI`}}", "ami": "{{env `JENKINS_WORKER_AMI`}}",
"test_platform_version": "{{env `TEST_PLATFORM_VERSION`}}" "test_platform_version": "{{env `TEST_PLATFORM_VERSION`}}",
"delete_or_keep": "{{env `DELETE_OR_KEEP_AMI`}}",
"remote_branch": "{{env `REMOTE_BRANCH`}}"
}, },
"builders": [{ "builders": [{
"type": "amazon-ebs", "type": "amazon-ebs",
...@@ -17,58 +20,32 @@ ...@@ -17,58 +20,32 @@
"ssh_username": "ubuntu", "ssh_username": "ubuntu",
"ami_description": "jenkins worker", "ami_description": "jenkins worker",
"iam_instance_profile": "jenkins-worker", "iam_instance_profile": "jenkins-worker",
"security_group_id": "sg-75af5e18" "security_group_id": "sg-75af5e18",
"tags": {
"delete_or_keep": "{{user `delete_or_keep`}}"
}
}], }],
"provisioners": [{ "provisioners": [{
"type": "shell", "type": "shell",
"inline": ["rm -rf {{user `playbook_remote_dir`}}", "inline": ["rm -rf {{user `playbook_remote_dir`}}",
"mkdir {{user `playbook_remote_dir`}}"] "mkdir {{user `playbook_remote_dir`}}"]
}, { }, {
"type": "file",
"source": "../../playbooks/run_role.yml",
"destination": "{{user `playbook_remote_dir`}}/run_role.yml"
}, {
"type": "file",
"source": "../../playbooks/roles",
"destination": "{{user `playbook_remote_dir`}}/roles"
}, {
"type": "file",
"source": "../../playbooks/edx-east",
"destination": "{{user `playbook_remote_dir`}}/edx-east"
}, {
"type": "file", "type": "file",
"source": "../../requirements.txt", "source": "../../util/install/ansible-bootstrap.sh",
"destination": "{{user `playbook_remote_dir`}}/requirements.txt" "destination": "{{user `playbook_remote_dir`}}/ansible-bootstrap.sh"
}, {
"type": "file",
"source": "../../github.txt",
"destination": "{{user `playbook_remote_dir`}}/github.txt"
}, {
"type": "shell",
"inline": ["sudo add-apt-repository ppa:git-core/ppa -y"]
}, {
"type": "shell",
"inline": ["sudo apt-get update"]
}, {
"type": "shell",
"inline": ["sudo apt-get -y install git-core"]
}, {
"type": "shell",
"inline": ["sudo apt-get -y install libmysqlclient-dev"]
}, { }, {
"type": "shell", "type": "shell",
"inline": ["cd {{user `playbook_remote_dir`}}", "inline": ["cd {{user `playbook_remote_dir`}}",
"virtualenv packer-venv", "export CONFIGURATION_VERSION='{{user `remote_branch`}}'",
". packer-venv/bin/activate", "sudo bash ./ansible-bootstrap.sh" ]
"pip install -q -r requirements.txt"]
}, { }, {
"type": "ansible-local", "type": "ansible-local",
"playbook_file": "../../playbooks/edx-east/jenkins_worker.yml", "playbook_file": "../../playbooks/edx-east/jenkins_worker.yml",
"playbook_dir": "../../playbooks", "playbook_dir": "../../playbooks",
"command": "source {{user `playbook_remote_dir`}}/packer-venv/bin/activate && ansible-playbook", "command": ". {{user `venv_dir`}}/bin/activate && ansible-playbook",
"inventory_groups": "jenkins_worker", "inventory_groups": "jenkins_worker",
"extra_arguments": [ "extra_arguments": [
"-vvv" "-vvv"
] ]
}] }]
} }
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}", "aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}", "aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"playbook_remote_dir": "/tmp/packer-edx-playbooks", "playbook_remote_dir": "/tmp/packer-edx-playbooks",
"ami": "{{env `JENKINS_WORKER_AMI`}}" "venv_dir": "/edx/app/edx_ansible/venvs/edx_ansible",
"ami": "{{env `JENKINS_WORKER_AMI`}}",
"delete_or_keep": "{{env `DELETE_OR_KEEP_AMI`}}",
"remote_branch": "{{env `REMOTE_BRANCH`}}"
}, },
"builders": [{ "builders": [{
"type": "amazon-ebs", "type": "amazon-ebs",
...@@ -16,49 +19,32 @@ ...@@ -16,49 +19,32 @@
"ssh_username": "ubuntu", "ssh_username": "ubuntu",
"ami_description": "jenkins worker sitespeedio", "ami_description": "jenkins worker sitespeedio",
"iam_instance_profile": "jenkins-worker", "iam_instance_profile": "jenkins-worker",
"security_group_id": "sg-75af5e18" "security_group_id": "sg-75af5e18",
"tags": {
"delete_or_keep": "{{user `delete_or_keep`}}"
}
}], }],
"provisioners": [{ "provisioners": [{
"type": "shell", "type": "shell",
"inline": ["rm -rf {{user `playbook_remote_dir`}}", "inline": ["rm -rf {{user `playbook_remote_dir`}}",
"mkdir {{user `playbook_remote_dir`}}"] "mkdir {{user `playbook_remote_dir`}}"]
}, { }, {
"type": "file",
"source": "../../playbooks/run_role.yml",
"destination": "{{user `playbook_remote_dir`}}/run_role.yml"
}, {
"type": "file",
"source": "../../playbooks/roles",
"destination": "{{user `playbook_remote_dir`}}/roles"
}, {
"type": "file",
"source": "../../playbooks/edx-east",
"destination": "{{user `playbook_remote_dir`}}/edx-east"
}, {
"type": "file",
"source": "../../requirements.txt",
"destination": "{{user `playbook_remote_dir`}}/requirements.txt"
}, {
"type": "file", "type": "file",
"source": "../../github.txt", "source": "../../util/install/ansible-bootstrap.sh",
"destination": "{{user `playbook_remote_dir`}}/github.txt" "destination": "{{user `playbook_remote_dir`}}/ansible-bootstrap.sh"
}, {
"type": "shell",
"inline": ["sudo add-apt-repository ppa:git-core/ppa -y"]
}, {
"type": "shell",
"inline": ["sudo apt-get update"]
}, {
"type": "shell",
"inline": ["sudo apt-get -y install git-core"]
}, { }, {
"type": "shell", "type": "shell",
"inline": ["cd {{user `playbook_remote_dir`}}", "inline": ["cd {{user `playbook_remote_dir`}}",
"virtualenv packer-venv", "export CONFIGURATION_VERSION='{{user `remote_branch`}}'",
". packer-venv/bin/activate", "sudo bash ./ansible-bootstrap.sh" ]
"pip install -q -r requirements.txt", }, {
"echo '[jenkins_worker]' > inventory.ini", "type": "ansible-local",
"echo 'localhost' >> inventory.ini", "playbook_file": "../../playbooks/edx-east/jenkins_worker_sitespeedio.yml",
"ansible-playbook edx-east/jenkins_worker_sitespeedio.yml -i inventory.ini -c local -vvvv"] "playbook": "../../playbooks",
"command": ". {{user `venv_dir`}}/bin/activate && ansible-playbook",
"inventory_groups": "jenkins workers",
"extra_arguments": [
"-vvv"
]
}] }]
} }
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