我正在使用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"发布于 2017-02-14 19:13:10
在启动jenkins和尝试安装插件之间,您似乎不需要等待。jenkins_plugin需要一个正在运行的jenkins安装程序,因此您应该在Start jenkins service和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发布于 2017-02-24 15:11:15
为了跳过启动向导,我找到了这个(当然是googling)
- name: Jenkins Skip startUp for MI
lineinfile:
dest=/etc/sysconfig/jenkins
regexp='^JENKINS_JAVA_OPTIONS='
line='JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Djenkins.install.runSetupWizard=false"'
register: result_skip_startup_wizardhttps://stackoverflow.com/questions/42219781
复制相似问题