Ansible Galaxy DovnarAlexander/jenkins
This role helps you to install any version of Jenkins (LTS and Not). It manages:
- Jenkins users;
- Credentials (SSH including key generation, Secret Text and Username-Password);
- Installs plugins;
- Jenkins Slaves (JNLP and SSH);
- Some Jenkins main configuration (the main Hostname and Email).
- You can manage as much as possible when you do not have direct SSH connection to Jenkins with "Remote_Jenkins" tag.
# file: defaults/main.yml
# Do you want install Jenkins from stable rep or not
jenkins_stable: True
If you want to install non-LTS version - set it to False.
# file: defaults/main.yml
# What version should be installed
jenkins_version: latest
If you want to install some specific version - input full version here (x.xx.x)
# file: defaults/main.yml
# Do you want to updated the Jenkins (if older version has been already installed)
jenkins_update: False
If you do not want to update the version to the latest - set it to True.
# file: defaults/main.yml
# Jenkins HTTP port
jenkins_http_port: 8080
You can change the default HTTP port here.
# file: defaults/main.yml
# Jenkins Home path
jenkins_home: /var/lib/jenkins
You can change default Jenkins Home path here.
# file: defaults/main.yml
# Jenkins External Hostname for main configuration
jenkins_notification_hostname: 'http://{{ inventory_hostname }}:{{ jenkins_http_port }}/'
You can set external Jenkins Hostname here manually.
# file: defaults/main.yml
# Jenkins EEmail for main configuration
jenkins_notification_email: 'admin@example.com'
You can set Jenkins Notification Email here.
# file: defaults/main.yml
# Jenkins New Admin details
jenkins_admin:
id: jenkins
password: jenkins
By default it is a not good idea to use default admin credentials. If you insist - you can change id to 'admin' and password for anything you want.
# file: defaults/main.yml
# Jenkins admin token location
jenkins_admin_token_file: '{{ jenkins_home }}/secrets/admin_token'
You can specify local place to store Jenkins Admin token.
# file: defaults/main.yml
# List of required users to create
# jenkins_users:
# -
# id: test-user
# email: test-user@gmail.com
# password: test-user
jenkins_users: []
You can create the required amount of users using this list of dicts.
# file: defaults/main.yml
# List of required Jenkins plugins to install
jenkins_plugins:
- git
- workflow-aggregator
- jobConfigHistory
- ssh
- ssh-slaves
- mailer
The list of Jenkins plugins which should be installed during installation.
# file: defaults/main.yml
# List of Nodes to create\configure
# jenkins_nodes:
# -
# name: master
# type: master
# labels: master
# executors: 7
# -
# name: test-jnlp
# executors: 1
# labels: test-jnlp
# type: jnlp
# home_path: /home/jenkins
# description: 'test-jnlp'
# -
# name: test-ssh
# executors: 1
# labels: test-ssh
# type: ssh
# external_host: 127.0.0.1
# credentials: jenkins-local-slave
# home_path: '/var/lib/jenkins'
# description: 'test-ssh'
# environment:
# FOO: bar
# BAR: foo
jenkins_nodes: []
You can create the required slaves using this variable. It also helps to change number of executors for every slave and to manage environment variables for the slaves.
# file: defaults/main.yml
# Jenkins user-password pairs credentials
# jenkins_userpass_credentials:
# -
# id: test-credentials
# description: "For test"
# username: test-credentials-user
# password: test-credentials-password
jenkins_userpass_credentials: []
Using this list of dicts you can create all required username-password pair credentials.
# file: defaults/main.yml
# Jenkins secret-text credentials
# jenkins_secret_text_credentials:
# -
# id: test-text-credentials
# description: "For test"
# secret_text: test-text-credentials
jenkins_secret_text_credentials: []
Using this list of dicts you can create all required secret text credentials.
# file: defaults/main.yml
# Jenkins SSH credentials
# jenkins_ssh_credentials:
# -
# id: test-ssh-user
# username: test-ssh-user
# print: True
# description: "For test"
# -
# id: jenkins-local-slave
# username: jenkins
# local: True
# description: "For test"
jenkins_ssh_credentials: []
Using this list of dicts you can create all required SSH credentials.
# file: defaults/main.yml
# Required Python Pip packages
pip_packages:
- setuptools
- lxml
- python-jenkins
- pyopenssl
- urllib3
The list of Python Pip packages to install.
# file: defaults/main.yml
# Pip index URL
pip_index_url: https://pypi.python.org/simple/
Full URL to pipy installation simple repository.
Jenkins Process Linux owner.
# file: defaults/main.yml
# Jenkins system user
jenkins_system_user: jenkins
Jenkins Process Linux owner.
Add role name DovnarAlexander.jenkins
to your playbook file.
If you want to install Java using DovnarAlexander/oracle-java playbook - install it with requirements.yml
ansible-galaxy install DovnarAlexander.oracle-java
If you need - modify variables your playbook\variables file.
Simple example:
---
# file: simple-playbook.yml
- hosts: all
roles:
- DovnarAlexander.oracle-java
- DovnarAlexander.jenkins
vars:
jenkins_version: 2.60.3
jenkins_plugins:
- git
- workflow-aggregator
- jobConfigHistory
- ssh
- ssh-slaves
- powershell
---
# file:inventory.ini
[jenkins]
your_host
[java:children]
jenkins
java:
children:
jenkins:
hosts:
your_host: