Git Product home page Git Product logo

ansible-jenkins's Introduction

Readme

Description

ansible-jenkins is an Ansible role. Use this role to install Jenkins and install/update plugins.

Provides

  1. Latest Jenkins server
  2. Jenkins plugins support

Requires

  1. Ansible 2.2 or higher
  2. Debian 8, Ubuntu 14, CentOS 7, FreeBSD 10 or later
  3. Vagrant (optional)

Usage

Install from Ansible Galaxy

$ ansible-galaxy install flyapen.jenkins

Or download manually

$ 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.

Create a host file

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

Create host specific variables

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.

Run the playbook

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

ansible-jenkins's People

Contributors

adamwolf avatar ameng avatar bryanlarsen avatar clarete avatar devjatkin avatar fupelaqu avatar gforcada avatar iffyuva avatar kami avatar karlmdavis avatar kristofkeppens avatar mcameron avatar piotrplenik avatar rorist avatar rvben avatar takluyver avatar tberton avatar troter avatar xmj avatar ycombinator avatar zeusf1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-jenkins's Issues

The 'prefix' option doesn't work on Debian

Pretty simple reason, really: the last line of the /etc/default/jenkins file is this:

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT"

To fix this, that line just has to be modified to this:

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --ajp13Port=$AJP_PORT --prefix=$PREFIX"

Seems jenkins changed a bunch of links

And maybe a few more ...

I guess this all due to Jenkins 2.0 being released. Looks like there is a lot more changes...

Was probably intermittent - and the old links work again ....

[DEPRECATION WARNING]: Using bare variables is deprecated

TASK [flyapen.jenkins : Install dependencies] **********************************
[DEPRECATION WARNING]: Using bare variables is deprecated. Update your
playbooks so that the environment value uses the full variable syntax
('{{jenkins.deb.dependencies}}').
This feature will be removed in a future
release. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.

Error when deploying

Run on ubuntu xenial -

TASK [flyapen.jenkins : Install/update plugins] ********************************
task path: /mnt/mmcblk0p1/tmp/work/xvt-dpe-cloud-infrastructure-stream2/roles/flyapen.jenkins/tasks/plugins.yml:7
failed: [13.54.197.74] (item=plugins) => {"changed": true, "cmd": "java -jar /opt/jenkins/jenkins-cli.jar -s http://localhost:8081 install-plugin plugins", "delta": "0:00:00.690971", "end": "2017-01-14 11:07:45.015734", "failed": true, "item": "plugins", "rc": 6, "start": "2017-01-14 11:07:44.324763", "stderr": "\nERROR: anonymous is missing the Overall/Read permission", "stdout": "", "stdout_lines": [], "warnings": []}

plugin authentication issue

when trying to run the jenkins cli in plugins.yml, i get an error about authentication
ERROR: You must authenticate to access this Jenkins.
Use --username/--password/--password-file parameters or login command.

i have tried using admin with locally stored admin password to no avail. how did you work around this or fix?

Release on galaxy?

Hi,

I was trying to set up a requirements.txt file for ansible roles and found that I either suck at searching or this role is not uploaded on galaxy.ansible.com. Is there any reason not to do so? If not, could someone register it there?

Thanks in advance!

jenkins-cli commands don't work when Jenkins authentication is turned on

I have Jenkins' own database authentication turned on with matrix based security and the ansible script can't install extensions or restart Jenkins:

failed: [10.0.0.10] => {"changed": true, "cmd": ["java", "-jar", "/opt/jenkins/jenkins-cli.jar", "-s", "http://localhost:8080", "safe-restart"], "delta": "0:00:00.866460", "end": "2014-12-10 15:55:43.202089", "rc": 1, "start": "2014-12-10 15:55:42.335629"}
stderr: hudson.security.AccessDeniedException2: anonymous is missing the Overall/Read permission

Could we have the ability to provide a username and password to use for these commands? This, and/or public key auth:
https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI#JenkinsCLI-WorkingwithCredentials

Jenkins fails to start

Ubuntu 16.04
Jenkins 2.19.1

I was running into a problem starting the Jenkins service.

Running from: /usr/share/jenkins/jenkins.war
Oct 09, 2016 7:02:16 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Logging initialized @631ms
Oct 09, 2016 7:02:16 AM winstone.Logger logInternal
INFO: Beginning extraction from war file
Oct 09, 2016 7:02:16 AM org.eclipse.jetty.util.log.JavaUtilLog warn
WARNING: Empty contextPath
Oct 09, 2016 7:02:16 AM winstone.Logger logInternal
INFO: Winstone shutdown successfully
Oct 09, 2016 7:02:16 AM winstone.Logger logInternal
SEVERE: Container startup failed
java.io.IOException: Failed to start a listener: winstone.Ajp13ConnectorFactory
        at winstone.Launcher.spawnListener(Launcher.java:207)
        at winstone.Launcher.<init>(Launcher.java:148)
        at winstone.Launcher.main(Launcher.java:352)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at Main._main(Main.java:246)
        at Main.main(Main.java:91)
