Ansible: Facts获取方法 How to get facts?

参考文章:https://www.middlewareinventory.com/blog/ansible-facts-list-how-to-use-ansible-facts/


常用指令:

ansible <hostname (or) hostgroup> -m setup

本地测试指令如:

ansible -i deploy/profiles/ha/hosts config  -u root --key-file ~/.ssh/build.key -m setup

Ansible Gathered Facts or playbook variables belongs to one of the following types

Dictionary:{{ansible_apparmor.status}}

List:{{ansible_all_ipv4_addresses[1]}} (不带[1]会返回整个list内容)

AnsibleUnsafeText:{{ ansible_architecture }}


测试variable类型:{{ <the variable name> | type_debug }}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,449评论 0 10
  • 运维核心工作: 操作系统安装(物理机、虚拟机)--> 应用程序包部署(安装、配置、服务启动 )--> 批量操作 -...
    Net夜风阅读 1,617评论 0 4
  • 简介 架构 原理 组成 ANSIBLE PLAYBOOKS:任务剧本(任务集),编排定义Ansible任务集的配置...
    毛利卷卷发阅读 1,090评论 0 2
  • 1)安装2)常用模块3)inventory4)playbook(role\tag\template)5) yaml...
    秦记阅读 4,278评论 2 5
  • 小草啊小草 就因为小草 在人心目中很渺小 叫不出名字也不少 看到无名小草就乱叫 我故乡有一种草 和我一样土生土长 ...
    秋AldrichB果阅读 461评论 0 7