Commit 2c0c6229 by Michael Roytman

add lifecycle tags to jenkins_master and tools_jenkins tasks

parent 73f1aa1f
...@@ -3,13 +3,22 @@ ...@@ -3,13 +3,22 @@
service: service:
name: jenkins name: jenkins
state: restarted state: restarted
tags:
- manage
- manage:start
- name: start nginx - name: start nginx
service: service:
name: nginx name: nginx
state: started state: started
tags:
- manage
- manage:start
- name: reload nginx - name: reload nginx
service: service:
name: nginx name: nginx
state: reloaded state: reloaded
tags:
- manage
- manage:start
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
with_items: "{{ jenkins_debian_pkgs }}" with_items: "{{ jenkins_debian_pkgs }}"
tags: tags:
- jenkins - jenkins
- install
- install:system-requirements
- name: Install jenkins extra system packages - name: Install jenkins extra system packages
apt: apt:
...@@ -16,17 +18,25 @@ ...@@ -16,17 +18,25 @@
with_items: "{{ JENKINS_EXTRA_PKGS }}" with_items: "{{ JENKINS_EXTRA_PKGS }}"
tags: tags:
- jenkins - jenkins
- install
- install:system-requirements
- name: Create jenkins group - name: Create jenkins group
group: group:
name: "{{ jenkins_group }}" name: "{{ jenkins_group }}"
state: present state: present
tags:
- install
- install:system-requirements
- name: Add the jenkins user to the group - name: Add the jenkins user to the group
user: user:
name: "{{ jenkins_user }}" name: "{{ jenkins_user }}"
append: yes append: yes
groups: "{{ jenkins_group }}" groups: "{{ jenkins_group }}"
tags:
- install
- install:system-requirements
# 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
...@@ -36,19 +46,31 @@ ...@@ -36,19 +46,31 @@
state: directory state: directory
owner: "{{ jenkins_user }}" owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}" group: "{{ jenkins_group }}"
tags:
- install
- install:system-requirements
# TODO in Ansible 2.1 we can do apt: deb="{{ jenkins_deb_url }}" # TODO in Ansible 2.1 we can do apt: deb="{{ jenkins_deb_url }}"
- name: download Jenkins package - name: download Jenkins package
get_url: url="{{ jenkins_deb_url }}" dest="/tmp/{{ jenkins_deb }}" get_url: url="{{ jenkins_deb_url }}" dest="/tmp/{{ jenkins_deb }}"
tags:
- install
- install:app-requirements
- name: install Jenkins package - name: install Jenkins package
apt: apt:
deb: "/tmp/{{ jenkins_deb }}" deb: "/tmp/{{ jenkins_deb }}"
tags:
- install
- install:app-requirements
- name: Stop Jenkins - name: Stop Jenkins
service: service:
name: jenkins name: jenkins
state: stopped state: stopped
tags:
- manage
- manage:stop
- name: Set jvm args - name: Set jvm args
lineinfile: lineinfile:
...@@ -61,6 +83,8 @@ ...@@ -61,6 +83,8 @@
tags: tags:
- java - java
- jenkins - jenkins
- install
- install:app-configuration
- name: Set jenkins home - name: Set jenkins home
lineinfile: lineinfile:
...@@ -73,12 +97,17 @@ ...@@ -73,12 +97,17 @@
tags: tags:
- java - java
- jenkins - jenkins
- install
- install:app-configuration
# 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 }}"
args: args:
creates: "{{ jenkins_home }}" creates: "{{ jenkins_home }}"
tags:
- install
- install:base
- name: Set owner for Jenkins home - name: Set owner for Jenkins home
file: file:
...@@ -87,6 +116,9 @@ ...@@ -87,6 +116,9 @@
state: directory state: directory
owner: "{{ jenkins_user }}" owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}" group: "{{ jenkins_group }}"
tags:
- install
- install:app-requirements
# 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
...@@ -99,11 +131,17 @@ ...@@ -99,11 +131,17 @@
group: "{{ jenkins_group }}" group: "{{ jenkins_group }}"
notify: notify:
- restart Jenkins - restart Jenkins
tags:
- install
- install:base
# 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 }}"
tags:
- install
- install:base
- name: Make plugins directory - name: Make plugins directory
file: file:
...@@ -111,6 +149,9 @@ ...@@ -111,6 +149,9 @@
state: directory state: directory
owner: "{{ jenkins_user }}" owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}" group: "{{ jenkins_group }}"
tags:
- install
- install:base
# 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
...@@ -121,11 +162,17 @@ ...@@ -121,11 +162,17 @@
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
tags:
- install
- install:base
- 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
tags:
- install
- install:base
- name: Set Jenkins plugin permissions - name: Set Jenkins plugin permissions
file: file:
...@@ -137,6 +184,9 @@ ...@@ -137,6 +184,9 @@
when: item.changed when: item.changed
notify: notify:
- restart Jenkins - restart Jenkins
tags:
- install
- install:base
# We had to fork some plugins to workaround # We had to fork some plugins to workaround
# certain issues. If these changes get merged # certain issues. If these changes get merged
...@@ -150,6 +200,9 @@ ...@@ -150,6 +200,9 @@
accept_hostkey: yes accept_hostkey: yes
with_items: "{{ jenkins_custom_plugins }}" with_items: "{{ jenkins_custom_plugins }}"
register: jenkins_custom_plugins_checkout register: jenkins_custom_plugins_checkout
tags:
- install
- install:base
- name: Compile custom plugins - name: Compile custom plugins
command: "mvn -Dmaven.test.skip=true install" command: "mvn -Dmaven.test.skip=true install"
...@@ -157,6 +210,9 @@ ...@@ -157,6 +210,9 @@
chdir: "/tmp/{{ item.item.repo_name }}" chdir: "/tmp/{{ item.item.repo_name }}"
with_items: "{{ jenkins_custom_plugins_checkout.results }}" with_items: "{{ jenkins_custom_plugins_checkout.results }}"
when: item.changed when: item.changed
tags:
- install
- install:base
- 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 }}
...@@ -165,6 +221,9 @@ ...@@ -165,6 +221,9 @@
when: item.changed when: item.changed
notify: notify:
- restart Jenkins - restart Jenkins
tags:
- install
- install:base
- name: Set custom plugin permissions - name: Set custom plugin permissions
file: file:
...@@ -174,6 +233,9 @@ ...@@ -174,6 +233,9 @@
mode: "0700" mode: "0700"
with_items: "{{ jenkins_custom_plugins_checkout.results }}" with_items: "{{ jenkins_custom_plugins_checkout.results }}"
when: item.changed when: item.changed
tags:
- install
- install:base
# 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
...@@ -184,11 +246,17 @@ ...@@ -184,11 +246,17 @@
args: args:
creates: "{{ jenkins_home }}/plugins/{{ item }}.jpi.pinned" creates: "{{ jenkins_home }}/plugins/{{ item }}.jpi.pinned"
with_items: "{{ jenkins_bundled_plugins }}" with_items: "{{ jenkins_bundled_plugins }}"
tags:
- install
- install:base
- 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"
tags:
- install
- install:vhosts
- name: Enable jenkins vhost - name: Enable jenkins vhost
file: file:
...@@ -197,8 +265,13 @@ ...@@ -197,8 +265,13 @@
state: link state: link
notify: notify:
- start nginx - start nginx
tags:
- install
- install:vhosts
- include: datadog.yml - include: datadog.yml
when: COMMON_ENABLE_DATADOG when: COMMON_ENABLE_DATADOG
tags: tags:
- datadog - datadog
- install
- install:base
...@@ -3,3 +3,6 @@ ...@@ -3,3 +3,6 @@
service: service:
name: jenkins name: jenkins
state: restarted state: restarted
tags:
- manage
- manage:start
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
shell: "ls {{ jenkins_home }}/plugins/*.hpi" shell: "ls {{ jenkins_home }}/plugins/*.hpi"
register: hpi_files register: hpi_files
ignore_errors: true ignore_errors: true
tags:
- install
- install:app-configuration
- name: Set the permission on hpi files - name: Set the permission on hpi files
file: file:
...@@ -14,11 +17,17 @@ ...@@ -14,11 +17,17 @@
when: hpi_files when: hpi_files
notify: notify:
- restart Jenkins - restart Jenkins
tags:
- install
- install:app-configuration
- name: Get the list of jpi files - name: Get the list of jpi files
shell: "ls {{ jenkins_home }}/plugins/*.jpi" shell: "ls {{ jenkins_home }}/plugins/*.jpi"
register: jpi_files register: jpi_files
ignore_errors: true ignore_errors: true
tags:
- install
- install:app-configuration
- name: Set the permission on jpi files - name: Set the permission on jpi files
file: file:
...@@ -30,6 +39,9 @@ ...@@ -30,6 +39,9 @@
when: jpi_files when: jpi_files
notify: notify:
- restart Jenkins - restart Jenkins
tags:
- install
- install:app-configuration
# The deadsnakes PPA is required to install python3.5 on Precise and Trusty. # The deadsnakes PPA is required to install python3.5 on Precise and Trusty.
# Xenial comes with python3.5 installed. # Xenial comes with python3.5 installed.
......
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