我想自动安装jenkins,因为我使用的是ansible。 我正在尝试用它的repo和gpg键安装jenkins。这是我的剧本
---
- hosts: "{{ HOST }}"
become: true
become_user: root
gather_facts: true
become_method: sudo
vars:
temp_folder: /tmp
tasks:
- name: Include variables
include_vars:
dir: '../vars'
extensions: ['yml']
- name: Install java
yum:
name: java
state: present
update_cache: yes
become: true
become_user: root
- name: Add Jenkins Repository | Add Sources List
yum_repository:
name: jenkins
description: jenkins
baseurl: "{{ jenkins_repo }}"
gpgkey: "{{ jenkins_key }}"
gpgcheck: yes
become: true
become_user: root
- name: Install jenkins
yum:
name: jenkins
state: present
update_cache: yes
become_user : root
become: true
- name: Start Jenkins Service | Enable on Boot
service:
name: jenkins
state: started
enabled: yes
become: true
become_user: root
var文件中的值包含以下键: - ---
jenkins_key: https://pkg.jenkins.io/redhat/jenkins.io.key
jenkins_repo: https://pkg.jenkins.io/redhat/jenkins.repo
现在,当我执行playbook时,它会让我跟着错误。
fatal: [atul-ec2]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"conf_file": null,
"disable_gpg_check": false,
"disablerepo": null,
"enablerepo": null,
"exclude": null,
"install_repoquery": true,
"installroot": "/",
"list": null,
"name": [
"jenkins"
],
"skip_broken": false,
"state": "present",
"update_cache": true,
"validate_certs": true
}
},
"msg": "Failure talking to yum: failure: repodata/repomd.xml from jenkins: [Errno 256] No more mirrors to try.\nhttps://pkg.jenkins.io/redhat/jenkins.repo/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found"
}
但是当我试图手动添加jenkins repo时,它并没有给我任何错误。
答案 0 :(得分:1)
baseurl
参数应包含指向包含包和repodata
的URL的值。您提供的值是包含yum repo信息的文件。您需要从该文件中提取baseurl
并将其用作值。在你的redhat示例中,你的值应该是:
jenkins_repo: https://pkg.jenkins.io/redhat/
当repodata/repomod.xml
变量与jenkins_repo
参数一起使用时,使用baseurl
中包含的yum_repository
正确配置回购。{{1}}任务中的模块。
答案 1 :(得分:0)
我知道这是一个很老的话题。
但是作为一个公认的答案并没有真正解释为什么有问题的代码没有按预期工作,请在下面找到几句话
使用后者可能是更好的选择,尤其是软件维护者提供的。