Commit 8cd7d0c5 by Arbab Nazar Committed by GitHub

Merge pull request #3231 from edx/arbab/jenkins_master-rewrite

use the YAML syntax for writing tasks
parents c29f4b2d c74a146b
--- ---
- name: restart Jenkins - name: restart Jenkins
service: name=jenkins state=restarted service:
name: jenkins
state: restarted
- name: start nginx - name: start nginx
service: name=nginx state=started service:
name: nginx
state: started
- name: reload nginx - name: reload nginx
service: name=nginx state=reloaded service:
name: nginx
state: reloaded
- name: enable jenkins datadog - name: Enable jenkins datadog
shell: cp /etc/dd-agent/conf.d/jenkins.yaml.example /etc/dd-agent/conf.d/jenkins.yaml creates=/etc/dd-agent/conf.d/jenkins.yaml shell: cp /etc/dd-agent/conf.d/jenkins.yaml.example /etc/dd-agent/conf.d/jenkins.yaml
args:
creates: /etc/dd-agent/conf.d/jenkins.yaml
notify: restart the datadog service notify: restart the datadog service
--- ---
- name: Install jenkins specific system packages
- name: install jenkins specific system packages
apt: apt:
pkg={{','.join(jenkins_debian_pkgs)}} name: "{{ item }}"
state=present update_cache=yes state: present
update_cache: yes
with_items: "{{ jenkins_debian_pkgs }}"
tags: tags:
- jenkins - jenkins
- name: install jenkins extra system packages - name: Install jenkins extra system packages
apt: apt:
pkg={{ item }} state=present update_cache=yes name: "{{ item }}"
with_items: JENKINS_EXTRA_PKGS state: present
update_cache: yes
with_items: "{{ JENKINS_EXTRA_PKGS }}"
tags: tags:
- jenkins - jenkins
- name: create jenkins group - name: Create jenkins group
group: name={{ jenkins_group }} state=present group:
name: "{{ jenkins_group }}"
state: present
- name: add the jenkins user to the group - name: Add the jenkins user to the group
user: name={{ jenkins_user }} append=yes groups={{ jenkins_group }} user:
name: "{{ jenkins_user }}"
append: yes
groups: "{{ jenkins_group }}"
# Should be resolved in the next release, but until then we need to do this # Should be resolved in the next release, but until then we need to do this
# https://issues.jenkins-ci.org/browse/JENKINS-20407 # https://issues.jenkins-ci.org/browse/JENKINS-20407
- name: workaround for JENKINS-20407 - name: Workaround for JENKINS-20407
file: file:
path: "/var/run/jenkins" path: "/var/run/jenkins"
state: directory state: directory
owner: "{{ jenkins_user }}" owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}" group: "{{ jenkins_group }}"
- name: download Jenkins package - name: Install Jenkins package from the internet
get_url: url="{{ jenkins_deb_url }}" dest="/tmp/{{ jenkins_deb }}" apt:
deb: "{{ jenkins_deb_url }}"
- name: install Jenkins package
shell: dpkg -i --force-depends "/tmp/{{ jenkins_deb }}"
- name: stop Jenkins - name: Stop Jenkins
service: name=jenkins state=stopped service:
name: jenkins
state: stopped
- name: set jvm args - name: Set jvm args
lineinfile: lineinfile:
backup: yes backup: yes
dest: /etc/default/jenkins dest: /etc/default/jenkins
...@@ -50,7 +58,7 @@ ...@@ -50,7 +58,7 @@
- java - java
- jenkins - jenkins
- name: set jenkins home - name: Set jenkins home
lineinfile: lineinfile:
backup: yes backup: yes
dest: /etc/default/jenkins dest: /etc/default/jenkins
...@@ -63,28 +71,37 @@ ...@@ -63,28 +71,37 @@
- jenkins - jenkins
# Move /var/lib/jenkins to Jenkins home (on the EBS) # Move /var/lib/jenkins to Jenkins home (on the EBS)
- name: move /var/lib/jenkins - name: Move /var/lib/jenkins
command: mv /var/lib/jenkins {{ jenkins_home }} command: "mv /var/lib/jenkins {{ jenkins_home }}"
creates={{ jenkins_home }} args:
creates: "{{ jenkins_home }}"
- name: set owner for Jenkins home - name: Set owner for Jenkins home
file: path={{ jenkins_home }} recurse=yes state=directory file:
owner={{ jenkins_user }} group={{ jenkins_group }} path: "{{ jenkins_home }}"
recurse: yes
state: directory
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
# Symlink /var/lib/jenkins to {{ COMMON_DATA_DIR }}/jenkins # Symlink /var/lib/jenkins to {{ COMMON_DATA_DIR }}/jenkins
# since Jenkins will expect its files to be in /var/lib/jenkins # since Jenkins will expect its files to be in /var/lib/jenkins
- name: symlink /var/lib/jenkins - name: Symlink /var/lib/jenkins
file: src={{ jenkins_home }} dest=/var/lib/jenkins state=link file:
owner={{ jenkins_user }} group={{ jenkins_group }} src: "{{ jenkins_home }}"
dest: /var/lib/jenkins
state: link
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
notify: notify:
- restart Jenkins - restart Jenkins
# Using this instead of the user module because the user module # Using this instead of the user module because the user module
# fails if the directory exists. # fails if the directory exists.
- name: set home directory for jenkins user - name: Set home directory for jenkins user
shell: usermod -d {{ jenkins_home }} {{ jenkins_user }} shell: "usermod -d {{ jenkins_home }} {{ jenkins_user }}"
- name: make plugins directory - name: Make plugins directory
file: file:
path: "{{ jenkins_home }}/plugins" path: "{{ jenkins_home }}/plugins"
state: directory state: directory
...@@ -94,25 +111,25 @@ ...@@ -94,25 +111,25 @@
# We first download the plugins to a temp directory and include # We first download the plugins to a temp directory and include
# the version in the file name. That way, if we increment # the version in the file name. That way, if we increment
# the version, the plugin will be updated in Jenkins # the version, the plugin will be updated in Jenkins
- name: download Jenkins plugins - name: Download Jenkins plugins
get_url: get_url:
url: http://updates.jenkins-ci.org/download/plugins/{{ item.name }}/{{ item.version }}/{{ item.name }}.hpi url: "http://updates.jenkins-ci.org/download/plugins/{{ item.name }}/{{ item.version }}/{{ item.name }}.hpi"
dest: /tmp/{{ item.name }}_{{ item.version }} dest: "/tmp/{{ item.name }}_{{ item.version }}"
with_items: jenkins_plugins with_items: "{{ jenkins_plugins }}"
register: jenkins_plugin_downloads register: jenkins_plugin_downloads
- name: install Jenkins plugins - name: Install Jenkins plugins
command: "cp {{ item.dest }} {{ jenkins_home }}/plugins/{{ item.item.name }}.hpi" command: "cp {{ item.dest }} {{ jenkins_home }}/plugins/{{ item.item.name }}.hpi"
with_items: jenkins_plugin_downloads.results with_items: "{{ jenkins_plugin_downloads.results }}"
when: item.changed when: item.changed
- name: set Jenkins plugin permissions - name: Set Jenkins plugin permissions
file: file:
path: "{{ jenkins_home }}/plugins/{{ item.item.name }}.hpi" path: "{{ jenkins_home }}/plugins/{{ item.item.name }}.hpi"
owner: "{{ jenkins_user }}" owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}" group: "{{ jenkins_group }}"
mode: "644" mode: "0644"
with_items: jenkins_plugin_downloads.results with_items: "{{ jenkins_plugin_downloads.results }}"
when: item.changed when: item.changed
notify: notify:
- restart Jenkins - restart Jenkins
...@@ -121,52 +138,63 @@ ...@@ -121,52 +138,63 @@
# certain issues. If these changes get merged # certain issues. If these changes get merged
# upstream, we may be able to use the regular plugin install process. # upstream, we may be able to use the regular plugin install process.
# Until then, we compile and install the forks ourselves. # Until then, we compile and install the forks ourselves.
- name: checkout custom plugin repo - name: Checkout custom plugin repo
git_2_0_1: > git_2_0_1:
repo={{ item.repo_url }} dest=/tmp/{{ item.repo_name }} version={{ item.version }} repo: "{{ item.repo_url }}"
accept_hostkey=yes dest: "/tmp/{{ item.repo_name }}"
with_items: jenkins_custom_plugins version: "{{ item.version }}"
accept_hostkey: yes
with_items: "{{ jenkins_custom_plugins }}"
register: jenkins_custom_plugins_checkout register: jenkins_custom_plugins_checkout
- name: compile custom plugins - name: Compile custom plugins
command: mvn -Dmaven.test.skip=true install chdir=/tmp/{{ item.item.repo_name }} command: "mvn -Dmaven.test.skip=true install"
with_items: jenkins_custom_plugins_checkout.results args:
chdir: "/tmp/{{ item.item.repo_name }}"
with_items: "{{ jenkins_custom_plugins_checkout.results }}"
when: item.changed when: item.changed
- name: install custom plugins - name: Install custom plugins
command: mv /tmp/{{ item.item.repo_name }}/target/{{ item.item.package }} command: mv /tmp/{{ item.item.repo_name }}/target/{{ item.item.package }}
{{ jenkins_home }}/plugins/{{ item.item.package }} {{ jenkins_home }}/plugins/{{ item.item.package }}
with_items: jenkins_custom_plugins_checkout.results with_items: "{{ jenkins_custom_plugins_checkout.results }}"
when: item.changed when: item.changed
notify: notify:
- restart Jenkins - restart Jenkins
- name: set custom plugin permissions - name: Set custom plugin permissions
file: path={{ jenkins_home }}/plugins/{{ item.item.package }} file:
owner={{ jenkins_user }} group={{ jenkins_group }} mode="700" path: "{{ jenkins_home }}/plugins/{{ item.item.package }}"
with_items: jenkins_custom_plugins_checkout.results owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
mode: "0700"
with_items: "{{ jenkins_custom_plugins_checkout.results }}"
when: item.changed when: item.changed
# Plugins that are bundled with Jenkins are "pinned". # Plugins that are bundled with Jenkins are "pinned".
# Jenkins will overwrite updated plugins with its built-in version # Jenkins will overwrite updated plugins with its built-in version
# unless we create a ".pinned" file for the plugin. # unless we create a ".pinned" file for the plugin.
# See https://issues.jenkins-ci.org/browse/JENKINS-13129 # See https://issues.jenkins-ci.org/browse/JENKINS-13129
- name: create plugin pin files - name: Create plugin pin files
command: touch {{ jenkins_home }}/plugins/{{ item }}.jpi.pinned command: "touch {{ jenkins_home }}/plugins/{{ item }}.jpi.pinned"
creates={{ jenkins_home }}/plugins/{{ item }}.jpi.pinned args:
with_items: jenkins_bundled_plugins creates: "{{ jenkins_home }}/plugins/{{ item }}.jpi.pinned"
with_items: "{{ jenkins_bundled_plugins }}"
- name: setup nginix vhost - name: Setup nginix vhost
template: template:
src=etc/nginx/sites-available/jenkins.j2 src: "etc/nginx/sites-available/jenkins.j2"
dest=/etc/nginx/sites-available/jenkins dest: "/etc/nginx/sites-available/jenkins"
- name: enable jenkins vhost - name: Enable jenkins vhost
file: file:
src=/etc/nginx/sites-available/jenkins src: "/etc/nginx/sites-available/jenkins"
dest=/etc/nginx/sites-enabled/jenkins dest: "/etc/nginx/sites-enabled/jenkins"
state=link state: link
notify: start nginx notify:
- start nginx
- include: datadog.yml tags=datadog - include: datadog.yml
when: COMMON_ENABLE_DATADOG when: COMMON_ENABLE_DATADOG
tags:
- datadog
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