diff --git a/changelogs/fragments/66304-facts_containerd.yml b/changelogs/fragments/66304-facts_containerd.yml new file mode 100644 index 00000000000..5dc0aff7926 --- /dev/null +++ b/changelogs/fragments/66304-facts_containerd.yml @@ -0,0 +1,2 @@ +minor_changes: + - virtual facts - containerd cgroup is now recognized as container tech (https://github.com/ansible/ansible/issues/66304). diff --git a/lib/ansible/module_utils/facts/virtual/linux.py b/lib/ansible/module_utils/facts/virtual/linux.py index f44c293c6c7..46a7cfaddc3 100644 --- a/lib/ansible/module_utils/facts/virtual/linux.py +++ b/lib/ansible/module_utils/facts/virtual/linux.py @@ -61,6 +61,12 @@ class LinuxVirtual(Virtual): virtual_facts['virtualization_type'] = 'lxc' virtual_facts['virtualization_role'] = 'guest' found_virt = True + if re.search('/system.slice/containerd.service', line): + guest_tech.add('containerd') + if not found_virt: + virtual_facts['virtualization_type'] = 'containerd' + virtual_facts['virtualization_role'] = 'guest' + found_virt = True # lxc does not always appear in cgroups anymore but sets 'container=lxc' environment var, requires root privs if os.path.exists('/proc/1/environ'): @@ -105,7 +111,7 @@ class LinuxVirtual(Virtual): found_virt = True # ensure 'container' guest_tech is appropriately set - if guest_tech.intersection(set(['docker', 'lxc', 'podman', 'openvz'])) or systemd_container: + if guest_tech.intersection(set(['docker', 'lxc', 'podman', 'openvz', 'containerd'])) or systemd_container: guest_tech.add('container') if os.path.exists("/proc/xen"):