Commit dec8ff69 by Michael Roytman Committed by GitHub

Merge pull request #3690 from edx/mroytman/update-dockerfile

Mroytman/update dockerfile
parents 73f1aa1f 07b20395
......@@ -7,4 +7,6 @@ RUN apt-get update
ADD . /edx/app/edx_ansible/edx_ansible
WORKDIR /edx/app/edx_ansible/edx_ansible/docker/plays
COPY docker/build/tools_jenkins/ansible_overrides.yml /
RUN PYTHONUNBUFFERED=1 /edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook -v jenkins_tools.yml -i '127.0.0.1,' -c local -e@/ansible_overrides.yml -vv
RUN PYTHONUNBUFFERED=1 /edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook -v jenkins_tools.yml -i '127.0.0.1,' -c local -e@/ansible_overrides.yml -vv -t 'install'
CMD /bin/su -l jenkins --shell=/bin/bash -c "/usr/bin/daemon -f --name=jenkins --inherit --env=JENKINS_HOME=/edx/var/jenkins --output=/var/log/jenkins/jenkins.log --pidfile=/var/run/jenkins/jenkins.pid -- /usr/bin/java -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080 --ajp13Port=-1"
......@@ -3,13 +3,22 @@
service:
name: jenkins
state: restarted
tags:
- manage
- manage:start
- name: start nginx
service:
name: nginx
state: started
tags:
- manage
- manage:start
- name: reload nginx
service:
name: nginx
state: reloaded
tags:
- manage
- manage:start
......@@ -7,6 +7,8 @@
with_items: "{{ jenkins_debian_pkgs }}"
tags:
- jenkins
- install
- install:system-requirements
- name: Install jenkins extra system packages
apt:
......@@ -16,17 +18,25 @@
with_items: "{{ JENKINS_EXTRA_PKGS }}"
tags:
- jenkins
- install
- install:system-requirements
- name: Create jenkins group
group:
name: "{{ jenkins_group }}"
state: present
tags:
- install
- install:system-requirements
- name: Add the jenkins user to the group
user:
name: "{{ jenkins_user }}"
append: yes
groups: "{{ jenkins_group }}"
tags:
- install
- install:system-requirements
# Should be resolved in the next release, but until then we need to do this
# https://issues.jenkins-ci.org/browse/JENKINS-20407
......@@ -36,19 +46,31 @@
state: directory
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
tags:
- install
- install:system-requirements
# TODO in Ansible 2.1 we can do apt: deb="{{ jenkins_deb_url }}"
- name: download Jenkins package
get_url: url="{{ jenkins_deb_url }}" dest="/tmp/{{ jenkins_deb }}"
tags:
- install
- install:app-requirements
- name: install Jenkins package
apt:
deb: "/tmp/{{ jenkins_deb }}"
tags:
- install
- install:app-requirements
- name: Stop Jenkins
service:
name: jenkins
state: stopped
tags:
- manage
- manage:stop
- name: Set jvm args
lineinfile:
......@@ -56,11 +78,11 @@
dest: /etc/default/jenkins
regexp: '^JAVA_ARGS='
line: 'JAVA_ARGS="{{ jenkins_jvm_args }}"'
notify:
- restart Jenkins
tags:
- java
- jenkins
- install
- install:app-configuration
- name: Set jenkins home
lineinfile:
......@@ -68,17 +90,20 @@
dest: /etc/default/jenkins
regexp: '^JENKINS_HOME='
line: 'JENKINS_HOME="{{ jenkins_home }}"'
notify:
- restart Jenkins
tags:
- java
- jenkins
- install
- install:app-configuration
# Move /var/lib/jenkins to Jenkins home (on the EBS)
- name: Move /var/lib/jenkins
command: "mv /var/lib/jenkins {{ jenkins_home }}"
args:
creates: "{{ jenkins_home }}"
tags:
- install
- install:base
- name: Set owner for Jenkins home
file:
......@@ -87,6 +112,9 @@
state: directory
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
tags:
- install
- install:app-requirements
# Symlink /var/lib/jenkins to {{ COMMON_DATA_DIR }}/jenkins
# since Jenkins will expect its files to be in /var/lib/jenkins
......@@ -97,13 +125,17 @@
state: link
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
notify:
- restart Jenkins
tags:
- install
- install:base
# Using this instead of the user module because the user module
# fails if the directory exists.
- name: Set home directory for jenkins user
shell: "usermod -d {{ jenkins_home }} {{ jenkins_user }}"
tags:
- install
- install:base
- name: Make plugins directory
file:
......@@ -111,6 +143,9 @@
state: directory
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
tags:
- install
- install:base
# We first download the plugins to a temp directory and include
# the version in the file name. That way, if we increment
......@@ -121,11 +156,17 @@
dest: "/tmp/{{ item.name }}_{{ item.version }}"
with_items: "{{ jenkins_plugins }}"
register: jenkins_plugin_downloads
tags:
- install
- install:base
- name: Install Jenkins plugins
command: "cp {{ item.dest }} {{ jenkins_home }}/plugins/{{ item.item.name }}.hpi"
with_items: "{{ jenkins_plugin_downloads.results }}"
when: item.changed
tags:
- install
- install:base
- name: Set Jenkins plugin permissions
file:
......@@ -135,8 +176,9 @@
mode: "0644"
with_items: "{{ jenkins_plugin_downloads.results }}"
when: item.changed
notify:
- restart Jenkins
tags:
- install
- install:base
# We had to fork some plugins to workaround
# certain issues. If these changes get merged
......@@ -150,6 +192,9 @@
accept_hostkey: yes
with_items: "{{ jenkins_custom_plugins }}"
register: jenkins_custom_plugins_checkout
tags:
- install
- install:base
- name: Compile custom plugins
command: "mvn -Dmaven.test.skip=true install"
......@@ -157,14 +202,18 @@
chdir: "/tmp/{{ item.item.repo_name }}"
with_items: "{{ jenkins_custom_plugins_checkout.results }}"
when: item.changed
tags:
- install
- install:base
- name: Install custom plugins
command: mv /tmp/{{ item.item.repo_name }}/target/{{ item.item.package }}
{{ jenkins_home }}/plugins/{{ item.item.package }}
with_items: "{{ jenkins_custom_plugins_checkout.results }}"
when: item.changed
notify:
- restart Jenkins
tags:
- install
- install:base
- name: Set custom plugin permissions
file:
......@@ -174,6 +223,9 @@
mode: "0700"
with_items: "{{ jenkins_custom_plugins_checkout.results }}"
when: item.changed
tags:
- install
- install:base
# Plugins that are bundled with Jenkins are "pinned".
# Jenkins will overwrite updated plugins with its built-in version
......@@ -184,21 +236,38 @@
args:
creates: "{{ jenkins_home }}/plugins/{{ item }}.jpi.pinned"
with_items: "{{ jenkins_bundled_plugins }}"
tags:
- install
- install:base
- name: Setup nginix vhost
template:
src: "etc/nginx/sites-available/jenkins.j2"
dest: "/etc/nginx/sites-available/jenkins"
tags:
- install
- install:vhosts
- name: Enable jenkins vhost
file:
src: "/etc/nginx/sites-available/jenkins"
dest: "/etc/nginx/sites-enabled/jenkins"
state: link
notify:
- start nginx
tags:
- install
- install:vhosts
- include: datadog.yml
when: COMMON_ENABLE_DATADOG
tags:
- datadog
- install
- install:base
- name: restart Jenkinks
service:
name: jenkins
state: restarted
tags:
- manage
- manage:start
---
- name: restart Jenkins
service:
name: jenkins
state: restarted
\ No newline at end of file
......@@ -7,3 +7,4 @@ dependencies:
jenkins_plugins: "{{ jenkins_tools_plugins }}"
jenkins_version: "{{ jenkins_tools_version }}"
jenkins_deb_url: "http://pkg.jenkins-ci.org/debian-stable/binary/jenkins_{{ jenkins_version }}_all.deb"
jenkins_custom_plugins: []
---
- name: Get the list of hpi files
shell: "ls {{ jenkins_home }}/plugins/*.hpi"
register: hpi_files
ignore_errors: true
- name: Set the permission on hpi files
file:
path: "{{ item }}"
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
mode: 0644
with_items: "{{ hpi_files.stdout_lines }}"
when: hpi_files
notify:
- restart Jenkins
- name: Get the list of jpi files
shell: "ls {{ jenkins_home }}/plugins/*.jpi"
register: jpi_files
ignore_errors: true
- name: Set the permission on jpi files
file:
path: "{{ item }}"
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
mode: 0644
with_items: "{{ jpi_files.stdout_lines }}"
when: jpi_files
notify:
- restart Jenkins
# The deadsnakes PPA is required to install python3.5 on Precise and Trusty.
# Xenial comes with python3.5 installed.
- name: add deadsnakes repository
......
......@@ -207,7 +207,7 @@ def get_plays(files, git_dir, playbooks_dirs):
# if the change set file is in the set of playbook files
if file_path in candidate_files:
plays.add(_get_playbok_name_from_file(file_path))
plays.add(_get_playbook_name_from_file(file_path))
return plays
......
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