簡體   English   中英

嘗試使用ANSIBLE安裝jenkins-plugin時獲取錯誤“無法獲取CSRF”

[英]Gets error “Cannot get CSRF” when trying to install jenkins-plugin using ANSIBLE

我正在使用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

為了跳過啟動向導,我發現了這個(在幕后谷歌搜索)

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM