大网数据广告活动
服务器运维问答

How to set ansible's gather_subset per host?

· 52CE 我爱测

We can use gather_subset at play level. Is it possible to use it on a per host level? Like putting it in a host_vars file? My quick testing on 2.2.1.0 did not work out. My problem at hand: I have a host, for which get_cpu_facts f…

问题原文

原帖链接 · Elrond · CC BY-SA 3.0

We can use gather_subset at play level. Is it possible to use it on a per host level? Like putting it in a host_vars file? My quick testing on 2.2.1.0 did not work out.

My problem at hand: I have a host, for which get_cpu_facts fails. And really, I never need hardware facts for this host, so I would like to put "!hardware" in its gather_subset.

已采纳解答

原帖链接 · Konstantin Suvorov · CC BY-SA 3.0

AFAIK you can't set gather_subset per host if you use automatic fact gathering at play start.

But you can disable automatic fact gathering and call setup manually with required parameters (which can be supplied from host vars):

---
- hosts: all
  gather_facts: no
  pre_tasks:
    - setup:
        gather_subset: "{{ gather_subset | default(omit) }}"

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-08-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。