【问题标题】:Reinstall deb package from another release从另一个版本重新安装 deb 包
【发布时间】:2017-09-30 07:45:23
【问题描述】:

我需要从另一个目标版本重新安装包。问题是如果软件包已经安装,则不采取任何行动。我的 ansible 剧本片段是:

- name: Add jessie-backports repo
  apt_repository:
    repo: 'deb http://httpredir.debian.org/debian jessie-backports main'
    state: present

- name: install libssl from jessie-backports
  apt:
    name: libssl1.0.0
    default_release: jessie-backports

答案是:

ptmp3 | SUCCESS => {
    "cache_update_time": 1493744770, 
    "cache_updated": true, 
    "changed": false, 
    "invocation": {
        ....
    }
}

我可以在安装新版本之前删除旧版本,但一大堆软件包取决于libssl(例如ssh)。

顺便说一句,远程主机上的命令apt-get install libssl1.0.0 -t jessie-backports 有效,并且libssl 已更新

【问题讨论】:

  • 为什么你的 apt 任务中没有 state=present?
  • state= present 是默认值
  • 您是否尝试过将force: true 与 apt 模块一起使用?
  • 是的,我试过了
  • 试试 'dpkg_options: force-downgrade' 和 'force: true'

标签: package ansible version apt


【解决方案1】:

解决方案是在 apt 任务中包含要安装的软件包的确切版本。确切版本可以通过apt-cache (apt-cache policy libssl1.0.0) 获取。

适当的剧本是:

- name: Add jessie-backports repo
  apt_repository:
    update_cache: yes
    repo: 'deb http://httpredir.debian.org/debian jessie-backports main'
    state: present

- name: get libssl1.0.0 jessie-backports version
  shell: apt-cache policy libssl1.0.0 | grep jessie-backports -B1 | head -n1 | sed -e 's/^\s*\**\s*\(\S*\).*/\1/'
  register: libsslinstalled

- name: install libssl from jessie-backports
  apt:
    name: "libssl1.0.0={{ libsslinstalled.stdout_lines[0] }}"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-01
    • 1970-01-01
    相关资源
    最近更新 更多