0

I have such config for ansible:

- hosts: localhost
  connection: local
  tasks:
          - name: Jenkins - add job
            jenkins_job:
                    config: "{{ lookup('file', 'jenkins_conf/pipeline_staging.xml') }}"
                    name: deploy-staging
                    password: XXXXX
                    url: https://jenkins.url.com
                    user: someuser

But when i try to start this playbook i'm getting:

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to validate if job exists, HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.\nThe last 30x error message was:\nFound for https://jenkins.url.com"} to retry, use: --limit @/home/holo/project/sources/devops/orchiestration/environment-cloud/ansible-playbook/jenkins.retry

What am i doing wrong?

user3069488
  • 159
  • 2
  • 3
  • 18
  • Is your Jenkins behind a proxy? And if so does the error occurre when connecting directly to the jenkins server? – Henrik Pingel Jun 09 '17 at 12:46
  • It is behind kubernetes ingress resource (google cloud platform): https://kubernetes.io/docs/concepts/services-networking/ingress/ So as it is on kubernetes i can't connect to it directly. – user3069488 Jun 09 '17 at 13:17
  • I checked with my other Jenkins instance (instaled on VM not in containers) with direct access and Ansible is working in that case. Is there possibility to use Ansible Jenkins plugin with app behind proxy? – user3069488 Jun 09 '17 at 13:39
  • I guess so, the proxy you have configures is just seems to be not working properly. I would try to setup [proxy-to-service](https://github.com/kubernetes/contrib/tree/master/for-demos/proxy-to-service). – Henrik Pingel Jun 09 '17 at 14:27
  • Hmm.. but this is another service which i need to expose with another ingress, so situation will be same like in my present configuration. Right now Jenkins pod is made same way. – user3069488 Jun 09 '17 at 15:01
  • I tried to use LoadBalancer instead of ingress to directly point to Jenkins port like described here: http://terrenceryan.com/blog/index.php/making-kubernetes-ip-addresses-static-on-google-container-engine/ But same efect "..ifinite loop". – user3069488 Jun 09 '17 at 16:07
  • You should ask a new question to figure out your proxy problems. It's is unlikely that anyone who could help you out with that will read this question as you make it appear to be about Ansible. But your proxy setup is a google cloud / kubernetes problem. – Henrik Pingel Jun 10 '17 at 07:59

1 Answers1

1

The proxy in front of the Jenkins server seems to be wrongly configured. However as the jenkins_job module is executed on the remote host this problem can be avoided by not using connection: local and setting the url parameter to localhost:jenkins_port.

Henrik Pingel
  • 8,676
  • 2
  • 24
  • 38
  • It is Kubernetes cluster and service is accessible by ingress IP. Executing it on remote host still will be connecting via ingress/proxy resource. PS as suggested i added tags and changed description instead of creating new question – user3069488 Jun 10 '17 at 10:19
  • I created additional nat instance and executed plugin remotely with direct connection to kubernetes endopoint (without ingress/LB). Still did not help. Same error like above. Looks like plugin is not working when Jenkins is installed on top of docker/kubernetes. – user3069488 Jun 12 '17 at 16:50