获取错误“无法获取CSRF";尝试使用ANSIBLE安装jenkins-plugin时 [英] Gets error "Cannot get CSRF" when trying to install jenkins-plugin using ANSIBLE
本文介绍了获取错误“无法获取CSRF";尝试使用ANSIBLE安装jenkins-plugin时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用ANSIBLE在CENTOS上安装jenkins. 安装工作正常,但是涉及安装插件的任务时,出现以下错误.
I am using ANSIBLE to install jenkins on CENTOS. The installation works fine but when it comes to the task of installing plugin, i get the following error.
fatal: [jenkins]: FAILED! => {"changed": false, "details": "Request failed: <urlopen error [Errno 111] Connection refused>", "failed": true, "msg": "Cannot get CSRF"}
代码如下.
- name: Install jenkins
rpm_key:
state: present
key: https://pkg.jenkins.io/redhat-stable/jenkins.io.key
- name: Add Repository for jenkins
yum_repository:
name: jenkins
description: Repo needed for automatic installation of Jenkins
baseurl: http://pkg.jenkins.io/redhat-stable
gpgcheck: yes
gpgkey: https://pkg.jenkins.io/redhat-stable/jenkins.io.key
#Pre requisite: add key and repo
- name: Install jenkins
yum:
name: jenkins
state: present
#Start/Stop jenkins
- name: Start jenkins service
service:
name: jenkins
state: started
#Start jenkins on startup
- name: Start jenkins on boot
shell: chkconfig jenkins on
- name: Install build-pipeline
jenkins_plugin:
name: build-pipeline-plugin
notify:
- "restart jenkins-service"
推荐答案
您似乎不必等待启动jenkins和尝试安装插件之间的等待. jenkins_plugin
需要运行可运行的jenkins安装,因此您应该在Start jenkins service
和Install build-pipeline
之间进行等待:
You don't seem to wait between starting up jenkins and trying to install the plugin. The jenkins_plugin
requires a running and working jenkins installation, so you should do a wait between Start jenkins service
and Install build-pipeline
:
- name: Wait for Jenkins to start up
uri:
url: http://localhost:8080
status_code: 200
timeout: 5
register: jenkins_service_status
# Keep trying for 5 mins in 5 sec intervals
retries: 60
delay: 5
until: >
'status' in jenkins_service_status and
jenkins_service_status['status'] == 200
这篇关于获取错误“无法获取CSRF";尝试使用ANSIBLE安装jenkins-plugin时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文