使用Ansible安装Jenkins插件告诉我crump值无效

使用Ansible安装Jenkins插件告诉我crump值无效,jenkins,plugins,vagrant,ansible,Jenkins,Plugins,Vagrant,Ansible,TL;DR Jenkins告诉我,当从Ansible脚本安装插件时,我传递了一个无效的crump值 详细信息 我让Jenkins 2.32.2运行在Docker容器中,使用正式的Docker容器 我已经把它安装到了一个流浪的虚拟机上,并试图用Ansible配置插件 我正在使用下面的任务遍历插件列表 - name: Install plugins include: install_plugin.yml with_items: "{{ plugins }}" loop_control:

TL;DR

Jenkins告诉我,当从Ansible脚本安装插件时,我传递了一个无效的crump值

详细信息

我让Jenkins 2.32.2运行在Docker容器中,使用正式的Docker容器

我已经把它安装到了一个流浪的虚拟机上,并试图用Ansible配置插件

我正在使用下面的任务遍历插件列表

- name: Install plugins
  include: install_plugin.yml
  with_items: "{{ plugins }}"
  loop_control:
    loop_var: plugin_name
  tags: [jenkins]
在defaults/main.yml文件中定义了以下列表

plugins:
  - git
  - template-project
  - pipeline
  - docker-workflow
  - template-project
  - config-file-provider
  - bitbucket
  - disk-usage
  - greenballs
  - jacoco
  - slack
  - sonar
---
- name: Get Jenkins crumb
  uri:
    user: admin
    password: "{{ jenkins_admin_password }}"
    force_basic_auth: yes
    url: "http://{{ ansible_hostname }}:8080/crumbIssuer/api/json"
    return_content: yes
  register: crumb_token
  until: crumb_token.content.find('Please wait while Jenkins is getting ready') == -1
  retries: 10
  delay: 5
  tags: [jenkins]

- name: Plugins are installed
  uri:
    url: "http://{{ ansible_host }}:8080/pluginManager/installNecessaryPlugins"
    method: POST
    user: admin
    password: "{{ jenkins_admin_password }}"
    body: '<jenkins><install plugin="{{ plugin_name }}@latest" /></jenkins>'
    headers:
      Content-Type: "text/xml"
      Jenkins-Crumb: "{{ crumb_token.json.crumb }}"
    creates: "{{ jenkins_home }}/plugins/{{ plugin_name }}"
  register: plugins_result
  tags: [jenkins]

- wait_for:
    path: "{{ jenkins_home }}/plugins/{{ plugin_name }}"
  tags: [jenkins]
下面是install_plugin.yml的定义,它是从main.yml文件调用的

plugins:
  - git
  - template-project
  - pipeline
  - docker-workflow
  - template-project
  - config-file-provider
  - bitbucket
  - disk-usage
  - greenballs
  - jacoco
  - slack
  - sonar
---
- name: Get Jenkins crumb
  uri:
    user: admin
    password: "{{ jenkins_admin_password }}"
    force_basic_auth: yes
    url: "http://{{ ansible_hostname }}:8080/crumbIssuer/api/json"
    return_content: yes
  register: crumb_token
  until: crumb_token.content.find('Please wait while Jenkins is getting ready') == -1
  retries: 10
  delay: 5
  tags: [jenkins]

- name: Plugins are installed
  uri:
    url: "http://{{ ansible_host }}:8080/pluginManager/installNecessaryPlugins"
    method: POST
    user: admin
    password: "{{ jenkins_admin_password }}"
    body: '<jenkins><install plugin="{{ plugin_name }}@latest" /></jenkins>'
    headers:
      Content-Type: "text/xml"
      Jenkins-Crumb: "{{ crumb_token.json.crumb }}"
    creates: "{{ jenkins_home }}/plugins/{{ plugin_name }}"
  register: plugins_result
  tags: [jenkins]

- wait_for:
    path: "{{ jenkins_home }}/plugins/{{ plugin_name }}"
  tags: [jenkins]
以下是此步骤的-vvv的日志输出

TASK [jenkins : Install plugins] ***********************************************
task path: /Users/chris/Projects/ci/roles/jenkins/tasks/main.yml:56
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
included: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01

TASK [jenkins : Get Jenkins crumb] *********************************************
task path: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml:2
Using module file /usr/local/Cellar/ansible/2.2.0.0_2/libexec/lib/python2.7/site-packages/ansible/modules/core/network/basics/uri.py
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r cluster01 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555 `" && echo ansible-tmp-1486148016.3-32614286575555="` echo $HOME/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555 `" ) && sleep 0'"'"''
<cluster01> PUT /var/folders/g5/h48p994d3qn7d9_nz7xv2lvh0000gn/T/tmprL_Pye TO /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/uri.py
<cluster01> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r '[cluster01]'
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r cluster01 '/bin/sh -c '"'"'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/ /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/uri.py && sleep 0'"'"''
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r -tt cluster01 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-vzqwuvcglpsfrrzkvwdcupjtukijcwvl; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/uri.py; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
ok: [cluster01] => {
    "attempts": 1, 
    "changed": false, 
    "connection": "close", 
    "content": "{\"_class\":\"hudson.security.csrf.DefaultCrumbIssuer\",\"crumb\":\"ad67abc734af7eae279df5c68098a29e\",\"crumbRequestField\":\"Jenkins-Crumb\"}", 
    "content_type": "application/json;charset=UTF-8", 
    "date": "Fri, 03 Feb 2017 18:53:36 GMT", 
    "invocation": {
        "module_args": {
            "backup": null, 
            "body": null, 
            "body_format": "raw", 
            "content": null, 
            "creates": null, 
            "delimiter": null, 
            "dest": null, 
            "directory_mode": null, 
            "follow": false, 
            "follow_redirects": "safe", 
            "force": false, 
            "force_basic_auth": true, 
            "group": null, 
            "headers": {
                "Authorization": "Basic YWRtaW46YWRtaW4="
            }, 
            "http_agent": "ansible-httpget", 
            "method": "GET", 
            "mode": null, 
            "owner": null, 
            "password": "admin", 
            "regexp": null, 
            "remote_src": null, 
            "removes": null, 
            "return_content": true, 
            "selevel": null, 
            "serole": null, 
            "setype": null, 
            "seuser": null, 
            "src": null, 
            "status_code": [
                200
            ], 
            "timeout": 30, 
            "unsafe_writes": null, 
            "url": "http://cluster01:8080/crumbIssuer/api/json", 
            "url_password": "admin", 
            "url_username": "admin", 
            "use_proxy": true, 
            "user": "admin", 
            "validate_certs": true
        }, 
        "module_name": "uri"
    }, 
    "json": {
        "_class": "hudson.security.csrf.DefaultCrumbIssuer", 
        "crumb": "ad67abc734af7eae279df5c68098a29e", 
        "crumbRequestField": "Jenkins-Crumb"
    }, 
    "msg": "OK (unknown bytes)", 
    "redirected": false, 
    "server": "Jetty(9.2.z-SNAPSHOT)", 
    "status": 200, 
    "url": "http://cluster01:8080/crumbIssuer/api/json", 
    "x_content_type_options": "nosniff", 
    "x_jenkins": "2.32.2", 
    "x_jenkins_session": "3abb7e45"
}

TASK [jenkins : Plugins are installed] *****************************************
task path: /Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml:15
Using module file /usr/local/Cellar/ansible/2.2.0.0_2/libexec/lib/python2.7/site-packages/ansible/modules/core/network/basics/uri.py
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r cluster01 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735 `" && echo ansible-tmp-1486148016.66-148559593691735="` echo $HOME/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735 `" ) && sleep 0'"'"''
<cluster01> PUT /var/folders/g5/h48p994d3qn7d9_nz7xv2lvh0000gn/T/tmp1RWIY4 TO /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/uri.py
<cluster01> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r '[cluster01]'
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r cluster01 '/bin/sh -c '"'"'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/ /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/uri.py && sleep 0'"'"''
<cluster01> ESTABLISH SSH CONNECTION FOR USER: vagrant
<cluster01> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile=".vagrant/machines/cluster01/virtualbox/private_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 -o ControlPath=/Users/chris/.ansible/cp/ansible-ssh-%h-%p-%r -tt cluster01 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-qixxmffrdktqhuyukutskswbxfsaxrdd; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/uri.py; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1486148016.66-148559593691735/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
fatal: [cluster01]: FAILED! => {
    "cache_control": "must-revalidate,no-cache,no-store", 
    "changed": false, 
    "connection": "close", 
    "content": "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<title>Error 403 No valid crumb was included in the request</title>\n</head>\n<body><h2>HTTP ERROR 403</h2>\n<p>Problem accessing /pluginManager/installNecessaryPlugins. Reason:\n<pre>    No valid crumb was included in the request</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>\n\n</body>\n</html>\n", 
    "content_length": "387", 
    "content_type": "text/html; charset=ISO-8859-1", 
    "date": "Fri, 03 Feb 2017 18:53:37 GMT", 
    "failed": true, 
    "invocation": {
        "module_args": {
            "backup": null, 
            "body": "<jenkins><install plugin=\"git@latest\" /></jenkins>", 
            "body_format": "raw", 
            "content": null, 
            "creates": "/var/jenkins_home/plugins/git", 
            "delimiter": null, 
            "dest": null, 
            "directory_mode": null, 
            "follow": false, 
            "follow_redirects": "safe", 
            "force": false, 
            "force_basic_auth": false, 
            "group": null, 
            "headers": {
                "Content-Type": "text/xml", 
                "Jenkins-Crumb": "ad67abc734af7eae279df5c68098a29e"
            }, 
            "http_agent": "ansible-httpget", 
            "method": "POST", 
            "mode": null, 
            "owner": null, 
            "password": "admin", 
            "regexp": null, 
            "remote_src": null, 
            "removes": null, 
            "return_content": false, 
            "selevel": null, 
            "serole": null, 
            "setype": null, 
            "seuser": null, 
            "src": null, 
            "status_code": [
                200
            ], 
            "timeout": 30, 
            "unsafe_writes": null, 
            "url": "http://cluster01:8080/pluginManager/installNecessaryPlugins", 
            "url_password": "admin", 
            "url_username": "admin", 
            "use_proxy": true, 
            "user": "admin", 
            "validate_certs": true
        }, 
        "module_name": "uri"
    }, 
    "msg": "Status code was not [200]: HTTP Error 403: No valid crumb was included in the request", 
    "redirected": false, 
    "server": "Jetty(9.2.z-SNAPSHOT)", 
    "status": 403, 
    "url": "http://cluster01:8080/pluginManager/installNecessaryPlugins", 
    "x_content_type_options": "nosniff"
}
TASK[jenkins:安装插件]***********************************************
任务路径:/Users/chris/Projects/ci/roles/jenkins/tasks/main.yml:56
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
包括:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml for cluster01
任务[詹金斯:拿詹金斯面包屑]*********************************************
任务路径:/Users/chris/Projects/ci/roles/jenkins/tasks/install_plugin.yml:2
使用模块文件/usr/local/ceral/ansible/2.2.0.0_2/libexec/lib/python2.7/site-packages/ansible/modules/core/network/basics/uri.py
为用户建立SSH连接:vagrant
SSH:EXEC SSH-C-o ControlMaster=auto-o ControlPersist=60s-o StrictHostKeyChecking=no-o'IdentityFile=“.vagrant/machines/cluster01/virtualbox/private_key””-o KbdInteractiveAuthentication=no-o PreferredAuthentications=gssapi带麦克风、gssapi-keyex、基于主机、,publickey-o PasswordAuthentication=no-o User=vagrant-o ConnectTimeout=10-o ControlPath=/Users/chris/.ansible/cp/ansible ssh-%h-%p-%r cluster01'/bin/sh-c''”(umask 77&&mkdir-p“`echo$HOME/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555`”和echo ansible-tmp-1486148016.3-32614286575555=“`echo$HOME/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555`&&sleep 0`”
将/var/folders/g5/h48p994d3qn7d9_nz7xv2lvh0000gn/T/tmprL_Pye放入/home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/uri.py
SSH:EXEC sftp-b--C-o ControlMaster=auto-o ControlPersist=60s-o StrictHostKeyChecking=no-o'IdentityFile=“.vagrant/machines/cluster01/virtualbox/private_key“'-o KbdInteractiveAuthentication=no-o PreferredAuthentications=gssapi with mic、gssapi keyex、基于主机、公钥-o PasswordAuthentication=no-o User=vagrant-o ConnectTimeout=10-o ControlPath=/Users/chris/.ansible/cp/ansible ssh-%p-%r'[cluster01]”
为用户建立SSH连接:vagrant
SSH:EXEC SSH-C-o ControlMaster=auto-o ControlPersist=60s-o StrictHostKeyChecking=no-o'IdentityFile=“.vagrant/machines/cluster01/virtualbox/private_key””-o KbdInteractiveAuthentication=no-o PreferredAuthentications=gssapi带麦克风、gssapi-keyex、基于主机、,publickey-o PasswordAuthentication=no-o User=vagrant-o ConnectTimeout=10-o ControlPath=/Users/chris/.ansible/cp/ansible ssh-%h-%p-%r cluster01'/bin/sh-c'''chmod u+x/home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/.ansible/tmp/tmp/1486148016.3-3264286575555/uri&&sleep''
为用户建立SSH连接:vagrant
SSH:EXEC SSH-C-o ControlMaster=auto-o ControlPersist=60s-o StrictHostKeyChecking=no-o'IdentityFile=“.vagrant/machines/cluster01/virtualbox/private_key””-o KbdInteractiveAuthentication=no-o PreferredAuthentications=gssapi带麦克风、gssapi-keyex、基于主机、,publickey-o PasswordAuthentication=no-o User=vagrant-o ConnectTimeout=10-o ControlPath=/Users/chris/.ansible/cp/ansible ssh-%h-%p-%r-tt cluster01'/bin/sh-c''S sudo-h-S-n-u root/bin/sh-c'''S''S''S''S''S''S''S''S''S''S''S''S''S''S''S''S''S'S'S'S'S'S'S'S'S/usr/bin/python/home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-32614286575555/uri.py;rm-rf“/home/vagrant/.ansible/tmp/ansible-tmp-1486148016.3-3261428657555/”>/dev/null 2>&1'''''''''''''''''和&sleep 0'''''
确定:[cluster01]=>{
"尝试":一,,
“更改”:错误,
“连接”:“关闭”,
“内容”:“{\”\u class\”:“hudson.security.csrf.DefaultCrumpIssuer\”,“crump\”:“ad67abc734af7eae279df5c68098a29e\”,“crumpRequestField\”:“Jenkins Crump\”,
“内容类型”:“应用程序/json;字符集=UTF-8”,
“日期”:“2017年2月3日星期五18:53:36 GMT”,
“调用”:{
“模块参数”:{
“备份”:空,
“主体”:空,
“正文格式”:“原始”,
“内容”:空,
“创建”:null,
“分隔符”:空,
“dest”:空,
“目录模式”:空,
“跟随”:错误,
“跟踪重定向”:“安全”,
"力":假,,
“强制基本授权”:正确,
“组”:空,
“标题”:{
“授权”:“基本YWRtaW46YWRtaW4=”
}, 
“http_代理”:“ansible httpget”,
“方法”:“获取”,
“模式”:空,
“所有者”:空,
“密码”:“管理员”,
“regexp”:空,
“远程_src”:空,