ansible-jenkins is an Ansible role. Use this role to install Jenkins and install/update plugins.
- Latest Jenkins server
- Jenkins plugins support
- Ansible 2.2 or higher
- Debian 8, Ubuntu 14, CentOS 7, FreeBSD 10 or later
- Vagrant (optional)
$ ansible-galaxy install flyapen.jenkins
$ git clone https://github.com/ICTO/ansible-jenkins.git roles
The code should reside in the roles directory of ansible ( See ansible documentation for more information on roles ), in a folder jenkins.
Following example make ansible aware of the Vagrant box reachable on localhost port 2222.
$ vi ansible.host
with
[jenkins]
127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user=vagrant ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
Make the host_vars
directory where ansible.host file is located.
$ mkdir host_vars
Create a file in the newly created directory matching your host.
$ cd host_vars
$ vi 127.0.0.1
with
---
plugins:
- 'ldap'
- 'github'
- 'translation'
- 'preSCMbuildstep'
email:
smtp_host: 'mail.example.com'
smtp_ssl: 'true'
default_email_suffix: '@example.com'
#jenkins_admin_user: admin
#jenkins_admin_password: admin
Take a look at the defaults/main.yml file which contains all possible variables.
First create a playbook including the jenkins role, naming it jenkins.yml.
- name: Jenkins
hosts: jenkins
roles:
# install jenkins
- { role: jenkins, become: yes, become_user: root }
Use ansible.host as inventory. Run the playbook only for the remote host jenkins. Use vagrant as the SSH user to connect to the remote host. -k enables the SSH password prompt.
$ ansible-playbook -i ansible.host jenkins.yml