问题 使用Ansible升级APT包的正确方法是什么?


在设置新的Linux服务器时,我通常会运行 apt-get update 接着 apt-get upgrade。第一个命令更新可用软件包及其版本的列表,但它不会安装或升级任何软件包。第二个命令实际上安装了我的软件包的更新版本。

在Ansible中执行此操作的正确方法是什么?你可以这样做的一种方式是这样的:

- name: update and upgrade apt packages
  apt: >
    upgrade=yes
    update_cache=yes
    cache_valid_time=3600

或者你可以分两步完成:

- name: update apt packages
  apt: >
    update_cache=yes
    cache_valid_time=3600

- name: upgrade apt packages
  apt: upgrade=yes

如果你是第一种方式,Ansible足够聪明,知道它应该在'升级'之前运行'更新'吗? Ansible apt文档 没有解决这个问题。


3461
2018-04-27 17:40


起源



答案:


apt模块文档 确实声明它将首先运行更新:

运行相当于apt-get update 之前 操作。可以运行   作为软件包安装的一部分或作为单独的步骤。

(强调我的)

所以这两个剧本在功能上应该是相同的。


9
2018-04-27 17:52





未知以下是否 the correct way to upgrade apt packages using ansible,但这更新了系统上的包:

- name: Upgrade all packages to the latest version
  apt:
    update_cache: yes
    upgrade: yes

0
2017-09-14 09:28



Ansible显示错误: The offending line appears to be: - name: Upgrade all packages to the latest version apt: ^ here - Chaminda Bandara


答案:


apt模块文档 确实声明它将首先运行更新:

运行相当于apt-get update 之前 操作。可以运行   作为软件包安装的一部分或作为单独的步骤。

(强调我的)

所以这两个剧本在功能上应该是相同的。


9
2018-04-27 17:52





未知以下是否 the correct way to upgrade apt packages using ansible,但这更新了系统上的包:

- name: Upgrade all packages to the latest version
  apt:
    update_cache: yes
    upgrade: yes

0
2017-09-14 09:28



Ansible显示错误: The offending line appears to be: - name: Upgrade all packages to the latest version apt: ^ here - Chaminda Bandara