{"action":"closed","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/49158","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/49158/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/49158/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/49158/events","html_url":"https://github.com/ansible/ansible/issues/49158","id":384499494,"node_id":"MDU6SXNzdWUzODQ0OTk0OTQ=","number":49158,"title":"Virtualization facts missing for KVM guests running FreeBSD","user":{"login":"niallor","id":11461838,"node_id":"MDQ6VXNlcjExNDYxODM4","avatar_url":"https://avatars1.githubusercontent.com/u/11461838?v=4","gravatar_id":"","url":"https://api.github.com/users/niallor","html_url":"https://github.com/niallor","followers_url":"https://api.github.com/users/niallor/followers","following_url":"https://api.github.com/users/niallor/following{/other_user}","gists_url":"https://api.github.com/users/niallor/gists{/gist_id}","starred_url":"https://api.github.com/users/niallor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niallor/subscriptions","organizations_url":"https://api.github.com/users/niallor/orgs","repos_url":"https://api.github.com/users/niallor/repos","events_url":"https://api.github.com/users/niallor/events{/privacy}","received_events_url":"https://api.github.com/users/niallor/received_events","type":"User","site_admin":false},"labels":[{"id":1126594180,"node_id":"MDU6TGFiZWwxMTI2NTk0MTgw","url":"https://api.github.com/repos/ansible/ansible/labels/P3","name":"P3","color":"e3ed5e","default":false},{"id":947190508,"node_id":"MDU6TGFiZWw5NDcxOTA1MDg=","url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.7","name":"affects_2.7","color":"ededed","default":false},{"id":785271699,"node_id":"MDU6TGFiZWw3ODUyNzE2OTk=","url":"https://api.github.com/repos/ansible/ansible/labels/bug","name":"bug","color":"fbca04","default":true},{"id":814251818,"node_id":"MDU6TGFiZWw4MTQyNTE4MTg=","url":"https://api.github.com/repos/ansible/ansible/labels/has_pr","name":"has_pr","color":"1d76db","default":false},{"id":636352796,"node_id":"MDU6TGFiZWw2MzYzNTI3OTY=","url":"https://api.github.com/repos/ansible/ansible/labels/support:core","name":"support:core","color":"ededed","default":false},{"id":1130170724,"node_id":"MDU6TGFiZWwxMTMwMTcwNzI0","url":"https://api.github.com/repos/ansible/ansible/labels/verified","name":"verified","color":"a1dbe2","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-26T20:34:41Z","updated_at":"2018-12-18T20:57:54Z","closed_at":"2018-12-18T20:57:54Z","author_association":"NONE","body":"<!--- Verify first that your issue is not already reported on GitHub -->\r\n<!--- Also test if the latest release and devel branch are affected too -->\r\n<!--- Complete *all* sections as described, this form is processed automatically -->\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly below -->\r\nFacts *virtualization_role* and *virtualization_type* are not set for **KVM guests** running **FreeBSD**, and so cannot be relied on in playlists. Live observation indicates that **version 2.7.2** is affected. Inspection of the **devel branch** seems to indicate that this and **previously released versions** are also affected.\r\n\r\nThe missing facts are set for both **OpenBSD** and **NetBSD** using a common approach, which seems applicable also for **FreeBSD**.\r\n\r\nMost closely related issue, #36350 seems not to overlap.\r\n\r\nChange pasted below works for limited test environment available. If this solution is incomplete, it seems at least a worthwhile improvement.\r\n\r\n```\r\n--- a/lib/ansible/module_utils/facts/virtual/freebsd.py\r\n+++ b/lib/ansible/module_utils/facts/virtual/freebsd.py\r\n@@ -19,9 +19,10 @@ __metaclass__ = type\r\n import os\r\n \r\n from ansible.module_utils.facts.virtual.base import Virtual, VirtualCollector\r\n+from ansible.module_utils.facts.virtual.sysctl import VirtualSysctlDetectionMixin\r\n \r\n \r\n-class FreeBSDVirtual(Virtual):\r\n+class FreeBSDVirtual(Virtual, VirtualSysctlDetectionMixin):\r\n     \"\"\"\r\n     This is a FreeBSD-specific subclass of Virtual.  It defines\r\n     - virtualization_type\r\n@@ -39,6 +40,18 @@ class FreeBSDVirtual(Virtual):\r\n             virtual_facts['virtualization_type'] = 'xen'\r\n             virtual_facts['virtualization_role'] = 'guest'\r\n \r\n+        # if no result yet, look for either of the following\r\n+        # hw.model: QEMU Virtual CPU version 1.1.0\r\n+        # hw.hv_vendor: KVMKVMKVM\r\n+\r\n+        if virtual_facts['virtualization_type'] == '':\r\n+            virtual_vendor_facts = self.detect_virt_vendor('hw.model')\r\n+            virtual_facts.update(virtual_vendor_facts)\r\n+            \r\n+        if virtual_facts['virtualization_type'] == '':\r\n+            virtual_product_facts = self.detect_virt_product('hw.hv_vendor')\r\n+            virtual_facts.update(virtual_product_facts)\r\n+\r\n         return virtual_facts\r\n```\r\n\r\n##### ISSUE TYPE\r\n- Bug Report\r\n\r\n##### COMPONENT NAME\r\n<!--- Write the short name of the module, plugin, task or feature below -->\r\nmodule_utils/facts/virtual/freebsd.py\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from \"ansible --version\" between quotes -->\r\n```paste below\r\nansible 2.7.2\r\n  config file = /Users/niall/.ansible.cfg\r\n  configured module search path = ['/Users/niall/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/local/Cellar/ansible/2.7.2/libexec/lib/python3.7/site-packages/ansible\r\n  executable location = /usr/local/bin/ansible\r\n  python version = 3.7.1 (default, Nov  6 2018, 18:46:03) [Clang 10.0.0 (clang-1000.11.45.5)]\r\n```\r\n\r\n##### CONFIGURATION\r\n<!--- Paste verbatim output from \"ansible-config dump --only-changed\" between quotes -->\r\n```paste below\r\nANSIBLE_SSH_RETRIES(/Users/niall/.ansible.cfg) = 10\r\nDEFAULT_GATHER_TIMEOUT(/Users/niall/.ansible.cfg) = 15\r\nDEFAULT_HOST_LIST(/Users/niall/.ansible.cfg) = ['/usr/local/etc/ansible/hosts']\r\nDEFAULT_TIMEOUT(/Users/niall/.ansible.cfg) = 15\r\nINVENTORY_ENABLED(/Users/niall/.ansible.cfg) = ['ini']\r\nRETRY_FILES_ENABLED(/Users/niall/.ansible.cfg) = False\r\n```\r\n\r\n##### OS / ENVIRONMENT\r\n<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->\r\n- Target OS: FreeBSD\r\n- Target OS Release: not believed relevant; observed with 11.2-RELEASE-p4\r\n- Hardware: Virtualized KVM guest other than Xen; observed with KVM guest\r\n\r\n##### STEPS TO REPRODUCE\r\n<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->\r\n- Identify or set up **KVM guest** running **FreeBSD**\r\n- Register this KVM guest in the inventory (for example, as *freebsd-kvm-guest.example.org*)\r\n- Run **setup** module: `ansible -m setup freebsd-kvm-guest.example.org`\r\n- Observe that *virtualization_role* and *virtualization_type* facts are not reported\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```\r\nansible -m setup freebsd-kvm-guest.example.org\r\n```\r\n\r\n<!--- HINT: You can paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- Describe what you expected to happen when running the steps above -->\r\nThe *virtualization_role* and *virtualization_type* facts should be reported\r\n\r\n##### ACTUAL RESULTS\r\n<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->\r\nThe *virtualization_role* and *virtualization_type* facts are **missing** (not reported)\r\n\r\n<!--- Paste verbatim command output between quotes -->\r\n```paste below\r\n        \"ansible_userspace_bits\": \"64\",\r\n       ### missing facts belong here ###\r\n        \"ansible_vtnet0\": {\r\n        ...\r\n        },\r\n\r\n```\r\n"}}
{"actor":{"display_login":"jborean93"}}