Bo's Oracle Station

查看: 926|回复: 0

ANSIBLE6-ANSIBLE LOCAL FACTS

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2020-8-8 20:32:18 | 显示全部楼层 |阅读模式

  1. ---
  2. - name: Fact Dump
  3.   hosts: srvgroup
  4.   tasks:
  5.   - name: Print All Facts
  6.     debug:
  7.       #var: ansible_facts.fqdn
  8.       msg: |
  9.         This "{{ ansible_facts.fqdn }}".
  10.         This "{{ ansible_facts['fqdn'] }}".
  11.         This "{{ ansible_fqdn }}".
  12.         SHORT HOSTNAME IS "{{ ansible_hostname }}".
  13.         DEFAULT IP ADDRESS IS "{{ ansible_facts.default_ipv4.address }}".
  14.         DEFAULT IP ADDRESS IS "{{ ansible_default_ipv4.address }}".
  15.         LOCAL IS "{{ ansible_local.local.a.v1 }}".
  16.         LOCAL IS "{{ ansible_local['local']['a']['v1'] }}".
  17.         LOCAL IS "{{ ansible_facts.ansible_local.local.a.v1 }}".
  18.         LOCAL IS "{{ ansible_facts['ansible_local']['local']['a']['v1'] }}".
  19.         Nextvar "{{ hostvars }}" Nextvar "{{ group_names }}".  
  20.         Nextvar "{{ groups }}" Nextvar "{{ inventory_hostname }}".


复制代码
  1. #!/bin/sh
  2. ansible all -m debug -a 'var=hostvars'
复制代码

  1. ---
  2. - name: Test
  3.   hosts: localhost
  4.   tasks:
  5.   - name: Debug
  6.     debug:
  7.       var: hostvars
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-5-9 16:53 , Processed in 0.043344 second(s), 24 queries .

快速回复 返回顶部 返回列表