Skip to content

Missing ansible_facts.virtualization_type for Azure Vms #431

@bbaassssiiee

Description

@bbaassssiiee

when: ansible_connection == 'docker' or ansible_facts.virtualization_type in ["docker", "lxc", "openvz", "podman", "container"]

- name: test facts
  hosts: all
  gather_facts: false

  tasks:
    - setup:

    - debug: var=ansible_facts.virtualization_type

    - name: "Setup rules if container"
      when:
        - ansible_connection == 'docker' or
          ansible_facts.virtualization_type in ["docker", "lxc", "openvz", "podman", "container"]
      debug:
        msg: "Setup rules if container"

Output

$ ansible-playbook -i localhost, -c local test.yml

PLAY [test facts] ******************************************************************************************************************************************************

TASK [setup] ***********************************************************************************************************************************************************
[WARNING]: Platform linux on host localhost is using the discovered Python interpreter at /usr/local/bin/python3.12, but future installation of another Python
interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.17/reference_appendices/interpreter_discovery.html for more information.
ok: [localhost]

TASK [debug] ***********************************************************************************************************************************************************
ok: [localhost] => {
    "ansible_facts.virtualization_type": "VirtualPC"
}

TASK [Setup rules if container] ****************************************************************************************************************************************
skipping: [localhost]

PLAY RECAP *************************************************************************************************************************************************************

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions