-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: add initial docker host playbook and dockerfiles
- Loading branch information
Showing
12 changed files
with
458 additions
and
2 deletions.
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
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,20 @@ | ||
--- | ||
|
||
# | ||
# set up a jenkins worker -- muy bueno! | ||
# | ||
|
||
- hosts: | ||
- test | ||
|
||
roles: | ||
- bootstrap | ||
- package-upgrade | ||
- docker | ||
|
||
pre_tasks: | ||
- name: check if containers property is properly set | ||
fail: | ||
failed_when: not containers | ||
|
||
environment: '{{remote_env}}' |
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,8 @@ | ||
--- | ||
|
||
# | ||
# generic handlers for baselayout stuff | ||
# | ||
|
||
- name: restart sshd | ||
service: name="{{ sshd_service_name }}" state=restarted |
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,133 @@ | ||
--- | ||
|
||
# | ||
# common tasks suitable for all machines | ||
# | ||
|
||
- name: gather facts | ||
setup: | ||
|
||
- name: set hostname | ||
hostname: | ||
name: "{{ inventory_hostname|replace('_', '-') }}" | ||
|
||
- name: disable sftp | ||
when: not os|startswith("win") | ||
notify: restart sshd | ||
lineinfile: | ||
state: absent | ||
dest: "{{ ssh_config }}" | ||
regexp: ^Subsystem(\s+)sftp | ||
|
||
- name: add os-specific repos | ||
include: "{{ repos_include }}" | ||
loop_control: | ||
loop_var: repos_include | ||
with_first_found: | ||
- files: | ||
- "{{ role_path }}/tasks/partials/repo/{{ os }}.yml" | ||
- "{{ role_path }}/tasks/partials/repo/{{ os|stripversion }}.yml" | ||
skip: true | ||
|
||
- name: install packages | ||
package: | ||
name: "{{ package }}" | ||
state: present | ||
loop_control: | ||
loop_var: package | ||
with_items: | ||
# ansible doesn't like empty lists | ||
- "{{ packages[os]|default('[]') }}" | ||
- "{{ packages[os|stripversion]|default('[]') }}" | ||
- "{{ common_packages|default('[]') }}" | ||
|
||
- name: remove fortune from login shells | ||
when: os|stripversion == 'freebsd' | ||
lineinfile: | ||
dest: "/home/{{ server_user }}/{{ login_item }}" | ||
state: absent | ||
regexp: fortune freebsd | ||
loop_control: | ||
loop_var: login_item | ||
with_items: [ '.login', '.profile' ] | ||
|
||
- name: set up ntp | ||
include: "{{ ntp_include }}" | ||
loop_control: | ||
loop_var: ntp_include | ||
with_first_found: | ||
- files: | ||
- "{{ role_path }}/../baselayout/tasks/partials/ntp/{{ os }}.yml" | ||
- "{{ role_path }}/../baselayout/tasks/partials/ntp/{{ os|stripversion }}.yml" | ||
- "{{ role_path }}/../baselayout/tasks/partials/ntp/{{ os|match_key(ntp_service, raise_error=False) }}.yml" | ||
skip: true | ||
|
||
- name: create group | ||
group: | ||
name: "{{ server_user }}" | ||
|
||
- name: create user | ||
user: | ||
name: "{{ server_user }}" | ||
group: "{{ server_user }}" | ||
|
||
- name: add ::1 to /etc/hosts for ipv6 compat | ||
lineinfile: | ||
dest: /etc/hosts | ||
state: present | ||
line: ::1 localhost.localdomain localhost | ||
|
||
- name: create worker directory | ||
file: | ||
path: "/home/{{ server_user }}/{{ item.name }}/" | ||
state: directory | ||
owner: "{{ server_user }}" | ||
group: "{{ server_user }}" | ||
mode: 0755 | ||
with_items: | ||
- "{{ containers }}" | ||
|
||
- name: create NODE_TEST_DIR directory | ||
file: | ||
path: "/home/{{ server_user }}/{{ item.name }}/tmp" | ||
state: directory | ||
owner: "{{ server_user }}" | ||
group: "{{ server_user }}" | ||
mode: 0755 | ||
with_items: | ||
- "{{ containers }}" | ||
|
||
- name: "docker : make build directory" | ||
file: | ||
path: /root/docker-container-{{ item.name }} | ||
state: directory | ||
with_items: | ||
- "{{ containers }}" | ||
|
||
- name: "docker : generate Dockerfile" | ||
template: | ||
src: "{{ role_path }}/templates/{{ item.os }}.Dockerfile.j2" | ||
dest: /root/docker-container-{{ item.name }}/Dockerfile | ||
mode: "0644" | ||
with_items: | ||
- "{{ containers }}" | ||
|
||
- name: "docker : build image" | ||
command: docker build -t node-ci:{{ item.name }} /root/docker-container-{{ item.name }}/ | ||
with_items: | ||
- "{{ containers }}" | ||
|
||
- name: "docker : generate and copy init script" | ||
template: | ||
src: "{{ role_path }}/templates/jenkins.service.j2" | ||
dest: "/lib/systemd/system/jenkins-{{ item.name }}.service" | ||
with_items: | ||
- "{{ containers }}" | ||
|
||
- name: "docker : start Jenkins" | ||
service: | ||
name: "jenkins-{{ item.name }}" | ||
state: started | ||
enabled: yes | ||
with_items: | ||
- "{{ containers }}" |
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,15 @@ | ||
--- | ||
|
||
# | ||
# add Docker repo | ||
# | ||
|
||
- name: "repo : add Ubuntu Docker repo key" | ||
raw: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
|
||
- name: "repo : add Ubuntu Docker repo" | ||
raw: add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | ||
register: has_updated_package_repo | ||
|
||
- name: "repo : update apt cache" | ||
apt: update_cache=yes |
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,56 @@ | ||
FROM alpine:3.4 | ||
|
||
ENV LC_ALL C | ||
ENV USER {{ server_user }} | ||
ENV JOBS {{ server_jobs | default(ansible_processor_vcpus) }} | ||
ENV SHELL /bin/bash | ||
ENV HOME /home/{{ server_user }} | ||
ENV PATH /usr/lib/ccache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
ENV NODE_COMMON_PIPE /home/{{ server_user }}/test.pipe | ||
ENV NODE_TEST_DIR /home/{{ server_user }}/tmp | ||
ENV OSTYPE linux-gnu | ||
ENV OSVARIANT docker | ||
ENV DESTCPU x64 | ||
ENV ARCH x64 | ||
|
||
RUN echo 'https://dl-3.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories && \ | ||
echo 'https://dl-3.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories | ||
|
||
RUN apk add --no-cache \ | ||
libstdc++ \ | ||
&& apk add --no-cache --virtual .build-deps \ | ||
binutils-gold \ | ||
curl \ | ||
g++ \ | ||
gcc \ | ||
gnupg \ | ||
libgcc \ | ||
linux-headers \ | ||
make \ | ||
paxctl \ | ||
python \ | ||
tar \ | ||
ccache \ | ||
openjdk8 \ | ||
git \ | ||
procps \ | ||
openssh-client \ | ||
py2-pip \ | ||
bash | ||
|
||
RUN pip install tap2junit | ||
|
||
RUN addgroup -g 1000 {{ server_user }} | ||
|
||
RUN adduser -G {{ server_user }} -D -u 1000 {{ server_user }} | ||
|
||
VOLUME [ "/home/{{ server_user }}/" ] | ||
|
||
USER iojs:iojs | ||
|
||
CMD cd /home/iojs \ | ||
&& curl https://ci.nodejs.org/jnlpJars/slave.jar -O \ | ||
&& java -Xmx{{ server_ram|default('128m') }} \ | ||
-jar /home/{{ server_user }}/slave.jar \ | ||
-jnlpUrl {{ jenkins_url }}/computer/{{ item.name }}/slave-agent.jnlp \ | ||
-secret {{ item.secret }} |
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,57 @@ | ||
FROM alpine:3.5 | ||
|
||
ENV LC_ALL C | ||
ENV USER {{ server_user }} | ||
ENV JOBS {{ server_jobs | default(ansible_processor_vcpus) }} | ||
ENV SHELL /bin/bash | ||
ENV HOME /home/{{ server_user }} | ||
ENV PATH /usr/lib/ccache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
ENV NODE_COMMON_PIPE /home/{{ server_user }}/test.pipe | ||
ENV NODE_TEST_DIR /home/{{ server_user }}/tmp | ||
ENV OSTYPE linux-gnu | ||
ENV OSVARIANT docker | ||
ENV DESTCPU x64 | ||
ENV ARCH x64 | ||
|
||
RUN echo 'https://dl-3.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories && \ | ||
echo 'https://dl-3.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories | ||
|
||
RUN apk add --no-cache \ | ||
libstdc++ \ | ||
&& apk add --no-cache --virtual .build-deps \ | ||
shadow \ | ||
binutils-gold \ | ||
curl \ | ||
g++ \ | ||
gcc \ | ||
gnupg \ | ||
libgcc \ | ||
linux-headers \ | ||
make \ | ||
paxctl \ | ||
python \ | ||
tar \ | ||
ccache \ | ||
openjdk8 \ | ||
git \ | ||
procps \ | ||
openssh-client \ | ||
py2-pip \ | ||
bash | ||
|
||
RUN pip install tap2junit | ||
|
||
RUN addgroup -g 1000 {{ server_user }} | ||
|
||
RUN adduser -G {{ server_user }} -D -u 1000 {{ server_user }} | ||
|
||
VOLUME [ "/home/{{ server_user }}/" ] | ||
|
||
USER iojs:iojs | ||
|
||
CMD cd /home/iojs \ | ||
&& curl https://ci.nodejs.org/jnlpJars/slave.jar -O \ | ||
&& java -Xmx{{ server_ram|default('128m') }} \ | ||
-jar /home/{{ server_user }}/slave.jar \ | ||
-jnlpUrl {{ jenkins_url }}/computer/{{ item.name }}/slave-agent.jnlp \ | ||
-secret {{ item.secret }} |
Oops, something went wrong.