mmagonde.ansible_jenkins_swarm_agent
Ansible Role: Jenkins Swarm Agent
This role installs the Jenkins Agent on servers using the Swarm jar. On Windows, it runs as a service with the help of NSSM.
Requirements
- Java 8 or higher must be installed on the server.
- A Jenkins master must have the Swarm client installed.
- You need Ansible version 2.2 because it uses some new Windows modules.
Role Variables
Here are the variables you can set, along with their default values (found in defaults/main.yml
):
jenkins_agent_master
: 'localhost'This is the hostname of the Jenkins master. Typically, 'localhost' works well. It will be used for setup to connect to the Jenkins instance through HTTP.
jenkins_admin_username
: adminjenkins_admin_password
: adminThese are the username and password for the Jenkins master user.
name
: 'Jenkins_Agent'This is the name of the agent.
version
: "3.6"You can set the version of the Jenkins agent Swarm client to any version available at https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/
client_jar
: "swarm-client-{{version}}.jar"client_source
: "https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/{{version}}/{{client_jar}}"This is the URL where the client jar file can be found.
swarm_mode
: 'exclusive'This parameter controls how Jenkins assigns jobs to agents. It can be 'normal' (use this agent as much as possible) or 'exclusive' (only use it for specific jobs). The default is exclusive.
swarm_executors
: '4'This specifies the number of executors.
swarm_labels
: 'windows'These are the labels this agent will have. The default is 'windows'.
disableSslVerification
This option turns off SSL verification in the HttpClient.
service_user
: "LocalSystem"service_pass
: undefinedThis specifies the account and password under which the service will run. By default, it runs as the
LocalSystem
account without a password.java
: 'C:\ProgramData\Oracle\Java\javapath\java.exe'This is the path to the Java executable on the system.
agent_drive
: 'C:'agent_home
: "{{agent_drive}}\j"This sets the home directory for the Jenkins agent, which is used to store files such as artifacts and plugins. You can change the default directory from C:\j to another location if desired.
Dependencies
- Java needs to be installed on the system. You can use the
geerlingguy.java
role for this.
Example Playbook
- hosts: jenkins_agents
vars:
jenkins_agent_master: "{{ hostvars.example_master.ansible_host }}",
jenkins_agent_num_executors: 8,
jenkins_agent_labels: "Windows dotnet swarm msbuild"
roles:
- mmagonde.jenkins-swarm-agent
License
This role is licensed under the BSD license.
Author Information
This role was created in 2021 by Mutsa Magonde.
ansible-galaxy install mmagonde.ansible_jenkins_swarm_agent