是否可以确定性地设置 Debian 系统? [英] Is it possible to setup a Debian system in a deterministic manner?

查看:25
本文介绍了是否可以确定性地设置 Debian 系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在工作中,我们开发了一些 Python 软件,可以在 Raspbian(基于 Debian)和 Raspberry Pi 上运行.

At work, we developed some Python software that runs on Raspbian (Debian Based), on a Raspberry Pi.

我们有一些 Ansible 脚本,可以获取新的 Raspbian 映像,在 Raspberry Pi 上启动,并对其进行配置以运行我们的软件.Ansible 做了一些事情:

We have some Ansible scripts that can take a fresh Raspbian image, booted on a Raspberry Pi, and configure it to run our software. Ansible does a few things:

  • 使用 apt 安装一些必需的包
  • 设置 Python 虚拟环境,并使用 pip 和需求文件来安装运行软件所需的 Python 库的确切版本

Ansible 每次运行时,它都会安装我们用来测试软件的确切版本的 Python 库(来自 PyPi),这一事实非常棒.不幸的是,这不适用于通过 apt 安装的软件包.

The fact that every time Ansible runs, it will install the exact version of the Python libraries (from PyPi) that we have tested our software with is great. Unfortunately, this does not apply to the packages installed through apt.

执行 apt-get install package 或 Ansible 等效项,会安装该软件包的最新版本.今天的版本,可能和明天的版本不一样.这意味着,如果我今天运行 Ansible 脚本来设置 Raspberry Pi,我的软件可能会完美运行,但明天在新的 Raspberry Pi 上运行 Ansible 可能会安装来自 apt 的更新版本的软件,这可能会破坏我们的软件.

Doing apt-get install package, or the Ansible equivalent, installs the latest version of that package. What the version is today, may not be the same as what it is tomorrow. That means if I run my Ansible scripts to setup a Raspberry Pi today, my software might work perfectly, but running Ansible on a fresh Raspberry Pi tomorrow might install newer versions of software from apt, which may break our software.

有没有什么办法可以做 pip 所做的事情,但对于 apt?冻结当前安装的软件包版本,然后在新系统上安装时,安装那些确切版本的软件包?或者类似的东西.

Is there any way to do what pip does, but for apt? Freeze the currently-installed versions of packages, and later, when installing on a fresh system, install those exact versions of packages? Or something similar.

我知道我们可以安装我们想要的任何版本的软件包,并将 SD 卡克隆到其他 PI,但这首先违背了拥有 Ansible 脚本的目的.

I know we can install whatever versions of packages we want, and clone the SD card to other PIs, but that kind of defeats the purpose of having Ansible scripts in the first place.

推荐答案

使用 ansible,您可以指定以这种方式安装哪个版本的包.

With ansible you can specify which version of a packge to install this way.

- name: Install the version '1.00' of package "foo"
  apt:
    name: foo=1.00

然后为了防止在系统升级的情况下升级包将包标记为保持这种方式

and then to prevent the package to be uprgraded in case of a system upgrade mark the package as hold this way

- dpkg_selections:
    name: python
    selection: hold

这篇关于是否可以确定性地设置 Debian 系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