Razique Mahroua
2020-03-18 b85c91a8192593f6b62f93e11c971868964343a9
commit | author | age
bf37eb 1 # Ansible Role: Jenkins CI
ec58c9 2
bf37eb 3 [![Build Status](https://travis-ci.org/geerlingguy/ansible-role-jenkins.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-jenkins)
ec58c9 4
bf37eb 5 Installs Jenkins CI on RHEL/CentOS and Debian/Ubuntu servers.
ec58c9 6
bf37eb 7 ## Requirements
ec58c9 8
bf37eb 9 Requires `curl` to be installed on the server. Also, newer versions of Jenkins require Java 8+ (see the test playbooks inside the `tests/` directory for an example of how to use newer versions of Java for your OS).
ec58c9 10
bf37eb 11 ## Role Variables
ec58c9 12
bf37eb 13 Available variables are listed below, along with default values (see `defaults/main.yml`):
ec58c9 14
bf37eb 15     jenkins_package_state: present
ec58c9 16
bf37eb 17 The state of the `jenkins` package install. By default this role installs Jenkins but will not upgrade Jenkins (when using package-based installs). If you want to always update to the latest version, change this to `latest`.
ec58c9 18
bf37eb 19     jenkins_hostname: localhost
ec58c9 20
bf37eb 21 The system hostname; usually `localhost` works fine. This will be used during setup to communicate with the running Jenkins instance via HTTP requests.
ec58c9 22
bf37eb 23     jenkins_home: /var/lib/jenkins
ec58c9 24
bf37eb 25 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.
ec58c9 26
bf37eb 27     jenkins_http_port: 8080
ec58c9 28
bf37eb 29 The HTTP port for Jenkins' web interface.
EL 30
31     jenkins_admin_username: admin
32     jenkins_admin_password: admin
33
34 Default admin account credentials which will be created the first time Jenkins is installed.
35
36     jenkins_admin_password_file: ""
37
38 Default admin password file which will be created the first time Jenkins is installed as /var/lib/jenkins/secrets/initialAdminPassword
39
40     jenkins_admin_token: ""
41
42 A Jenkins API token (generated after installation) for [authenticated scripted clients](https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients). You can use the admin token instead of a username and password for more convenient scripted access to Jenkins (e.g. for plugin management through this role).
43
44     jenkins_admin_token_file: ""
45
46 A file (with full path) on the Jenkins server containing the admin token. If this variable is set in addition to the `jenkins_admin_token`, the contents of this file will overwrite the value of `jenkins_admin_token`.
47
48     jenkins_jar_location: /opt/jenkins-cli.jar
49
50 The location at which the `jenkins-cli.jar` jarfile will be kept. This is used for communicating with Jenkins via the CLI.
51
52     jenkins_plugins: []
53
54 Jenkins plugins to be installed automatically during provisioning.
55
56     jenkins_plugins_install_dependencies: yes
57
58 Whether Jenkins plugins to be installed should also install any plugin dependencies.
59
60     jenkins_plugins_state: present
61
62 Use `latest` to ensure all plugins are running the most up-to-date version.
63
64     jenkins_plugin_updates_expiration: 86400
65
66 Number of seconds after which a new copy of the update-center.json file is downloaded. Set it to 0 if no cache file should be used.
67
68     jenkins_plugin_timeout: 30
69
70 The server connection timeout, in seconds, when installing Jenkins plugins.
71
72     jenkins_version: "1.644"
73     jenkins_pkg_url: "http://www.example.com"
74
75 (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).
76
77     jenkins_url_prefix: ""
78
79 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`).
80
81     jenkins_connection_delay: 5
82     jenkins_connection_retries: 60
83
84 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.
85
86     # For RedHat/CentOS (role default):
87     jenkins_repo_url: http://pkg.jenkins-ci.org/redhat/jenkins.repo
88     jenkins_repo_key_url: http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
89     # For Debian (role default):
90     jenkins_repo_url: deb http://pkg.jenkins-ci.org/debian binary/
91     jenkins_repo_key_url: http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key
92
93 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:
94
95     # For RedHat/CentOS LTS:
96     jenkins_repo_url: http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
97     jenkins_repo_key_url: http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
98     # For Debian/Ubuntu LTS:
99     jenkins_repo_url: deb http://pkg.jenkins-ci.org/debian-stable binary/
100     jenkins_repo_key_url: http://pkg.jenkins-ci.org/debian-stable/jenkins-ci.org.key
101
102 It is also possible stop the repo file being added by setting  `jenkins_repo_url = ''`. This is useful if, for example, you sign your own packages or run internal package management (e.g. Spacewalk).
103
104     jenkins_java_options: "-Djenkins.install.runSetupWizard=false"
105
106 Extra Java options for the Jenkins launch command configured in the init file can be set with the var `jenkins_java_options`. For example, if you want to configure the timezone Jenkins uses, add `-Dorg.apache.commons.jelly.tags.fmt.timeZone=America/New_York`. By default, the option to disable the Jenkins 2.0 setup wizard is added.
107
108     jenkins_init_changes:
109       - option: "JENKINS_ARGS"
110         value: "--prefix={{ jenkins_url_prefix }}"
111       - option: "JENKINS_JAVA_OPTIONS"
112         value: "{{ jenkins_java_options }}"
113
114 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.
115
116 ## Dependencies
117
118   - geerlingguy.java
119
120 ## Example Playbook
121
122 ```yaml
123 - hosts: jenkins
124   vars:
125     jenkins_hostname: jenkins.example.com
126   roles:
127     - role: geerlingguy.java
128     - role: geerlingguy.jenkins
129       become: true
130 ```
131
132 ## License
133
134 MIT (Expat) / BSD
135
136 ## Author Information
137
138 This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).