获取 ansible os 家族和 ansible pkg mgr 与设置

我们可以通过设置模块和过滤器的 Ad-Hoc 命令获取事实(ansible_os_familyansible_pkg_mgr)。

  • ansible_os_family:

      $ ansible all -m setup -a 'filter=ansible_os_family'
      ra.local | SUCCESS => {
          "ansible_facts": {
              "ansible_os_family": "Debian"
          },
          "changed": false
      }
    
  • ansible_pkg_mgr:

      $ ansible all -m setup -a 'filter=ansible_pkg_mgr'
      debian.local | SUCCESS => {
          "ansible_facts": {
              "ansible_pkg_mgr": "apt"
          },
          "changed": false
      }