【问题标题】:apt_repository module fails ansibleapt_repository 模块失败
【发布时间】:2016-03-14 15:12:42
【问题描述】:

有时当我运行我的剧本时,它会引发下一次失败:

FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1457967885.72-104659711487416/apt_repository\", 
line 3210, in <module>\r\n    main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1457967885.72-104659711487416/apt_repository\", line 469, in main\r\n`    `cache.update()\r\n  File \"/usr/lib/python2.7/dist-packages/apt/cache.py\", line 440, 
in update\r\n    raise FetchFailedException(e)\r\napt.cache.FetchFailedException: W:Imposible obtener` `http://security.ubuntu.com/ubuntu/dists/trusty-security/main/source/Sources`  `La suma hash difiere\r\n, 
W:Imposible obtener http://security.ubuntu.com/ubuntu/dists/trusty-security/main/binary-amd64/Packages  La suma hash difiere\r\n, W:Imposible obtener http://security.ubuntu.com/ubuntu/dists/trusty-security/main/binary-i386/Packages  La suma hash difiere\r\n, 
E:Algunos archivos de` `índice fallaron al descargar. Se han ignorado, o se han utilizado unos` `antiguos en su lugar\r\n", 
"msg": "MODULE FAILURE", "parsed": false}

剧本中“有时”失败的部分是下一个:

- name: ppa java8
  apt_repository: repo=ppa:webupd8team/java state=present update_cache=yes

【问题讨论】:

  • 错误信息必须是英文。您还必须提供失败的ansible代码部分
  • 是的,很抱歉没有用英文添加失败。但是添加了ansible代码的一部分。 @baptistemm

标签: java ansible ansible-playbook apt ansible-2.x


【解决方案1】:

v1.在任何地方使用update_cache: no

ansible 2.5.2,远程主机:ubuntu 18.04

- name: Install MySQL utilities and workbench 4 Ubuntu
  when:
    - ansible_distribution == 'Ubuntu'
    - ansible_architecture == 'x86_64'
  become: yes
  block:
    - apt:
        update_cache: no
    - apt_repository:
        repo: deb http://repo.mysql.com/apt/ubuntu/ {{ ansible_distribution_release }} mysql-apt-config
        state: present
        filename: mysql
        update_cache: no
    - apt_repository:
        repo: deb http://repo.mysql.com/apt/ubuntu/ {{ ansible_distribution_release }} mysql-tools
        state: present
        filename: mysql
        update_cache: no
    - apt_key:
        # url: http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x8C718D3B5072E1F5
        keyserver: pool.sks-keyservers.net
        id: 8C718D3B5072E1F5
        state: present
    - debconf:
        name: mysql-apt-config
        question: select-product
        vtype: select
        value: Ok
    - debconf:
        name: mysql-apt-config
        question: select-tools
        vtype: select
        value: Enabled
    - debconf:
        name: mysql-apt-config
        question: repo-distro
        vtype: select
        value: ubuntu
    - debconf:
        name: mysql-apt-config
        question: tools-component
        vtype: select
        value: mysql-tools
    - debconf:
        name: mysql-apt-config
        question: repo-url
        vtype: select
        value: http://repo.mysql.com/apt
    - debconf:
        name: mysql-apt-config
        question: select-server
        vtype: select
        value: mysql-{{ mysql_version }}
    - apt:
        update_cache: yes
    - apt:
        name: "{{ item }}"
        state: latest
        install_recommends: yes
        force: yes
      with_items:
        - mysql-apt-config
        - mysql-utilities
        - mysql-workbench

- name: Install MySQL CLI 4 Ubuntu
  when:
    - ansible_distribution == 'Ubuntu'
    - ansible_architecture == 'x86_64'
  become: yes
  block:
    - apt:
        update_cache: no
    - apt_repository:
        repo: deb https://packagecloud.io/amjith/mycli/ubuntu/ {{ ansible_distribution_release }} main
        filename: amjith_mycli
        update_cache: no
    - apt_key:
        url: https://packagecloud.io/amjith/mycli/gpgkey
        state: present
    - apt:
        update_cache: yes
    - apt:
        name: mycli
        state: latest

Bug 回来了。

v2.首先添加一个新密钥(UPD 20-10-2020)。

- apt_key:
    # url: http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x8C718D3B5072E1F5
    keyserver: pool.sks-keyservers.net
    id: 8C718D3B5072E1F5
    state: present
- apt_repository:
    repo: deb http://repo.mysql.com/apt/ubuntu/ {{ ansible_distribution_release }} mysql-apt-config
    state: present
    filename: mysql
- apt_repository:
    repo: deb http://repo.mysql.com/apt/ubuntu/ {{ ansible_distribution_release }} mysql-tools
    state: present
    filename: mysql

【讨论】:

    【解决方案2】:

    在你的任务之前运行sudo apt-get -y clean &amp;&amp; sudo apt-get -y autoclean

    【讨论】:

      猜你喜欢
      • 2021-11-25
      • 2017-04-23
      • 2023-03-29
      • 2019-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多