mircomasa.jenkins_slave
jenkins-slave role
This role sets up a new jenkins slave node and adds it to the jenkins master.
Requirements
- Version of the ansible for installation: >=2.8
- Supported OS
- EL
- 7
- 8
- Amazon Linux 2
- Ubuntu
- xenial
- bionic
- Debian
- stretch
- Windows
- 2016
- 2019
- EL
Dependencies
Role Variables
required
master_usernameJenkins master CLI user name. Default value isadmin.master_passwordJenkins master CLI user password. Default value isadmin.master_hostFQDN name or IP address of the jenkins master host. Default value is{{ ansible_host }}.master_portJenkins master http port. Default value is8080.
general defaults
slave_agent_nameAgent name of the slave node. Default value isagent.slave_executors_numNumber of executors of the slave node. Default value is1.slave_environmentsDictionary of env variables to be set on slave. Default value is{}slave_mode_exclusiveSet usage of this node. If true, node will only build jobs with matching label expressions. Default value isfalse.master_urlJenkins master host URL. Default value ishttp://{{ master_host }}:{{ master_port }}.
linux defaults
slave_linux_jenkins_cred_idAlready exist credentials id on the jenkins master: Default value isci_slave.slave_linux_jenkins_usernameUser name that is defined inslave_linux_jenkins_cred_id. A new user with this name to be created on the slave node. Default value isuser.slave_linux_jenkins_passwordPassword for a new user on the slave node. Must match with the credentials password if its kind is 'Username with password'. Default value is 'password'.slave_linux_jenkins_public_keyPublic key that to be added to authorized_keys slave user file. Private key is placed in the credentials on the jenkins master if its kind is 'SSH Username with private key'. Default value is"".slave_linux_homeHome path for deploying jenkins slave binaries. Default value is/opt/jenkins.slave_linux_user_groupGroup for a new user on the slave node. Default value isuser.slave_linux_hostHost where jenkins slave is installed to. Default value is"{{ ansible_host }}".slave_linux_ssh_portSSH port of the slave node. Default value is22.slave_linux_selinux_portsSelinux ports of the slave node. Default value is"{{ master_port }},49187,{{ slave_linux_ssh_port }}".slave_linux_labelsList of labels for the slave node. Default value is['linux'].
windows defaults
slave_windows_workdirHome path for deploying jenkins slave binaries. Default value isC:/Jenkins_Slave.slave_windows_serviceWindows service name. Default value isjenkins-slave.slave_windows_java_optsAdditional options to pass to java. Default value is"".slave_windows_labelsList of labels for the slave node. Default value is['windows'].slave_windows_service_userThe username to set the service to start as.slave_windows_service_passwordThe password of given username to set the service to start as.
Example Playbook
- name: "Install jenkins-slave on remote hosts using default 'Username with password' credentials"
hosts: slave
vars:
master_host: master.example.com
roles:
- role: lean_delivery.jenkins_slave
- name: "Install jenkins-slave on remote hosts using created 'Username with password' credentials"
hosts: one_slave
vars:
master_host: master.example.com
slave_linux_jenkins_cred_id: new_cred
slave_linux_jenkins_username: new_user
slave_linux_jenkins_password: new_password
slave_agent_name: new_linux_slave
roles:
- role: lean_delivery.jenkins_slave
- name: "Install jenkins-slave on remote hosts using created 'SSH Username with private key' credentials"
hosts: many_slaves
vars:
master_host: master.example.com
slave_linux_jenkins_cred_id: new_cred
slave_linux_jenkins_username: new_user
slave_linux_jenkins_public_key:
Nck6x4HPrsdfkjhwhf98239hfoijhpowifnYXRXAW1GYGC3lsq7FpWjCeN8wT5QzRsblTh6HZKqh96K3Jj6kpob8ykjhsdkfjhskdfuhksdjfhksjdfhksfjhhkjhUHKUHDKFksjdfhkjshdfXPlx2xSUINDsH2IACLjIrxSAppxITzR7fHZyLmkjsdhfkuwhe98237982fhksdfhksdfhkuhCmcvH6fdVtozo42lXt4QgKytGtiuGAT+lN+uJ4LVGOq32WiEbYKbc7WE7N
roles:
- role: lean_delivery.jenkins_slave
Inventory example
[master]
master.example.com
[one_slave]
slave.example.com
[many_slaves]
slave1.example.com slave_agent_name=slave1
slave2.example.com slave_agent_name=slave2
License
Author Information
authors:
- Lean Delivery Team team@lean-delivery.com
