簡體   English   中英

在安裝新的Docker軟件包之前,如何確保已卸載舊的Docker軟件包?

[英]How do I ensure legacy Docker packages are uninstalled before installing the new packages?

我們有一些較舊的服務器,這些服務器從分發軟件包存儲庫中安裝了舊版Docker軟件包。 可以通過手動安裝

$ yum install docker

或更舊的清單

package { 'docker': 
    ensure => present,
}

我們希望通過“受支持的” puppetlabs-docker模塊遷移到官方Docker存儲庫和軟件包

include docker

但是,舊的Docker軟件包不會被此新模塊刪除或以其他方式管理!

[vagrant@localhost ~]$ sudo -i puppet apply -e 'include docker'
Notice: Compiled catalog for localhost.localdomain in environment production in 0.42 seconds
Notice: /Stage[main]/Docker::Repos/Yumrepo[docker]/ensure: created
Error: Execution of '/bin/yum -d 0 -e 0 -y install docker-ce' returned 1: Error: docker-ce conflicts with 2:docker-1.13.1-75.git8633870.el7.centos.x86_64
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
Error: /Stage[main]/Docker::Install/Package[docker]/ensure: change from 'purged' to 'present' failed: Execution of '/bin/yum -d 0 -e 0 -y install docker-ce' returned 1: Error: docker-ce conflicts with 2:docker-1.13.1-75.git8633870.el7.centos.x86_64
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

安裝新軟件包之前,我們如何確保刪除舊軟件包?

您首先要確保不存在舊版軟件包。

package { 'docker':
    ensure => absent,
}

但是,您不能使用Package['docker'] docker Package['docker'] ,因為新的puppetlabs-docker模塊已經聲明了它。 您必須執行以下操作:

package { 'legacy-docker':
    ensure => absent,
    name => 'docker',
}

也有許多舊的必備軟件包也需要刪除。

package { [
    'docker-client',
    'docker-client-latest',
    'docker-common',
    'docker-latest',
    'docker-latest-logrotate',
    'docker-logrotate',
    'docker-selinux',
    'docker-engine-selinux',
    'docker-engine',
]:
    ensure => absent,
}

因此,總的來說,這種排序似乎是隱式的。

package { 'legacy-docker':
    ensure => absent,
    name => 'docker',
}

package { [
    'docker-client',
    'docker-client-latest',
    'docker-common',
    'docker-latest',
    'docker-latest-logrotate',
    'docker-logrotate',
    'docker-selinux',
    'docker-engine-selinux',
    'docker-engine',
]:
    ensure => absent,
}

include docker

實際上,這似乎在清單的后續運行中引起問題...刪除了常見的第二級依賴項!

Error: Execution of '/bin/rpm -e container-selinux-2.68-1.el7.noarch' returned 1: error: Failed dependencies:
        container-selinux >= 2.9 is needed by (installed) docker-ce-18.06.1.ce-3.el7.x86_64
Error: /Stage[main]/Profile::Docker/Package[docker-selinux]/ensure: change from '2:2.68-1.el7' to 'absent' failed: Execution of '/bin/rpm -e container-selinux-2.68-1.el7.noarch' returned 1: error: Failed dependencies:
        container-selinux >= 2.9 is needed by (installed) docker-ce-18.06.1.ce-3.el7.x86_64
Error: Execution of '/bin/rpm -e container-selinux-2.68-1.el7.noarch' returned 1: error: Failed dependencies:
        container-selinux >= 2.9 is needed by (installed) docker-ce-18.06.1.ce-3.el7.x86_64
Error: /Stage[main]/Profile::Docker/Package[docker-engine-selinux]/ensure: change from '2:2.68-1.el7' to 'absent' failed: Execution of '/bin/rpm -e container-selinux-2.68-1.el7.noarch' returned 1: error: Failed dependencies:
        container-selinux >= 2.9 is needed by (installed) docker-ce-18.06.1.ce-3.el7.x86_64

好的,包資源沒有refreshonly類型的屬性,因此我們需要求助於exec資源。 啊。

package { 'legacy-docker':
    ensure => absent,
    name => 'docker',
    notify => Exec['autoremove'],
}

exec { 'autoremove':
    command => '/usr/bin/yum -y autoremove',
    refreshonly => true,
}

include docker

這是...合理嗎? 唯一的事情可能是排序,您可以使用->探索顯式的資源排序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM