geerlingguy.jenkins
Ansible Role: Jenkins CI
This role installs Jenkins CI on RHEL/CentOS and Debian/Ubuntu servers.
Requirements
You need to have curl
installed on the server. Newer versions of Jenkins also require Java 8 or higher. Check the test playbooks in the molecule/default
directory for how to use recent Java versions for your OS.
Role Variables
Here are the available variables along with their default values (see defaults/main.yml
):
jenkins_package_state:
present
This sets whether to install Jenkins. By default, it installs Jenkins without upgrading it. To always keep Jenkins updated, set it tolatest
.jenkins_hostname:
localhost
The hostname for the system;localhost
usually works. This will be used to connect to Jenkins.jenkins_home:
/var/lib/jenkins
The home directory for Jenkins, where it stores files. You can change this default directory.jenkins_http_port:
8080
The port Jenkins uses for its web interface.jenkins_admin_username:
admin
jenkins_admin_password:
admin
These are the default credentials for the admin account created on the first installation of Jenkins.jenkins_admin_password_file:
""
This file will be created to store the admin password on the initial installation, located at/var/lib/jenkins/secrets/initialAdminPassword
.jenkins_jar_location:
/opt/jenkins-cli.jar
This is where thejenkins-cli.jar
file will be stored for command-line interactions with Jenkins.jenkins_plugins:
blueocean
name: influxdb
,version: "1.12.1"
These are the Jenkins plugins you want to install automatically. You can specify versions.
jenkins_plugins_install_dependencies:
true
This determines if plugin dependencies should be installed alongside the main plugins.jenkins_plugins_state:
present
Change tolatest
to keep all plugins updated. For plugins with specific versions set,present
will be used instead.jenkins_plugin_updates_expiration:
86400
This is the amount of time in seconds after which Jenkins will download a new updates file. Set to0
to disable caching.jenkins_updates_url:
"https://updates.jenkins.io"
The URL for Jenkins plugin updates.jenkins_plugin_timeout:
30
The timeout duration in seconds for connecting to Jenkins while installing plugins.jenkins_version:
"2.346"
jenkins_pkg_url:
"http://www.example.com"
(Optional) Specify any version you need for Jenkins from the default package URLs or override this with your own.jenkins_url_prefix:
""
Set a prefix for accessing Jenkins. For example,/jenkins
.jenkins_connection_delay:
5
jenkins_connection_retries:
60
This sets the time to wait and the number of attempts to connect to Jenkins after it starts. The total wait time isdelay * retries
(default is 300 seconds).jenkins_prefer_lts:
false
By default, the latest version of Jenkins is installed. Set this totrue
to install the Long-Term Support (LTS) version instead.
The default repository URLs can be customized as well:
For RedHat/CentOS:
- jenkins_repo_url:
https://pkg.jenkins.io/redhat{{ '-stable' if (jenkins_prefer_lts | bool) else '' }}/jenkins.repo
- jenkins_repo_key_url:
https://pkg.jenkins.io/redhat{{ '-stable' if (jenkins_prefer_lts | bool) else '' }}/jenkins.io.key
- jenkins_repo_url:
For Debian/Ubuntu:
- jenkins_repo_url:
deb https://pkg.jenkins.io/debian{{ '-stable' if (jenkins_prefer_lts | bool) else '' }} binary/
- jenkins_repo_key_url:
https://pkg.jenkins.io/debian{{ '-stable' if (jenkins_prefer_lts | bool) else '' }}/jenkins.io.key
- jenkins_repo_url:
You can prevent the repo file from being added by setting jenkins_repo_url: ''
, useful if you handle your own packages.
jenkins_options:
""
This allows you to add extra options for Jenkins on startup.jenkins_java_options:
"-Djenkins.install.runSetupWizard=false"
This allows you to set additional Java options for Jenkins on startup, such as disabling the setup wizard.jenkins_init_changes:
This sets various initialization options for Jenkins, including the options for Jenkins and Java on startup.jenkins_proxy_host:
""
jenkins_proxy_port:
""
jenkins_proxy_noproxy:
"127.0.0.1"
"localhost"
Use these settings if running Jenkins behind a proxy.
Dependencies
There are no dependencies for this role.
Example Playbook
- hosts: jenkins
become: true
vars:
jenkins_hostname: jenkins.example.com
java_packages:
- openjdk-8-jdk
roles:
- role: geerlingguy.java
- role: geerlingguy.jenkins
Note: The java_packages
might need different versions based on your distribution (e.g., openjdk-11-jdk
for Debian 10, or java-1.8.0-openjdk
for RHEL 7 or 8).
License
MIT (Expat) / BSD
Author Information
This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.
ansible-galaxy install geerlingguy.jenkins