-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
## This script is designed to be enabled in /etc/sudoers for the `iojs` user, | ||
## the only privileged access that user has to Docker. | ||
## Since there is considerable access given by selecting arbitrary images and | ||
## execution commands, there are still security concerns and additions of new | ||
## images and changes to existing ones as well as the Bash that's executed | ||
## inside them should be monitored for malicious activity. | ||
|
||
set -e | ||
|
||
OPTIND=1 | ||
image_base="rvagg/node-ci-containers" | ||
image_tag= | ||
exec_script="node-ci-exec.sh" | ||
|
||
while getopts "i:" opt; do | ||
case "$opt" in | ||
i) | ||
if [[ "$OPTARG" =~ ^[a-zA-Z0-9_-]+$ ]]; then | ||
image_tag=$OPTARG | ||
else | ||
echo "Bad -i value" | ||
exit 1 | ||
fi | ||
;; | ||
*) | ||
echo "Wut?" | ||
exit 1 | ||
esac | ||
done | ||
|
||
if test "$image_tag" = ""; then | ||
echo "Did not provide the docker image [-i]" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "$(pwd)/$exec_script" ]; then | ||
echo "Did not provide a node-ci-exec.sh script" | ||
exit 1 | ||
fi | ||
|
||
set -x | ||
|
||
image="${image_base}:${image_tag}" | ||
docker pull "${image}" | ||
docker run \ | ||
--init \ | ||
--rm \ | ||
-v $(pwd):/home/iojs/workspace \ | ||
-v /home/iojs/.ccache/${image_tag}:/home/iojs/.ccache \ | ||
-u iojs \ | ||
"${image}" \ | ||
/bin/sh -xc "cd /home/iojs/workspace && . ./$exec_script" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
ansible/roles/jenkins-worker/tasks/partials/docker-host-x64.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
|
||
- name: docker-host-x64 | check if docker exists | ||
shell: which docker | ||
register: docker_exists | ||
ignore_errors: yes | ||
|
||
- name: docker-host-x64 | install docker from docker.com | ||
when: "docker_exists.stdout == ''" | ||
raw: curl -fsSL get.docker.com | bash - | ||
|
||
- name: docker-host-x64 | copy docker-node-exec.sh | ||
copy: | ||
src: "{{ role_path }}/files/docker-node-exec.sh" | ||
dest: "/usr/local/bin/docker-node-exec.sh" | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
|
||
- name: docker-host-x64 | give {{ server_user }} sudoers access to docker-exec script | ||
lineinfile: | ||
line: "{{ server_user }} ALL=(ALL) NOPASSWD: /usr/local/bin/docker-node-exec.sh" | ||
dest: "/etc/sudoers" | ||
regexp: docker-node-exec.sh$ | ||
|
||
- name: docker-host-x64 | install shyaml | ||
pip: | ||
name: shyaml | ||
state: present | ||
executable: pip3 |