Code Monkey home page Code Monkey logo

ansible-role-jenkins's Introduction

jenkins

Install and configure jenkins on your system.

GitHub GitLab Quality Downloads Version
github gitlab quality downloads Version

Example Playbook

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: all
  become: yes
  gather_facts: yes

  roles:
    - role: buluma.jenkins

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  gather_facts: no
  become: yes

  roles:
    - role: buluma.bootstrap
    - role: buluma.epel
    - role: buluma.java
    - role: buluma.locale
    - role: buluma.core_dependencies

Role Variables

The default values for the variables are set in defaults/main.yml:

---
# defaults file for jenkins

# What tcp port Jenkins should listen to.
jenkins_port: 8080

# What address Jenkins should bind to.
jenkins_listen_address: "0.0.0.0"

Requirements

Status of used roles

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub GitLab
buluma.bootstrap Build Status GitHub Build Status GitLab
buluma.epel Build Status GitHub Build Status GitLab
buluma.java Build Status GitHub Build Status GitLab
buluma.locale Build Status GitHub Build Status GitLab
buluma.core_dependencies Build Status GitHub Build Status GitLab

Context

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles:

dependencies

Compatibility

This role has been tested on these container images:

container tags
debian bullseye
el all
fedora all

The minimum version of Ansible required is 2.10, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

Exceptions

Some roles can't run on a specific distribution or version. Here are some exceptions.

variation reason
alpine tried to configure name using a file "/etc/sysconfig/clock", but could not write to it
amazonlinux /etc/rc.d/init.d/jenkins: line 59: /etc/init.d/functions: No such file or directory
ubuntu:bionic No openjdk 8, with openjdk 11 jenkins returns an error.
ubuntu:focal No openjdk 8, with openjdk 11 jenkins returns an error.
opensuse An initscript is not idempotent.

If you find issues, please register them in GitHub

License

Apache-2.0

Author Information

Michael Buluma

ansible-role-jenkins's People

Contributors

buluma avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

uk-bolly

ansible-role-jenkins's Issues

[Feature request] Install default plugins (suggested plugins)

Hello! Thanks for Jenkins role!

I use this role and add ansible code for Install default plugins (suggested plugins).
May be add Install default plugins (suggested plugins) to role? (May be not all steps)

- hosts: jenkins
  become: yes
  roles:
    - role: buluma.java
    - role: buluma.jenkins
  post_tasks:
    - name: get initialAdminPassword
      shell: cat /var/lib/jenkins/secrets/initialAdminPassword
      register: adminpwd

    - name: unlock and add admin user
      jenkins_script:
        script: |
          import jenkins.model.*
          import hudson.security.*
          def instance = Jenkins.getInstance()
          def hudsonRealm = new HudsonPrivateSecurityRealm(false)
          hudsonRealm.createAccount('jenkins', '${user_pwd}')
          instance.setSecurityRealm(hudsonRealm)
          def strategy = new FullControlOnceLoggedInAuthorizationStrategy()
          strategy.setAllowAnonymousRead(false)
          instance.setAuthorizationStrategy(strategy)
          instance.save()
        args:
          user_pwd: "{{ adminpwd }}"
        user: admin
        password: "{{ adminpwd.stdout }}"

    - name: complete setup wizard
      jenkins_script:
        script: |
          import static jenkins.model.Jenkins.instance as jenkins
          import jenkins.install.InstallState
          if (!jenkins.installState.isSetupComplete()) {
            InstallState.INITIAL_SETUP_COMPLETED.initializeState()
          }
        user: admin
        password: "{{ adminpwd.stdout }}"

    - name: Install default plugins when choice 'install suggested plugins'
      jenkins_plugin:
        name: "{{ item }}"
        url: http://localhost:8080
        url_username: "admin"
        url_password: "{{ adminpwd['stdout'] }}"
      register: plugin_result
      until: plugin_result is success
      loop:
        - cloudbees-folder
        - antisamy-markup-formatter
        - build-timeout
        - credentials-binding
        - timestamper
        - ws-cleanup
        - ant
        - gradle
        - workflow-aggregator
        - github-branch-source
        - pipeline-github-lib
        - pipeline-stage-view
        - git
        - ssh-slaves
        - matrix-auth
        - pam-auth
        - ldap
        - email-ext
        - mailer

    - name: Restart Jenkins
      ansible.builtin.service:
        name: jenkins
        state: restarted

    - name: Check Jenkins work (Get Jenkins Crumb).
      ansible.builtin.uri:
        force_basic_auth: yes
        url_username:     "admin"
        url_password:     "{{ adminpwd.stdout }}"
        url:              http://localhost:8080/crumbIssuer/api/json
        return_content:   yes
      retries:            10
      delay:              5

    - name: Print adminpwd var
      debug:
        var: adminpwd['stdout']

    - name: Print ansible_ssh_host var
      debug:
        var: ansible_ssh_host

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.