第 5 章 Ansible 内容迁移

如果您要从 ansible-core 版本迁移到 ansible-core 2.13,请考虑检查 Ansible 核心移植指南,以熟悉每个版本之间的更改和更新。在查看 Ansible 核心端口指南时,请确保选择最新版本的 ansible-coredevel,它位于指南的左上方。

有关完全支持和经认证的 Ansible 内容集合列表,请参阅 console.redhat.com 上的 Ansible Automation hub

5.1. 将 Ansible playbook 和角色迁移到 Core 2.13

当您从基于集合的内容迁移到基于集合的内容时,您应该在 playbook 和角色中使用 Fully Qualified Collection Names(FQCN)以避免意外行为。

带有 FQCN 的 playbook 示例:

- name: get some info
  amazon.aws.ec2_vpc_net_info:
    region: "{{ec2_region}}"
  register: all_the_info
  delegate_to: localhost
  run_once: true

如果您使用 ansible-core 模块,且没有从不同的集合调用模块,您应该使用 FQCN ansible.builtin.copy

带有 FQCN 的模块示例:

- name: copy file with owner and permissions
  ansible.builtin.copy:
  src: /srv/myfiles/foo.conf
  dest: /etc/foo.conf
  owner: foo
  group: foo
  mode: '0644'