Caused by: java.lang.NumberFormatException: For input string: ""
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:592)
        at java.lang.Integer.parseInt(Integer.java:615)
        at winstone.cmdline.Option.intArg(Option.java:291)
        at winstone.cmdline.Option$OInt.get(Option.java:203)
        at winstone.Ajp13ConnectorFactory.start(Ajp13ConnectorFactory.java:24)
        at winstone.Launcher.spawnListener(Launcher.java:205)
        ... 8 more

To get Jenkins to start I went into /etc/default/jenkins and removed the --ajp13Port=$AJP_PORT from JENKINS_ARGS. The $AJP_PORT variable does not exist in the current file. The JENKINS_ARGS value is set in the config.yml
https://github.com/ICTO/ansible-jenkins/blob/development/tasks/config.yml#L39

Systemd service file

I had some trouble running Jenkins under Ubuntu 16.04 with systemd. This seems to have been resolved by creating a systemd service file at /etc/systemd/system/jenkins.service:

[Unit]
Description=Jenkins Daemon

[Service]
Environment="JENKINS_HOME=/var/lib/jenkins"
ExecStart=/usr/bin/java -jar /usr/share/jenkins/jenkins.war
User=jenkins

[Install]
WantedBy=multi-user.target

(This is cobbled together and there may well be some extra bits needed, but it seems to be working for me)

No package matching 'openjdk-7-jre' is available

AWS EC2
Ubuntu 16.04
ansible 2.2.0

failed: [50.16.73.148](item=[u'openjdk-7-jre', u'openjdk-7-jdk', u'git', u'curl']) => {"failed": true, "item": ["openjdk-7-jre", "openjdk-7-jdk", "git", "curl"], "msg": "No package matching 'openjdk-7-jre' is available"}

Buildslaves on separate machines?

This role seems primarily focused on configuring the master. What would be my best path forward for setting up slaves on other boxes?

New release?

Hi, thanks @flyapen for releasing on ansible galaxy, unfortunately the release you pushed there is quite old (commit b311158), could you make a new tag targeting current development branch?

"Get Jenkins CLI" failes with a 503 from localhost

So I'm using this plugin via Vagrant (created an ansible/roles directory; my .yml that includes the ansible-jenkins role is in ansible. Vagrant file is in .)

I see the following:

TASK: [ansible-jenkins | Get Jenkins CLI] ************************************* 
failed: [build] => {"dest": "/opt/jenkins/jenkins-cli.jar", "failed": true, "response": "HTTP Error 503: Service Unavailable", "state": "absent", "status_code": 503, "url": "http://localhost:8080/jnlpJars/jenkins-cli.jar"}
msg: Request failed

Seems to be failing here where you get the CLI jar file from the running Jenkins instance:

# Get Jenkins CLI from localhost
- name: Get Jenkins CLI
  sudo: yes
  action: get_url url=http://localhost:8080/jnlpJars/jenkins-cli.jar dest={{ jenkins.cli_dest }} mode=0440

Not sure if something is different with the new Jenkins version... leaving work right now but I'll try to figure this out when I get home and get up a patch.

This role is only Debian compatible

When running this role

fatal: [192.168.33.10]: FAILED! => {"changed": false, "cmd": "apt-get update", "failed": true, "msg": "[Errno 2] No such file or directory", "rc": 2}

on CentOS 6 and ansible 2.1.0.0

Issue on 'Get Jenkins updates'

I have the role configured and running correctly, but when I get to the get jenkins update task, I get the following failure

I can ssh into vagrant and directly curl that URL, so little confused whats failing. I am able to connect both in and out of the VM to and pull the update json via curl

TASK: [ansible-jenkins | Get Jenkins updates] *********************************
failed: [127.0.0.1] => {"failed": true}
msg: Failed to connect to updates.jenkins-ci.org:443.

Any suggestions would be appreciated, and thanks!

jenkins-cli might not be needed on jenkins server

The "Restart Jenkins" handler uses {{ jenkins.cli_dest }} to restart the service which assumes that the client is running on the server. This is not strictly necessary though and a Jenkins server can exist without having a client running on it. So, it might be preferable to define the handler as:

- name: Restart Jenkins
  sudo: True
  service: name=jenkins state=restarted

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.