ansible: add vendor roles needed by mozreview CI (bug 1294805) r?gps,smacleod,glob draft
authorMāris Fogels <mars@mozilla.com>
Thu, 01 Sep 2016 11:41:31 -0400
changeset 9571 709ea5056f06cc437736e9c3b5019dd4dd7231e9
parent 9567 90a675700c51b487b03b4b16375adc4c82574bd9
child 9572 a9e8148c65b6b2c19ab302d8b9f22f0d8d33d5b0
child 9574 fc193b6ef8089046247cb2a9893abdb43eff3c25
push id1223
push usermfogels@mozilla.com
push dateTue, 13 Sep 2016 20:26:40 +0000
reviewersgps, smacleod, glob
bugs1294805
ansible: add vendor roles needed by mozreview CI (bug 1294805) r?gps,smacleod,glob Added two vendor roles needed to set up a mozreview CI host. MozReview-Commit-ID: 5U5aV4EZiax
ansible/vendor-roles/geerlingguy.java/.travis.yml
ansible/vendor-roles/geerlingguy.java/README.md
ansible/vendor-roles/geerlingguy.java/defaults/main.yml
ansible/vendor-roles/geerlingguy.java/meta/.galaxy_install_info
ansible/vendor-roles/geerlingguy.java/meta/main.yml
ansible/vendor-roles/geerlingguy.java/tasks/main.yml
ansible/vendor-roles/geerlingguy.java/tasks/setup-Debian.yml
ansible/vendor-roles/geerlingguy.java/tasks/setup-FreeBSD.yml
ansible/vendor-roles/geerlingguy.java/tasks/setup-RedHat.yml
ansible/vendor-roles/geerlingguy.java/tests/Dockerfile.centos-6
ansible/vendor-roles/geerlingguy.java/tests/Dockerfile.centos-7
ansible/vendor-roles/geerlingguy.java/tests/Dockerfile.ubuntu-12.04
ansible/vendor-roles/geerlingguy.java/tests/Dockerfile.ubuntu-14.04
ansible/vendor-roles/geerlingguy.java/tests/test.yml
ansible/vendor-roles/geerlingguy.java/vars/Debian.yml
ansible/vendor-roles/geerlingguy.java/vars/FreeBSD.yml
ansible/vendor-roles/geerlingguy.java/vars/RedHat.yml
ansible/vendor-roles/geerlingguy.java/vars/Ubuntu-12.04.yml
ansible/vendor-roles/geerlingguy.java/vars/Ubuntu-14.04.yml
ansible/vendor-roles/geerlingguy.java/vars/Ubuntu-16.04.yml
ansible/vendor-roles/geerlingguy.jenkins/.travis.yml
ansible/vendor-roles/geerlingguy.jenkins/README.md
ansible/vendor-roles/geerlingguy.jenkins/defaults/main.yml
ansible/vendor-roles/geerlingguy.jenkins/handlers/main.yml
ansible/vendor-roles/geerlingguy.jenkins/meta/.galaxy_install_info
ansible/vendor-roles/geerlingguy.jenkins/meta/main.yml
ansible/vendor-roles/geerlingguy.jenkins/tasks/main.yml
ansible/vendor-roles/geerlingguy.jenkins/tasks/plugins.yml
ansible/vendor-roles/geerlingguy.jenkins/tasks/settings.yml
ansible/vendor-roles/geerlingguy.jenkins/tasks/setup-Debian.yml
ansible/vendor-roles/geerlingguy.jenkins/tasks/setup-RedHat.yml
ansible/vendor-roles/geerlingguy.jenkins/templates/basic-security.groovy
ansible/vendor-roles/geerlingguy.jenkins/tests/Dockerfile.centos-6
ansible/vendor-roles/geerlingguy.jenkins/tests/Dockerfile.centos-7
ansible/vendor-roles/geerlingguy.jenkins/tests/Dockerfile.ubuntu-12.04
ansible/vendor-roles/geerlingguy.jenkins/tests/Dockerfile.ubuntu-14.04
ansible/vendor-roles/geerlingguy.jenkins/tests/requirements.yml
ansible/vendor-roles/geerlingguy.jenkins/tests/test-http-port.yml
ansible/vendor-roles/geerlingguy.jenkins/tests/test-jenkins-version.yml
ansible/vendor-roles/geerlingguy.jenkins/tests/test-plugins-with-pinning.yml
ansible/vendor-roles/geerlingguy.jenkins/tests/test-plugins.yml
ansible/vendor-roles/geerlingguy.jenkins/tests/test-prefix.yml
ansible/vendor-roles/geerlingguy.jenkins/tests/test.yml
ansible/vendor-roles/geerlingguy.jenkins/vars/Debian.yml
ansible/vendor-roles/geerlingguy.jenkins/vars/RedHat.yml
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/.travis.yml
@@ -0,0 +1,57 @@
+---
+sudo: required
+
+env:
+  - distribution: centos
+    version: 6
+    init: /sbin/init
+    run_opts: ""
+  - distribution: centos
+    version: 7
+    init: /usr/lib/systemd/systemd
+    run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
+  - distribution: ubuntu
+    version: 14.04
+    init: /sbin/init
+    run_opts: ""
+  - distribution: ubuntu
+    version: 12.04
+    init: /sbin/init
+    run_opts: ""
+
+services:
+  - docker
+
+before_install:
+  # Pull container
+  - 'sudo docker pull ${distribution}:${version}'
+  # Customize container
+  - 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
+
+script:
+  - container_id=$(mktemp)
+  # Run container in detached state
+  - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
+
+  # Ansible syntax check.
+  - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
+
+  # Test role.
+  - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
+
+  # Test role idempotence.
+  - >
+    sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml
+    | grep -q 'changed=0.*failed=0'
+    && (echo 'Idempotence test: pass' && exit 0)
+    || (echo 'Idempotence test: fail' && exit 1)
+
+  # Ensure daemonize is available.
+  - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm which java'
+
+  # Clean up
+  - 'sudo docker stop "$(cat ${container_id})"'
+
+notifications:
+  webhooks: https://galaxy.ansible.com/api/v1/notifications/
+
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/README.md
@@ -0,0 +1,62 @@
+# Ansible Role: Java
+
+[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-java.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-java)
+
+Installs Java for RedHat/CentOS and Debian/Ubuntu linux servers.
+
+## Requirements
+
+None.
+
+## Role Variables
+
+Available variables are listed below, along with default values:
+
+    # The defaults provided by this role are specific to each distribution.
+    java_packages:
+      - java-1.7.0-openjdk
+
+Set the version/development kit of Java to install, along with any other necessary Java packages. Some other options include are included in the distribution-specific files in this role's 'defaults' folder.
+
+## Dependencies
+
+None.
+
+## Example Playbook (using default package, usually OpenJDK 7)
+
+    - hosts: servers
+      roles:
+        - geerlingguy.java
+
+## Example Playbook (install OpenJDK 8)
+
+For RHEL / CentOS:
+
+    - hosts: server
+      roles:
+        - role: geerlingguy.java
+          when: "ansible_os_family == 'RedHat'"
+          java_packages:
+            - java-1.8.0-openjdk
+
+For Ubuntu < 16.04:
+
+    - hosts: server
+      tasks:
+        - name: installing repo for Java 8 in Ubuntu
+  	      apt_repository: repo='ppa:openjdk-r/ppa'
+    
+    - hosts: server
+      roles:
+        - role: geerlingguy.java
+          when: "ansible_os_family == 'Debian'"
+          java_packages:
+            - openjdk-8-jdk
+
+## License
+
+MIT / BSD
+
+## Author Information
+
+This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/).
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+# Set java_packages if you would like to use a different version than the
+# default (OpenJDK 1.7).
+# java_packages: []
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/meta/.galaxy_install_info
@@ -0,0 +1,1 @@
+{install_date: 'Thu Aug 25 19:21:08 2016', version: 1.4.0}
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/meta/main.yml
@@ -0,0 +1,27 @@
+---
+dependencies: []
+
+galaxy_info:
+  author: geerlingguy
+  description: Java for Linux
+  company: "Midwestern Mac, LLC"
+  license: "license (BSD, MIT)"
+  min_ansible_version: 1.9
+  platforms:
+    - name: EL
+      versions:
+      - 6
+      - 7
+    - name: Debian
+      versions:
+      - all
+    - name: Ubuntu
+      versions:
+      - all
+    - name: FreeBSD
+      versions:
+      - 10.2
+  galaxy_tags:
+    - development
+    - system
+    - web
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/tasks/main.yml
@@ -0,0 +1,23 @@
+---
+- name: Include OS-specific variables.
+  include_vars: "{{ ansible_os_family }}.yml"
+  when: ansible_distribution != 'Ubuntu'
+
+- name: Include version-specific variables for Ubuntu.
+  include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
+  when: ansible_distribution == 'Ubuntu'
+
+- name: Define java_packages.
+  set_fact:
+    java_packages: "{{ __java_packages | list }}"
+  when: java_packages is not defined
+
+# Setup/install tasks.
+- include: setup-RedHat.yml
+  when: ansible_os_family == 'RedHat'
+
+- include: setup-Debian.yml
+  when: ansible_os_family == 'Debian'
+
+- include: setup-FreeBSD.yml
+  when: ansible_os_family == 'FreeBSD'
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/tasks/setup-Debian.yml
@@ -0,0 +1,7 @@
+---
+- name: Update apt cache.
+  apt: update_cache=yes cache_valid_time=86400
+
+- name: Ensure Java is installed.
+  apt: "name={{ item }} state=installed"
+  with_items: "{{ java_packages }}"
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/tasks/setup-FreeBSD.yml
@@ -0,0 +1,10 @@
+---
+- name: Ensure Java is installed.
+  pkgng: "name={{ item }} state=present"
+  with_items: "{{ java_packages }}"
+
+- name: ensure proc is mounted
+  mount: name=/proc fstype=procfs src=proc opts=rw state=mounted
+
+- name: ensure fdesc is mounted
+  mount: name=/dev/fd fstype=fdescfs src=fdesc opts=rw state=mounted
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/tasks/setup-RedHat.yml
@@ -0,0 +1,4 @@
+---
+- name: Ensure Java is installed.
+  yum: "name={{ item }} state=installed"
+  with_items: "{{ java_packages }}"
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/tests/Dockerfile.centos-6
@@ -0,0 +1,15 @@
+FROM centos:6
+
+# Install Ansible
+RUN yum -y update; yum clean all;
+RUN yum -y install epel-release
+RUN yum -y install git ansible sudo
+RUN yum clean all
+
+# Disable requiretty
+RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/'  /etc/sudoers
+
+# Install Ansible inventory file
+RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
+
+CMD ["/usr/sbin/init"]
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/tests/Dockerfile.centos-7
@@ -0,0 +1,27 @@
+FROM centos:7
+
+# Install systemd -- See https://hub.docker.com/_/centos/
+RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
+RUN yum -y update; yum clean all; \
+(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
+rm -f /lib/systemd/system/multi-user.target.wants/*; \
+rm -f /etc/systemd/system/*.wants/*; \
+rm -f /lib/systemd/system/local-fs.target.wants/*; \
+rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
+rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
+rm -f /lib/systemd/system/basic.target.wants/*; \
+rm -f /lib/systemd/system/anaconda.target.wants/*;
+
+# Install Ansible
+RUN yum -y install epel-release
+RUN yum -y install git ansible sudo
+RUN yum clean all
+
+# Disable requiretty
+RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/'  /etc/sudoers
+
+# Install Ansible inventory file
+RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
+
+VOLUME ["/sys/fs/cgroup"]
+CMD ["/usr/sbin/init"]
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/tests/Dockerfile.ubuntu-12.04
@@ -0,0 +1,11 @@
+FROM ubuntu:12.04
+RUN apt-get update
+
+# Install Ansible
+RUN apt-get install -y software-properties-common python-software-properties git
+RUN apt-add-repository -y ppa:ansible/ansible
+RUN apt-get update
+RUN apt-get install -y ansible
+
+# Install Ansible inventory file
+RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/tests/Dockerfile.ubuntu-14.04
@@ -0,0 +1,11 @@
+FROM ubuntu:14.04
+RUN apt-get update
+
+# Install Ansible
+RUN apt-get install -y software-properties-common git
+RUN apt-add-repository -y ppa:ansible/ansible
+RUN apt-get update
+RUN apt-get install -y ansible
+
+# Install Ansible inventory file
+RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/tests/test.yml
@@ -0,0 +1,10 @@
+---
+- hosts: all
+
+  pre_tasks:
+    - name: Ensure build dependencies are installed (RedHat).
+      yum: name=which state=present
+      when: ansible_os_family == 'RedHat'
+
+  roles:
+    - role_under_test
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/vars/Debian.yml
@@ -0,0 +1,7 @@
+---
+# JDK version options include:
+#   - java
+#   - openjdk-6-jdk
+#   - openjdk-7-jdk
+__java_packages:
+  - openjdk-7-jdk
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/vars/FreeBSD.yml
@@ -0,0 +1,7 @@
+---
+# JDK version options for FreeBSD include:
+#   - openjdk
+#   - openjdk6
+#   - openjdk8
+__java_packages:
+  - openjdk
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/vars/RedHat.yml
@@ -0,0 +1,7 @@
+---
+# JDK version options include:
+#   - java
+#   - java-1.6.0-openjdk
+#   - java-1.7.0-openjdk
+__java_packages:
+  - java-1.7.0-openjdk
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/vars/Ubuntu-12.04.yml
@@ -0,0 +1,7 @@
+---
+# JDK version options include:
+#   - java
+#   - openjdk-6-jdk
+#   - openjdk-7-jdk
+__java_packages:
+  - openjdk-7-jdk
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/vars/Ubuntu-14.04.yml
@@ -0,0 +1,7 @@
+---
+# JDK version options include:
+#   - java
+#   - openjdk-6-jdk
+#   - openjdk-7-jdk
+__java_packages:
+  - openjdk-7-jdk
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.java/vars/Ubuntu-16.04.yml
@@ -0,0 +1,7 @@
+---
+# JDK version options include:
+#   - java
+#   - openjdk-8-jdk
+#   - openjdk-9-jdk
+__java_packages:
+  - openjdk-8-jdk
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/.travis.yml
@@ -0,0 +1,126 @@
+---
+sudo: required
+
+env:
+  # tests/test.yml
+  - distribution: centos
+    version: 7
+    init: /usr/lib/systemd/systemd
+    run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
+    site: test.yml
+    prefix: ''
+    http_port: 8080
+  - distribution: ubuntu
+    version: 14.04
+    init: /sbin/init
+    run_opts: ""
+    site: test.yml
+    prefix: ''
+    http_port: 8080
+  - distribution: ubuntu
+    version: 12.04
+    init: /sbin/init
+    run_opts: ""
+    site: test.yml
+    prefix: ''
+    http_port: 8080
+
+  # tests/test-http-port.yml
+  - distribution: ubuntu
+    version: 14.04
+    init: /sbin/init
+    run_opts: ""
+    site: test-http-port.yml
+    prefix: ''
+    http_port: 8081
+
+  # tests/test-prefix.yml
+  - distribution: ubuntu
+    version: 14.04
+    init: /sbin/init
+    run_opts: ""
+    site: test-prefix.yml
+    prefix: jenkins
+    http_port: 8080
+
+  # tests/test-jenkins-version.yml
+  - distribution: centos
+    version: 7
+    init: /usr/lib/systemd/systemd
+    run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
+    site: test-jenkins-version.yml
+    prefix: ''
+    http_port: 8080
+  - distribution: ubuntu
+    version: 14.04
+    init: /sbin/init
+    run_opts: ""
+    site: test-jenkins-version.yml
+    prefix: ''
+    http_port: 8080
+
+  # tests/test-plugins.yml
+  - distribution: ubuntu
+    version: 14.04
+    init: /sbin/init
+    run_opts: ""
+    site: test-plugins.yml
+    prefix: ''
+    http_port: 8080
+
+  # tests/test-plugins-with-pinning.yml
+  - distribution: ubuntu
+    version: 14.04
+    init: /sbin/init
+    run_opts: ""
+    site: test-plugins-with-pinning.yml
+    prefix: ''
+    http_port: 8080
+
+services:
+  - docker
+
+before_install:
+  # - sudo apt-get update
+  # Pull container
+  - 'sudo docker pull ${distribution}:${version}'
+  # Customize container
+  - 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
+
+script:
+  - container_id=$(mktemp)
+  # Run container in detached state
+  - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
+
+  # Install dependencies.
+  - 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
+
+  # Ansible syntax check.
+  - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/$site --syntax-check'
+
+  # Test role.
+  - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/$site'
+
+  # Test role idempotence.
+  - idempotence=$(mktemp)
+  - sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/$site | tee -a ${idempotence}
+  - >
+    tail ${idempotence}
+    | grep -q 'changed=0.*failed=0'
+    && (echo 'Idempotence test: pass' && exit 0)
+    || (echo 'Idempotence test: fail' && exit 1)
+
+  # Make sure Jenkins is running.
+  - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm curl http://localhost:$http_port/$prefix'
+
+after_failure:
+  # Check what happened on systemd systems.
+  - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm systemctl -l status jenkins.service'
+  - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm journalctl -xe --no-pager'
+
+after_success:
+  # Clean up
+  - 'sudo docker stop "$(cat ${container_id})"'
+
+notifications:
+  webhooks: https://galaxy.ansible.com/api/v1/notifications/
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/README.md
@@ -0,0 +1,104 @@
+# Ansible Role: Jenkins CI
+
+[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-jenkins.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-jenkins)
+
+Installs Jenkins CI on RHEL/CentOS and Debian/Ubuntu servers.
+
+## Requirements
+
+Requires `curl` to be installed on the server.
+
+## Role Variables
+
+Available variables are listed below, along with default values (see `defaults/main.yml`):
+
+    jenkins_hostname: localhost
+
+The system hostname; usually `localhost` works fine. This will be used during setup to communicate with the running Jenkins instance via HTTP requests.
+
+    jenkins_home: /var/lib/jenkins
+
+The Jenkins home directory which, amongst others, is being used for storing artifacts, workspaces and plugins. This variable allows you to override the default `/var/lib/jenkins` location.
+
+    jenkins_http_port: 8080
+
+The HTTP port for Jenkins' web interface.
+
+    jenkins_admin_username: admin
+    jenkins_admin_password: admin
+
+Default admin account credentials which will be created the first time Jenkins is installed.
+
+    jenkins_admin_password_file: ""
+
+Default admin password file which will be created the first time Jenkins is installed as /var/lib/jenkins/secrets/initialAdminPassword
+
+    jenkins_jar_location: /opt/jenkins-cli.jar
+
+The location at which the `jenkins-cli.jar` jarfile will be kept. This is used for communicating with Jenkins via the CLI.
+
+    jenkins_plugins: []
+
+Jenkins plugins to be installed automatically during provisioning. (_Note_: This feature is currently undergoing some changes due to the `jenkins-cli` authentication changes in Jenkins 2.0, and may not work as expected.)
+
+    jenkins_version: "1.644"
+    jenkins_pkg_url: "http://www.example.com/"
+
+(Optional) Then Jenkins version can be pinned to any version available on `http://pkg.jenkins-ci.org/debian/` (Debian/Ubuntu) or `http://pkg.jenkins-ci.org/redhat/` (RHEL/CentOS). If the Jenkins version you need is not available in the default package URLs, you can override the URL with your own; set `jenkins_pkg_url` (_Note_: the role depends on the same naming convention that `http://pkg.jenkins-ci.org/` uses).
+
+    jenkins_url_prefix: ""
+
+Used for setting a URL prefix for your Jenkins installation. The option is added as `--prefix={{ jenkins_url_prefix }}` to the Jenkins initialization `java` invocation, so you can access the installation at a path like `http://www.example.com{{ jenkins_url_prefix }}`. Make sure you start the prefix with a `/` (e.g. `/jenkins`).
+
+    jenkins_connection_delay: 5
+    jenkins_connection_retries: 60
+
+Amount of time and number of times to wait when connecting to Jenkins after initial startup, to verify that Jenkins is running. Total time to wait = `delay` * `retries`, so by default this role will wait up to 300 seconds before timing out.
+
+    # For RedHat/CentOS (role default):
+    jenkins_repo_url: http://pkg.jenkins-ci.org/redhat/jenkins.repo
+    jenkins_repo_key_url: http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
+    # For Debian (role default):
+    jenkins_repo_url: deb http://pkg.jenkins-ci.org/debian binary/
+    jenkins_repo_key_url: http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key
+
+This role will install the latest version of Jenkins by default (using the official repositories as listed above). You can override these variables (use the correct set for your platform) to install the current LTS version instead:
+
+    # For RedHat/CentOS LTS:
+    jenkins_repo_url: http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
+    jenkins_repo_key_url: http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
+    # For Debian/Ubuntu LTS:
+    jenkins_repo_url: deb http://pkg.jenkins-ci.org/debian-stable binary/
+    jenkins_repo_key_url: http://pkg.jenkins-ci.org/debian-stable/jenkins-ci.org.key
+
+    jenkins_java_options: "-Djenkins.install.runSetupWizard=false"
+
+Extra Java options for the Jenkins launch command configured in the init file can be set with the var `jenkins_java_options`. By default the option to disable the Jenkins 2.0 setup wizard is added.
+
+    jenkins_init_changes:
+      - option: "JENKINS_ARGS"
+        value: "--prefix={{ jenkins_url_prefix }}"
+      - option: "JENKINS_JAVA_OPTIONS"
+        value: "{{ jenkins_java_options }}"
+
+Changes made to the Jenkins init script; the default set of changes set the configured URL prefix and add in configured Java options for Jenkins' startup. You can add other option/value pairs if you need to set other options for the Jenkins init file.
+
+## Dependencies
+
+  - geerlingguy.java
+
+## Example Playbook
+
+    - hosts: ci-server
+      vars:
+        jenkins_hostname: jenkins.example.com
+      roles:
+        - geerlingguy.jenkins
+
+## License
+
+MIT (Expat) / BSD
+
+## Author Information
+
+This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/).
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/defaults/main.yml
@@ -0,0 +1,25 @@
+---
+# Optional method of pinning a specific version of Jenkins and/or overriding the
+# default Jenkins packaging URL.
+# jenkins_version: "1.644"
+# jenkins_pkg_url: "https://www.example.com/"
+
+jenkins_connection_delay: 5
+jenkins_connection_retries: 60
+jenkins_home: /var/lib/jenkins
+jenkins_hostname: localhost
+jenkins_http_port: 8080
+jenkins_jar_location: /opt/jenkins-cli.jar
+jenkins_plugins: []
+jenkins_url_prefix: ""
+jenkins_java_options: "-Djenkins.install.runSetupWizard=false"
+
+jenkins_admin_username: admin
+jenkins_admin_password: admin
+jenkins_admin_password_file: ""
+
+jenkins_init_changes:
+  - option: "JENKINS_ARGS"
+    value: "--prefix={{ jenkins_url_prefix }}"
+  - option: "JENKINS_JAVA_OPTIONS"
+    value: "{{ jenkins_java_options }}"
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/handlers/main.yml
@@ -0,0 +1,9 @@
+---
+- name: restart jenkins
+  service: name=jenkins state=restarted
+
+- name: configure default users
+  template:
+    src: basic-security.groovy
+    dest: "{{ jenkins_home }}/init.groovy.d/basic-security.groovy"
+  register: jenkins_users_config
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/meta/.galaxy_install_info
@@ -0,0 +1,1 @@
+{install_date: 'Thu Aug 25 19:21:12 2016', version: 2.5.0}
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/meta/main.yml
@@ -0,0 +1,24 @@
+---
+dependencies:
+  - geerlingguy.java
+
+galaxy_info:
+  author: geerlingguy
+  description: Jenkins CI
+  company: "Midwestern Mac, LLC"
+  license: "license (BSD, MIT)"
+  min_ansible_version: 1.9
+  platforms:
+  - name: EL
+    versions:
+    - 6
+    - 7
+  - name: Debian
+    versions:
+    - all
+  - name: Ubuntu
+    versions:
+    - all
+  galaxy_tags:
+    - development
+    - packaging
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tasks/main.yml
@@ -0,0 +1,58 @@
+---
+# Variable setup.
+- name: Include OS-Specific variables
+  include_vars: "{{ ansible_os_family }}.yml"
+
+- name: Define jenkins_repo_url
+  set_fact:
+    jenkins_repo_url: "{{ __jenkins_repo_url }}"
+  when: jenkins_repo_url is not defined
+
+- name: Define jenkins_repo_key_url
+  set_fact:
+    jenkins_repo_key_url: "{{ __jenkins_repo_key_url }}"
+  when: jenkins_repo_key_url is not defined
+
+- name: Define jenkins_pkg_url
+  set_fact:
+    jenkins_pkg_url: "{{ __jenkins_pkg_url }}"
+  when: jenkins_pkg_url is not defined
+
+# Setup/install tasks.
+- include: setup-RedHat.yml
+  when: ansible_os_family == 'RedHat'
+
+- include: setup-Debian.yml
+  when: ansible_os_family == 'Debian'
+
+# Configure Jenkins init settings.
+- include: settings.yml
+
+# Make sure Jenkins starts, then configure Jenkins.
+- name: Ensure Jenkins is started and runs on startup.
+  service: name=jenkins state=started enabled=yes
+
+- name: Wait for Jenkins to start up before proceeding.
+  shell: "curl -D - --silent --max-time 5 http://{{ jenkins_hostname }}:{{ jenkins_http_port }}{{ jenkins_url_prefix }}/cli/"
+  register: result
+  until: (result.stdout.find("403 Forbidden") != -1) or (result.stdout.find("200 OK") != -1) and (result.stdout.find("Please wait while") == -1)
+  retries: "{{ jenkins_connection_retries }}"
+  delay: "{{ jenkins_connection_delay }}"
+  changed_when: false
+
+- name: Get the jenkins-cli jarfile from the Jenkins server.
+  get_url:
+    url: "http://{{ jenkins_hostname }}:{{ jenkins_http_port }}{{ jenkins_url_prefix }}/jnlpJars/jenkins-cli.jar"
+    dest: "{{ jenkins_jar_location }}"
+  register: jarfile_get
+  until: "'OK' in jarfile_get.msg or 'file already exists' in jarfile_get.msg"
+  retries: 5
+  delay: 10
+
+- name: Remove Jenkins security init scripts after first startup.
+  file:
+    path: "{{ jenkins_home }}/init.groovy.d/basic-security.groovy"
+    state: absent
+
+# Update Jenkins and install configured plugins.
+- include: plugins.yml
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tasks/plugins.yml
@@ -0,0 +1,51 @@
+---
+# Jenkins doesn't allow updates via CLI, though that is required before plugins
+# can be installed via CLI. See: https://gist.github.com/rowan-m/1026918
+- name: Create Jenkins updates folder.
+  file:
+    path: "{{ jenkins_home }}/updates"
+    owner: jenkins
+    group: jenkins
+    mode: 0755
+    state: directory
+  register: jenkins_plugins_folder_create
+
+- name: Update Jenkins plugin data.
+  shell: curl -L https://updates.jenkins-ci.org/update-center.json | sed '1d;$d' > "{{ jenkins_home }}/updates/default.json"
+  args:
+    creates: "{{ jenkins_home }}/updates/default.json"
+
+- name: Permissions for default.json updates info.
+  file:
+    path: "{{ jenkins_home }}/updates/default.json"
+    owner: jenkins
+    group: jenkins
+    mode: 0755
+  when: jenkins_plugins_folder_create.changed
+
+- name: Check if we're using a password file for authentication
+  stat:
+    path: "{{ jenkins_admin_password_file }}"
+  register: adminpasswordfile
+
+- name: Install Jenkins plugins using password.
+  command: >
+    java -jar {{ jenkins_jar_location }} -s http://{{ jenkins_hostname }}:{{ jenkins_http_port }}{{ jenkins_url_prefix | default('') }}/
+    install-plugin {{ item }}
+    --username {{ jenkins_admin_username }}
+    --password {{ jenkins_admin_password }}
+    creates="{{ jenkins_home }}/plugins/{{ item }}.jpi"
+  with_items: "{{ jenkins_plugins }}"
+  when: jenkins_admin_password != ""
+  notify: restart jenkins
+
+- name: Install Jenkins plugins using password-file.
+  command: >
+    java -jar {{ jenkins_jar_location }} -s http://{{ jenkins_hostname }}:{{ jenkins_http_port }}{{ jenkins_url_prefix | default('') }}/
+    install-plugin {{ item }}
+    --username {{ jenkins_admin_username }}
+    --password-file {{ jenkins_admin_password_file }}
+    creates={{ jenkins_home }}/plugins/{{ item }}.jpi
+  with_items: "{{ jenkins_plugins }}"
+  when: adminpasswordfile.stat.exists == True
+  notify: restart jenkins
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tasks/settings.yml
@@ -0,0 +1,47 @@
+---
+- name: Modify variables in init file
+  lineinfile:
+    dest: "{{ jenkins_init_file }}"
+    insertafter: '^{{ item.option }}='
+    regexp: '^{{ item.option}}=\"\${{ item.option }} '
+    line: '{{ item.option }}="${{ item.option }} {{ item.value }}"'
+    state: present
+  with_items:
+      "{{ jenkins_init_changes }}"
+  register: jenkins_init_prefix
+
+- name: Set the Jenkins home directory
+  lineinfile:
+    dest: "{{ jenkins_init_file }}"
+    regexp: '^JENKINS_HOME=.*'
+    line: 'JENKINS_HOME={{ jenkins_home }}'
+  register: jenkins_home_config
+
+- name: Immediately restart Jenkins on init config changes.
+  service: name=jenkins state=restarted
+  when: jenkins_init_prefix.changed
+
+- name: Set HTTP port in Jenkins config.
+  lineinfile:
+    backrefs: yes
+    dest: "{{ jenkins_init_file }}"
+    regexp: '^{{ jenkins_http_port_param }}='
+    line: '{{ jenkins_http_port_param }}={{ jenkins_http_port }}'
+  register: jenkins_http_config
+
+- name: Create custom init scripts directory.
+  file:
+    path: "{{ jenkins_home }}/init.groovy.d"
+    state: directory
+    owner: jenkins
+    group: jenkins
+    mode: 0775
+
+- name: Trigger handlers immediately in case Jenkins was installed
+  meta: flush_handlers
+
+- name: Immediately restart Jenkins on http or user changes.
+  service: name=jenkins state=restarted
+  when: (jenkins_users_config is defined and jenkins_users_config.changed) or
+        (jenkins_http_config is defined and jenkins_http_config.changed) or
+        (jenkins_home_config is defined and jenkins_home_config.changed)
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tasks/setup-Debian.yml
@@ -0,0 +1,46 @@
+---
+- name: Ensure dependencies are installed.
+  apt:
+    pkg: curl
+    state: installed
+
+- name: Add Jenkins apt repository key.
+  apt_key:
+    url: "{{ jenkins_repo_key_url }}"
+    state: present
+
+- name: Add Jenkins apt repository.
+  apt_repository:
+    repo: "{{ jenkins_repo_url }}"
+    state: present
+    update_cache: yes
+
+- name: Download specific Jenkins version.
+  get_url:
+    url: "{{ jenkins_pkg_url }}/jenkins_{{ jenkins_version }}_all.deb"
+    dest: "/tmp/jenkins.deb"
+  when: jenkins_version is defined
+
+- name: Check if we downloaded a specific version of Jenkins.
+  stat:
+    path: "/tmp/jenkins.deb"
+  register: specific_version
+
+- name: Install our specific version of Jenkins.
+  apt:
+    deb: "/tmp/jenkins.deb"
+    state: installed
+  when: specific_version.stat.exists
+  notify: configure default users
+
+- name: Validate Jenkins is installed and register package name.
+  apt:
+    name: jenkins
+    state: present
+  notify: configure default users
+
+- name: Install Jenkins from repository.
+  apt:
+    name: jenkins
+    state: installed
+  when: jenkins_version is undefined
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tasks/setup-RedHat.yml
@@ -0,0 +1,46 @@
+---
+- name: Ensure dependencies are installed.
+  yum:
+    pkg: curl
+    state: installed
+
+- name: Ensure Jenkins repo is installed.
+  get_url:
+    url: "{{ jenkins_repo_url }}"
+    dest: /etc/yum.repos.d/jenkins.repo
+
+- name: Add Jenkins repo GPG key.
+  rpm_key:
+    state: present
+    key: "{{ jenkins_repo_key_url }}"
+
+- name: Download specific Jenkins version.
+  get_url:
+    url: "{{ jenkins_pkg_url }}/jenkins-{{ jenkins_version }}-1.1.noarch.rpm"
+    dest: "/tmp/jenkins.rpm"
+  when: jenkins_version is defined
+
+- name: Check if we downloaded a specific version of Jenkins.
+  stat:
+    path: "/tmp/jenkins.rpm"
+  register: specific_version
+
+- name: Install our specific version of Jenkins.
+  yum:
+    name: "/tmp/jenkins.rpm"
+    state: installed
+  when: specific_version.stat.exists
+  notify: configure default users
+
+- name: Validate Jenkins is installed and register package name.
+  yum:
+    name: jenkins
+    state: present
+  when: not specific_version.stat.exists
+  notify: configure default users
+
+- name: Install Jenkins from repository.
+  yum:
+    name: jenkins
+    state: installed
+  when: jenkins_version is undefined
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/templates/basic-security.groovy
@@ -0,0 +1,19 @@
+#!groovy
+import hudson.security.*
+import jenkins.model.*
+
+def instance = Jenkins.getInstance()
+
+println "--> Checking if security has been set already"
+
+if (!instance.isUseSecurity()) {
+    println "--> creating local user 'admin'"
+
+    def hudsonRealm = new HudsonPrivateSecurityRealm(false)
+    hudsonRealm.createAccount('{{ jenkins_admin_username }}', '{{ jenkins_admin_password }}')
+    instance.setSecurityRealm(hudsonRealm)
+
+    def strategy = new FullControlOnceLoggedInAuthorizationStrategy()
+    instance.setAuthorizationStrategy(strategy)
+    instance.save()
+}
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/Dockerfile.centos-6
@@ -0,0 +1,20 @@
+FROM centos:6
+MAINTAINER Jeff Geerling
+
+# Install Ansible
+RUN yum makecache fast \
+ && yum -y install deltarpm epel-release \
+ && yum -y update \
+ && yum -y install \
+      ansible \
+      git \
+      sudo \
+ && yum clean all
+
+# Disable requiretty
+RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/'  /etc/sudoers
+
+# Install Ansible inventory file
+RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
+
+CMD ["/usr/sbin/init"]
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/Dockerfile.centos-7
@@ -0,0 +1,32 @@
+FROM centos:7
+MAINTAINER Jeff Geerling
+ENV container=docker
+
+# Install systemd -- See https://hub.docker.com/_/centos/
+RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
+rm -f /lib/systemd/system/multi-user.target.wants/*;\
+rm -f /etc/systemd/system/*.wants/*;\
+rm -f /lib/systemd/system/local-fs.target.wants/*; \
+rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
+rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
+rm -f /lib/systemd/system/basic.target.wants/*;\
+rm -f /lib/systemd/system/anaconda.target.wants/*;
+
+# Install Ansible and other requirements.
+RUN yum makecache fast \
+ && yum -y install deltarpm epel-release initscripts \
+ && yum -y update \
+ && yum -y install \
+      ansible \
+      git \
+      sudo \
+ && yum clean all
+
+# Disable requiretty
+RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/'  /etc/sudoers
+
+# Install Ansible inventory file
+RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts
+
+VOLUME ["/sys/fs/cgroup"]
+CMD ["/usr/sbin/init"]
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/Dockerfile.ubuntu-12.04
@@ -0,0 +1,25 @@
+FROM ubuntu:12.04
+MAINTAINER Jeff Geerling
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt-get update \
+    && apt-get install -y --no-install-recommends \
+       software-properties-common \
+       python-software-properties \
+       git \
+    && rm -rf /var/lib/apt/lists/* \
+    && rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
+    && apt-get clean
+# Install Ansible
+RUN apt-add-repository -y ppa:ansible/ansible \
+    && apt-get update \
+    && apt-get install -y --no-install-recommends \
+       ansible \
+    && rm -rf /var/lib/apt/lists/* \
+    && rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
+    && touch -m -t 200101010101.01 /var/lib/apt/periodic/update-success-stamp \
+    && apt-get clean
+
+# Install Ansible inventory file
+RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/Dockerfile.ubuntu-14.04
@@ -0,0 +1,22 @@
+FROM ubuntu:14.04
+MAINTAINER Jeff Geerling
+
+ENV DEBIAN_FRONTEND noninteractive
+
+RUN apt-get update \
+    && apt-get install -y --no-install-recommends \
+       software-properties-common git \
+    && rm -Rf /var/lib/apt/lists/* \
+    && rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
+    && apt-get clean
+# Install Ansible
+RUN apt-add-repository -y ppa:ansible/ansible \
+    && apt-get update \
+    && apt-get install -y --no-install-recommends \
+       ansible \
+    && rm -rf /var/lib/apt/lists/* \
+    && rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
+    && apt-get clean
+
+# Install Ansible inventory file
+RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/requirements.yml
@@ -0,0 +1,2 @@
+---
+- src: geerlingguy.java
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/test-http-port.yml
@@ -0,0 +1,9 @@
+---
+- hosts: all
+
+  vars:
+    jenkins_http_port: 8081
+
+  roles:
+    - geerlingguy.java
+    - role_under_test
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/test-jenkins-version.yml
@@ -0,0 +1,7 @@
+- hosts: localhost
+  vars:
+    jenkins_version: 1.644
+
+  roles:
+    - geerlingguy.java
+    - role_under_test
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/test-plugins-with-pinning.yml
@@ -0,0 +1,9 @@
+- hosts: localhost
+  vars:
+    jenkins_version: 2.14
+    jenkins_plugins:
+      - ant
+
+  roles:
+    - geerlingguy.java
+    - role_under_test
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/test-plugins.yml
@@ -0,0 +1,10 @@
+---
+- hosts: all
+
+  vars:
+    jenkins_plugins:
+      - ant
+
+  roles:
+    - geerlingguy.java
+    - role_under_test
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/test-prefix.yml
@@ -0,0 +1,9 @@
+---
+- hosts: all
+
+  vars:
+    jenkins_url_prefix: /jenkins
+
+  roles:
+    - geerlingguy.java
+    - role_under_test
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/tests/test.yml
@@ -0,0 +1,6 @@
+---
+- hosts: all
+
+  roles:
+    - geerlingguy.java
+    - role_under_test
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/vars/Debian.yml
@@ -0,0 +1,6 @@
+---
+__jenkins_repo_url: deb http://pkg.jenkins.io/debian binary/
+__jenkins_repo_key_url: http://pkg.jenkins.io/debian/jenkins.io.key
+__jenkins_pkg_url: http://pkg.jenkins.io/debian/binary/
+jenkins_init_file: /etc/default/jenkins
+jenkins_http_port_param: HTTP_PORT
new file mode 100644
--- /dev/null
+++ b/ansible/vendor-roles/geerlingguy.jenkins/vars/RedHat.yml
@@ -0,0 +1,6 @@
+---
+__jenkins_repo_url: http://pkg.jenkins.io/redhat/jenkins.repo
+__jenkins_repo_key_url: http://pkg.jenkins.io/redhat/jenkins.io.key
+__jenkins_pkg_url: http://pkg.jenkins.io/redhat
+jenkins_init_file: /etc/sysconfig/jenkins
+jenkins_http_port_param: JENKINS_PORT