简体   繁体   中英

Reinstall deb package from another release

I need reinstall package from another target release. Problem is that if package is already installed no action is taken. My ansible playbook fragment is:

- 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

and ansible answer is:

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

I can remove old version before installing new, but whole bunch of packages depends on libssl ( ssh for example).

Btw command apt-get install libssl1.0.0 -t jessie-backports at remote host works, and libssl is updated

Solution is to include exact version of package to be installed in apt task. Exact version can be retrieved by apt-cache ( apt-cache policy libssl1.0.0 ).

Appropriate chunk of playbook would be:

- 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] }}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM