{"cha-6ren">
gpt4 book ai didi

jenkins - 尝试使用 ANSIBLE 安装 jenkins-plugin 时出现错误 "Cannot get CSRF"

转载 作者:行者123 更新时间:2023-12-02 18:39:19 24 4
gpt4 key购买 nike

我正在使用 ANSIBLE 在 CENTOS 上安装 jenkins。安装工作正常,但是当涉及到安装插件的任务时,我收到以下错误。

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 serviceInstall 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

关于jenkins - 尝试使用 ANSIBLE 安装 jenkins-plugin 时出现错误 "Cannot get CSRF",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42219781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com