Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-120362

Ansible 'service' module fails when run with '-c local' inside a bootc/ostree container build

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • rhel-system-roles
    • 5
    • False
    • Hide

      None

      Show
      None
    • None

      When building an ostree-based (bootc) container image, using ansible-playbook -c local to execute a task with the ansible.builtin.service module fails. The module is unable to correctly detect or manage services within the non-booted container build environment, impacting the usability of many standard roles for image creation.

       

      Steps to Reproduce

      1. Create a simple playbook, baseline.yml, to enable a service:

      name: Configure baseline
        hosts: all
        become: true
        tasks:
          - name: Enable firewalld service
            ansible.builtin.service:
              name: firewalld
              enabled: true
       

      2. Create a Containerfile:
      FROM registry.redhat.io/rhel9/rhel-bootc:latest

      1. Install dependencies for the test
        RUN dnf -y install ansible-core firewalld
      2. Add playbook and run it
        ADD baseline.yml /root/baseline.yml
        RUN ansible-playbook -c local /root/baseline.yml

      3. Attempt to build the image: podman build -t my-bootc-image .
       

      Actual Result: ❌ The playbook fails with a fatal error on the service task:
      fatal: [localhost]: FAILED! => {"changed": false, "msg": "Could not find the requested service firewalld: host"}
       

      Solution:
      Use the systemd module directly: Replacing the service module with ansible.builtin.systemd works correctly in this environment.

              rmeggins@redhat.com Richard Megginson
              spetros@redhat.com Sergei Petrosian
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: