Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fact "ansible_virtualization_type" incorrect for alpine container on GitHub runner "ubuntu-latest" #66304

Closed
robertdebock opened this issue Jan 9, 2020 · 3 comments · Fixed by #72210
Assignees
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category

Comments

@robertdebock
Copy link
Contributor

SUMMARY

GitHub offers a shared runner of the type "ubuntu-latest". When molecule spins up an Alpine container, setup returns "VirtualPC" for ansible_virtualization_type.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

setup

ANSIBLE VERSION
ansible 2.9.2
  config file = None
  configured module search path = ['/home/robertdb/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.5 (default, Dec 15 2019, 17:54:26) [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]
CONFIGURATION
# empty
OS / ENVIRONMENT

GitHub runners are Ubuntu machines, hosted on Azure

STEPS TO REPRODUCE

This can only be reproduced in CI, as I don't know any other way to start this type of instance manually.

I use this code to check if the play is running in a container:

- name: reproduce
  debug:
    msg: "I am running in a container"
  when:
    - ansible_virtualization_type == "docker"
EXPECTED RESULTS

I was expecting ansible_virtualization_type to return docker.

ACTUAL RESULTS

The fact ansible_virtualization_type is set to VirtualPC

Likely this code is related: https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/virtual/linux.py#L134

@ansibot
Copy link
Contributor

ansibot commented Jan 9, 2020

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category labels Jan 9, 2020
robertdebock added a commit to robertdebock/ansible-role-hostname that referenced this issue Jan 9, 2020
@bcoca bcoca added needs_verified This issue needs to be verified/reproduced by maintainer P3 Priority 3 - Approved, No Time Limitation and removed needs_triage Needs a first human triage before being processed. labels Jan 14, 2020
@bcoca
Copy link
Member

bcoca commented Jan 14, 2020

So the issue here seems to be that we detect ONE of the virtualization types in use, in this case Azure exposes 'VirtualPC'. This is 'correct' but not 'fully correct', for a long time we have had the issue that most hosts now run under multiple virtualization types and can be host to mulitple types. For example, my workstation does qemu/virtualbox/lxd/docker/xen hosting, but only appears as one of those to facts.

So I'm going to keep this issue open but hijack it to create new 'virtualization facts list' vs the current single value, which only shows ONE of the types of virtualization you are in.

robertdebock added a commit to robertdebock/ansible-role-update that referenced this issue Apr 21, 2020
@ansibot
Copy link
Contributor

ansibot commented May 15, 2020

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

relrod added a commit to relrod/ansible that referenced this issue Jul 23, 2020
Change:
- Allow systems to declare multiple virt techs. For example if a system
  is both a docker container, but virtualized on KVM, show both. If a
  system is set up to run virtualbox and KVM VMs, show both.

- This is done by introducing new facts keys:
  - virtualization_tech_guest
  - virtualization_tech_host

- Backwards compatibility is preserved by keeping track of the previous
  return-points and refusing to update those keys after we would have
  returned, but now returning them at the end, so that the new keys can
  accumulate their data.

Test Plan:
- Local
- CI

Tickets:
- Refs ansible#66304
- Refs ansible#17151
- Refs ansible#17058
- Probably others

Signed-off-by: Rick Elrod <rick@elrod.me>
relrod added a commit to relrod/ansible that referenced this issue Jul 26, 2020
Change:
- Allow systems to declare multiple virt techs. For example if a system
  is both a docker container, but virtualized on KVM, show both. If a
  system is set up to run virtualbox and KVM VMs, show both.

- This is done by introducing new facts keys:
  - virtualization_tech_guest
  - virtualization_tech_host

- Backwards compatibility is preserved by keeping track of the previous
  return-points and refusing to update those keys after we would have
  returned, but now returning them at the end, so that the new keys can
  accumulate their data.

Test Plan:
- Local
- CI

Tickets:
- Refs ansible#66304
- Refs ansible#17151
- Refs ansible#17058
- Probably others

Signed-off-by: Rick Elrod <rick@elrod.me>
relrod added a commit to relrod/ansible that referenced this issue Aug 5, 2020
Change:
- Allow systems to declare multiple virt techs. For example if a system
  is both a docker container, but virtualized on KVM, show both. If a
  system is set up to run virtualbox and KVM VMs, show both.

- This is done by introducing new facts keys:
  - virtualization_tech_guest
  - virtualization_tech_host

- Backwards compatibility is preserved by keeping track of the previous
  return-points and refusing to update those keys after we would have
  returned, but now returning them at the end, so that the new keys can
  accumulate their data.

Test Plan:
- Local
- CI

Tickets:
- Refs ansible#66304
- Refs ansible#17151
- Refs ansible#17058
- Probably others

Signed-off-by: Rick Elrod <rick@elrod.me>
relrod added a commit that referenced this issue Aug 6, 2020
Change:
- Allow systems to declare multiple virt techs. For example if a system
  is both a docker container, but virtualized on KVM, show both. If a
  system is set up to run virtualbox and KVM VMs, show both.

- This is done by introducing new facts keys:
  - virtualization_tech_guest
  - virtualization_tech_host

- Backwards compatibility is preserved by keeping track of the previous
  return-points and refusing to update those keys after we would have
  returned, but now returning them at the end, so that the new keys can
  accumulate their data.

Test Plan:
- Local
- CI

Tickets:
- Refs #66304
- Refs #17151
- Refs #17058
- Probably others

Signed-off-by: Rick Elrod <rick@elrod.me>
zoredache pushed a commit to zoredache/ansible that referenced this issue Aug 10, 2020
Change:
- Allow systems to declare multiple virt techs. For example if a system
  is both a docker container, but virtualized on KVM, show both. If a
  system is set up to run virtualbox and KVM VMs, show both.

- This is done by introducing new facts keys:
  - virtualization_tech_guest
  - virtualization_tech_host

- Backwards compatibility is preserved by keeping track of the previous
  return-points and refusing to update those keys after we would have
  returned, but now returning them at the end, so that the new keys can
  accumulate their data.

Test Plan:
- Local
- CI

Tickets:
- Refs ansible#66304
- Refs ansible#17151
- Refs ansible#17058
- Probably others

Signed-off-by: Rick Elrod <rick@elrod.me>
carlosmmatos pushed a commit to carlosmmatos/ansible that referenced this issue Aug 13, 2020
Change:
- Allow systems to declare multiple virt techs. For example if a system
  is both a docker container, but virtualized on KVM, show both. If a
  system is set up to run virtualbox and KVM VMs, show both.

- This is done by introducing new facts keys:
  - virtualization_tech_guest
  - virtualization_tech_host

- Backwards compatibility is preserved by keeping track of the previous
  return-points and refusing to update those keys after we would have
  returned, but now returning them at the end, so that the new keys can
  accumulate their data.

Test Plan:
- Local
- CI

Tickets:
- Refs ansible#66304
- Refs ansible#17151
- Refs ansible#17058
- Probably others

Signed-off-by: Rick Elrod <rick@elrod.me>
(cherry picked from commit 4e55b93)

Backporting enhanced virtualization/container reporting.
carlosmmatos pushed a commit to carlosmmatos/ansible that referenced this issue Aug 13, 2020
Change:
- Allow systems to declare multiple virt techs. For example if a system
  is both a docker container, but virtualized on KVM, show both. If a
  system is set up to run virtualbox and KVM VMs, show both.

- This is done by introducing new facts keys:
  - virtualization_tech_guest
  - virtualization_tech_host

- Backwards compatibility is preserved by keeping track of the previous
  return-points and refusing to update those keys after we would have
  returned, but now returning them at the end, so that the new keys can
  accumulate their data.

Test Plan:
- Local
- CI

Tickets:
- Refs ansible#66304
- Refs ansible#17151
- Refs ansible#17058
- Probably others

Signed-off-by: Rick Elrod <rick@elrod.me>
(cherry picked from commit 4e55b93)

Backporting enhanced virtualization/container reporting.
carlosmmatos pushed a commit to carlosmmatos/ansible that referenced this issue Aug 13, 2020
…ble#70832)

Change:
- Allow systems to declare multiple virt techs. For example if a system
  is both a docker container, but virtualized on KVM, show both. If a
  system is set up to run virtualbox and KVM VMs, show both.

- This is done by introducing new facts keys:
  - virtualization_tech_guest
  - virtualization_tech_host

- Backwards compatibility is preserved by keeping track of the previous
  return-points and refusing to update those keys after we would have
  returned, but now returning them at the end, so that the new keys can
  accumulate their data.

Test Plan:
- Local
- CI

Tickets:
- Refs ansible#66304
- Refs ansible#17151
- Refs ansible#17058
- Probably others

Signed-off-by: Rick Elrod <rick@elrod.me>.
(cherry picked from commit 4e55b93)

Co-authored-by: Rick Elrod <rick@elrod.me>
carlosmmatos pushed a commit to carlosmmatos/ansible that referenced this issue Aug 13, 2020
…le#70832)

Change:
- Allow systems to declare multiple virt techs. For example if a system
  is both a docker container, but virtualized on KVM, show both. If a
  system is set up to run virtualbox and KVM VMs, show both.

- This is done by introducing new facts keys:
  - virtualization_tech_guest
  - virtualization_tech_host

- Backwards compatibility is preserved by keeping track of the previous
  return-points and refusing to update those keys after we would have
  returned, but now returning them at the end, so that the new keys can
  accumulate their data.

Test Plan:
- Local
- CI

Tickets:
- Refs ansible#66304
- Refs ansible#17151
- Refs ansible#17058
- Probably others

Signed-off-by: Rick Elrod <rick@elrod.me>.
(cherry picked from commit 4e55b93)

Co-authored-by: Rick Elrod <rick@elrod.me>
@relrod relrod self-assigned this Oct 13, 2020
@ansibot ansibot added the has_pr This issue has an associated PR. label Oct 13, 2020
relrod added a commit to relrod/ansible that referenced this issue Oct 13, 2020
Change:
- containerd is now recognized as container tech

Test Plan:
- N/A :(

Tickets:
- Fixes ansible#66304 because this is what docker containers show up as
  in Github Actions.

Signed-off-by: Rick Elrod <rick@elrod.me>
relrod added a commit to relrod/ansible that referenced this issue Oct 13, 2020
Change:
- containerd is now recognized as container tech

Test Plan:
- N/A :(

Tickets:
- Fixes ansible#66304 because this is what docker containers show up as
  in Github Actions.

Signed-off-by: Rick Elrod <rick@elrod.me>
relrod added a commit to relrod/ansible that referenced this issue Oct 13, 2020
Change:
- containerd is now recognized as container tech

Test Plan:
- Tested with github actions with Docker, and got expected result.

Tickets:
- Fixes ansible#66304 because this is what docker containers show up as
  in Github Actions.

Signed-off-by: Rick Elrod <rick@elrod.me>
relrod added a commit to relrod/ansible that referenced this issue Oct 13, 2020
Change:
- containerd is now recognized as container tech

Test Plan:
- Tested with github actions with Docker, and got expected result.

Tickets:
- Fixes ansible#66304 because this is what docker containers show up as
  in Github Actions.

Signed-off-by: Rick Elrod <rick@elrod.me>
relrod added a commit to relrod/ansible that referenced this issue Oct 19, 2020
Change:
- containerd is now recognized as container tech

Test Plan:
- Tested with Docker inside Github Actions in a private repo:

        "ansible_virtualization_role": "guest",
        "ansible_virtualization_tech_guest": [
            "containerd",
            "container",
            "VirtualPC"
        ],
        "ansible_virtualization_tech_host": [],
        "ansible_virtualization_type": "containerd",

Tickets:
- Fixes ansible#66304 because this is what docker containers show up as
  in Github Actions.

Signed-off-by: Rick Elrod <rick@elrod.me>
sivel pushed a commit that referenced this issue Oct 20, 2020
Change:
- containerd is now recognized as container tech

Test Plan:
- Tested with Docker inside Github Actions in a private repo:

        "ansible_virtualization_role": "guest",
        "ansible_virtualization_tech_guest": [
            "containerd",
            "container",
            "VirtualPC"
        ],
        "ansible_virtualization_tech_host": [],
        "ansible_virtualization_type": "containerd",

Tickets:
- Fixes #66304 because this is what docker containers show up as
  in Github Actions.

Signed-off-by: Rick Elrod <rick@elrod.me>
@ansible ansible locked and limited conversation to collaborators Nov 17, 2020
@sivel sivel removed the needs_verified This issue needs to be verified/reproduced by maintainer label Feb 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants