Stouts / Stouts.jenkins

Ansible role which manage Jenkins CI
MIT License
41 stars 35 forks source link

Fail running web api #33

Closed lawrencegs closed 8 years ago

lawrencegs commented 9 years ago

I run this on ubuntu 15.04

ansible-playbook -i localhost -c local jenkins.yml

Here is the jenkins.yml playbook

- hosts: localhost
  roles:
    - role: Stouts.nginx
    - role: Stouts.jenkins
      sudo: yes

  vars:
    jenkins_proxy: nginx
    jenkins_proxy_hostname: jenkins.redacted.com
    jenkins_ssh_key_file: "files/ssh_key/redacted-bot"
    jenkins_jobs:
    - name: mixer
      repo: https://github.com/klen/mixer.git
      command: make test

And the result is:

PLAY [localhost] 
GATHERING FACTS

ok: [localhost]

TASK: [Stouts.nginx | Install dependencies] ***********************************
ok: [localhost]

TASK: [Stouts.nginx | Add nginx repository] ***********************************
ok: [localhost]

TASK: [Stouts.nginx | Install Dependencies] ***********************************
ok: [localhost] => (item=nginx,python-passlib)

TASK: [Stouts.nginx | Delete default site] ************************************
skipping: [localhost]

TASK: [Stouts.nginx | Encrypt http auth passwords] ****************************
skipping: [localhost]

TASK: [Stouts.nginx | Configure nginx] ****************************************
ok: [localhost]

TASK: [Stouts.jenkins | Include OS-specific variables.] ***********************
skipping: [localhost]

TASK: [Stouts.jenkins | Include OS-specific variables.] ***********************
ok: [localhost]

TASK: [Stouts.jenkins | jenkins-install | Add apt key] ************************
ok: [localhost]

TASK: [Stouts.jenkins | jenkins-install | Add apt repo] ***********************
ok: [localhost]

TASK: [Stouts.jenkins | jenkins-install | Install jenkins] ********************
ok: [localhost] => (item=curl,jenkins)

TASK: [Stouts.jenkins | jenkins-install | Install additional deb packages] ****
skipping: [localhost]

TASK: [Stouts.jenkins | jenkins-install | Setup passlib] **********************
skipping: [localhost]

TASK: [Stouts.jenkins | jenkins-configure | Configure Jenkins Service] ********
ok: [localhost]

TASK: [Stouts.jenkins | Create home folder] ***********************************
ok: [localhost]

TASK: [Stouts.jenkins | jenkins-configure | Ensure Jenkins restarted] *********
ok: [localhost]

TASK: [Stouts.jenkins | Wait untils Jenkins web API is available] *************
failed: [localhost] => {"attempts": 10, "changed": true, "cmd": "curl --head --silent http://127.0.0.1:8000//cli/", "delta": "0:00:00.020527", "end": "2015-06-09 15:11:35.615232", "failed": true, "rc": 7, "start": "2015-06-09 15:11:35.594705", "warnings": ["Consider using get_url module rather than running curl"]}
msg: Task failed as maximum retries was encountered

FATAL: all hosts have already failed -- aborting
klen commented 8 years ago

Should work now.

twistedpair commented 7 years ago
TASK [Stouts.jenkins : Wait untils Jenkins web API is available] ***************
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (12 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (11 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (10 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (9 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (8 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (7 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (6 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (5 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (4 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (3 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (2 retries left).
FAILED - RETRYING: TASK: Stouts.jenkins : Wait untils Jenkins web API is available (1 retries left).
fatal: [jobs]: FAILED! => {"attempts": 12, "changed": false, "cmd": "curl --head --silent http://localhost:8080//cli/", "delta": "0:00:00.017769", "end": "2017-01-08 21:31:01.081315", "failed": true, "rc": 0, "start": "2017-01-08 21:31:01.063546", "stderr": "", "stdout": "HTTP/1.1 403 Forbidden\r\nDate"}

This appears to still be broken. When using the v3.4.4 build installed from GitHub, or when using the v3.4.2 version installed from Galaxy, the script keeps failing to talk to the restarted server, because the server returns a 403 error. This is because the curl statement isn't using credentials, so it won't get in.

The server is online and can be accessed from the Web UI, but you need to provide the creds first:

image

Does the role need to disable auth to run correctly?

mickaeltr commented 7 years ago

@twistedpair That should work thanks to the jenkins.install.runSetupWizard=false java argument: https://github.com/Stouts/Stouts.jenkins/blob/3.4.4/defaults/main.yml#L65 Maybe you are overriding the jenkins_java_args variable?

lauflabs commented 7 years ago

@mickaeltr, you're right, I was. However, that's because I was trying to remove the following line from /etc/default/jenkins, since it caused classpath exceptions that prevented starting Jenkins.

JENKINS_ARGS="$JENKINS_ARGS --preferredClassLoader=java.net.URLClassLoader"

I'll do some line replace kungfu to get all of these working.

Jan 08, 2017 8:48:12 PM Main deleteWinstoneTempContents
WARNING: Failed to delete the temporary Winstone file /tmp/winstone/jenkins.war
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at Main._main(Main.java:264)
        at Main.main(Main.java:112)
Caused by: java.lang.IllegalArgumentException: Unrecognized option: --preferredClassLoader=java.net.URLClassLoader
        at winstone.cmdline.CmdLineParser.parse(CmdLineParser.java:53)
        at winstone.Launcher.getArgsFromCommandLine(Launcher.java:359)
        at winstone.Launcher.main(Launcher.java:332)
        ... 6 more

I'm not running any other Java processes on this node, but perhaps other people would need that line? Removing it should fix things for anyone else impacted with this exception.

mickaeltr commented 7 years ago

@lauflabs I don't have this in JENKINS_ARGS (see https://github.com/Stouts/Stouts.jenkins/blob/3.4.4/templates/jenkins.j2#L72 ). Maybe you should do a clean install using Stouts.jenkins 3.4.4