第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.
19.1. Configuring image registry management for Podman and other container tools リンクのコピーリンクがクリップボードにコピーされました!
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
- You have prepared the control node and the managed nodes.
- You are logged in to the control node as a user who can run playbooks on the managed nodes.
-
The account you use to connect to the managed nodes has
sudopermissions for these nodes.
Procedure
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.podmanThe 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 settinginsecure=trueto a local registry running at my-local-registry:5000.
-
Validate the playbook syntax:
$ ansible-playbook --syntax-check ~/playbook.ymlNote that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
$ ansible-playbook ~/playbook.ymlThe
podman_use_new_toml_formattervariable 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: truein your configuration:
podman_use_new_toml_formatter: true
podman_containers_conf:
containers:
annotations:
- environment=production
- status=tier2
Verification
Run the
podman infocommand on the host:$ ansible managed-node-01.example.com -m command -a 'podman info'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