第 19 章 Managing containers by using RHEL system roles


With the podman RHEL system role, you can manage Podman configuration, containers, and systemd services that run Podman containers.

With the podman RHEL system role, you can automate the Podman management, including registry configuration, across multiple RHEL systems. Instead of manually editing files, you define your desired registry configuration in an Ansible playbook.

The podman RHEL system role uses the podman_registries_conf variable, which accepts a dictionary containing the registry settings. The role then creates a drop-in file, for example, in the /etc/containers/registries.conf.d/ to apply your configuration, following best practices for managing system configurations.

Prerequisites

Procedure

  1. Create a playbook file, for example, ~/playbook.yml, with the following content:

    ---
    - name: Configure Podman registries with RHEL system roles
      hosts: managed-node-01.example.com
      vars:
        podman_registries_conf:
          unqualified-search-registries:
            - "registry.access.redhat.com"
            - "docker.io"
            - "my-company-registry.com"
          registry:
            - location: "my-company-registry.com"
            - location: "my-local-registry:5000"
              insecure: true
      tasks:
        - name: Include the podman system role
          ansible.builtin.include_role:
            name: redhat.rhel_system_roles.podman

    The settings specified in the example playbook include the following:

    • unqualified-search-registries: Extends the list of registries Podman searches when you use a short image name (for example, podman pull <my-image>). Podman searches for images in my-company-registry.com after the default registries.
    • [registry]: Defines specific properties for a given registry. For example, you can enable an insecure connection by setting insecure=true to a local registry running at my-local-registry:5000.
  2. Validate the playbook syntax:

    $ ansible-playbook --syntax-check ~/playbook.yml

    Note that this command only validates the syntax and does not protect against a wrong but valid configuration.

  3. Run the playbook:

    $ ansible-playbook ~/playbook.yml

    The podman_use_new_toml_formatter variable generates TOML-compliant configuration files that are compatible with Podman. This variable enhances the Podman role by supporting all TOML features, including tables and inline tables, through a true TOML formatter instead of the Jinja template used previously.

    The new formatter is disabled by default to maintain compatibility with the previous formatter’s behavior. To enable the new formatter, set podman_use_new_toml_formatter: true in your configuration:

podman_use_new_toml_formatter: true
podman_containers_conf:
  containers:
    annotations:
      - environment=production
      - status=tier2

Verification

  1. Run the podman info command on the host:

    $ ansible managed-node-01.example.com -m command -a 'podman info'
  2. Verify the registeries section:

    registries:
      my-company-registry.com:
        Blocked: false
        Insecure: false
        Location: my-company-registry.com
        MirrorByDigestOnly: false
        Mirrors: null
        Prefix: my-company-registry.com
        PullFromMirror: ""
      my-local-registry:5000:
        Blocked: false
        Insecure: true
        Location: my-local-registry:5000
        MirrorByDigestOnly: false
        Mirrors: null
        Prefix: my-local-registry:5000
        PullFromMirror: ""
      search:
      - registry.access.redhat.com
      - docker.io
      - my-company-registry.com
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部