How to create an ansible task to update golang

huangapple go评论85阅读模式
英文:

How to create an ansible task to update golang

问题

我想在一些开发服务器上将golang版本更新到最新版,并且我想为此添加一个任务。我考虑做这样的事情:

- name: 升级golang
  ansible.builtin.yum:
    name: 'golang'
    state: latest

但我不确定这是否有效,而且我认为在name部分写入"golang"可能不够。如果我只想将golang更新到最新版本,你能否建议一下这个任务应该是什么样子的?

英文:

I want to update golang version to the latest in some dev servers, and I wanted to add a task for this. I was thinking of doing something like this-

- name: Upgrade golang
  ansible.builtin.yum:
    name: 'golang'
    state: latest

but Im not sure if this would work, plus I dont think if writing "golang" in the name section is enough.
Could you please suggest what this task should look like if I just want to update golang to the latest

答案1

得分: 2

state: latest 将会更新指定的软件包,如果它不是最新可用版本的话(参见 Ansible 文档:yum 模块)。你的任务应该可以工作。对于 name,你需要写上软件包的名称,就像你在安装时使用的那样。

如果你想要更新其他不是 golang 依赖的软件包,你必须单独指定它们。golang 依赖的软件包会被 yum 自动解析和安装。

如果你想要指定多个软件包,你可以将它们作为一个列表传递给 name。例如:

- name: 升级 golang
  ansible.builtin.yum:
    name:
      - golang
      - golang-docker-dev
      - golang-collectd-dev
    state: latest
英文:

state: latest will update the specified package if it’s not of the latest available version (see Ansible Docs: yum module). Your task should work. For name you have to write the package name, as you used for installation.

If you want to update other packages that are not themselves a dependency of golang, you must specify them separately. Packages that golang depends on are automatically resolved and installed by yum.

If you want to specify multiple packages, you can pass them as a list to for name. For example:

- name: Upgrade golang
  ansible.builtin.yum:
    name:
      - golang
      - golang-docker-dev
      - golang-collectd-dev
    state: latest

huangapple
  • 本文由 发表于 2022年9月1日 00:07:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/73558833.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定