Skip to content

Ansible helper runbook to install Jenkins from well known roles

Notifications You must be signed in to change notification settings

yiskaneto/ansible_install_jenkins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible_Install_Jenkins

Ansible helper runbook to install Jenkins from ansible-role-jenkins

First time Installation

  1. Install the collections and roles from requirements.yaml:

    ansible-galaxy install -r requirements.yaml
  2. Open the main.yaml file and adjust the parameters values as needed.

    Note: you can set the jenkins_admin_username andjenkins_admin_password variable values by using an Ansible vault file, see section Updating existing installation for a quick way to do

  3. Run the playbook on the target node:

    time ansible-playbook main.yaml -i <node>, -b -K
    
    ## if run locally
    time ansible-playbook main.yaml -i "$(hostname -i)", -b -K --connection=local

For a clean installation on the target node we may need to remove some files to avoid package conflicts (only do this if you are definitely not using them), the commands below explain how to do it on RHEL distribution systems but adjust it for Ubuntu:

sudo dnf remove java-11-openjdk java jenkins java-1.8.0-openjdk-headless -y ; sudo dnf clean all ; sudo dnf clean packages ; sudo rm -rf /var/lib/jenkins /opt/jenkins-cli.jar

In case the default version of java needs to be replaced you can run:

update-alternatives --config java

Updating existing installation

You can update an existing installation by providing the jenkins_admin_username and jenkins_admin_password variables into a vault file:

  1. Create a new Ansible vault:

    ansible-vault create <path to>/jenkins_credentials.yaml
  2. Enter a new password and confirm it.

  3. Add the jenkins_admin_username and jenkins_admin_password parameters with their corresponding values, example:

    jenkins_admin_username: "<username>"
    jenkins_admin_password: "<admin user password"
  4. Save and quit.

  5. Now we can run the playbook:

    time ansible-playbook main.yaml -e @<path to>/jenkins_credentials.yaml --ask-vault-pass -i <node>, -b -K
    
    ## If run locally:
    time ansible-playbook main.yaml -e @<path to>/jenkins_credentials.yaml --ask-vault-pass -i "$(hostname -i)", -b -K --connection=local
  6. If a specific version of Jenkins is needed then pass the following environmental variables to the command:

    -e "jenkins_package_state=present jenkins_version=<version>"

About

Ansible helper runbook to install Jenkins from well known roles

Resources

Stars

Watchers

Forks

Packages

No packages published