botang 发表于 2020-8-8 20:32:18

ANSIBLE6-ANSIBLE LOCAL FACTS


---
- name: Fact Dump
hosts: srvgroup
tasks:
- name: Print All Facts
    debug:
      #var: ansible_facts.fqdn
      msg: |
      This "{{ ansible_facts.fqdn }}".
      This "{{ ansible_facts['fqdn'] }}".
      This "{{ ansible_fqdn }}".
      SHORT HOSTNAME IS "{{ ansible_hostname }}".
      DEFAULT IP ADDRESS IS "{{ ansible_facts.default_ipv4.address }}".
      DEFAULT IP ADDRESS IS "{{ ansible_default_ipv4.address }}".
      LOCAL IS "{{ ansible_local.local.a.v1 }}".
      LOCAL IS "{{ ansible_local['local']['a']['v1'] }}".
      LOCAL IS "{{ ansible_facts.ansible_local.local.a.v1 }}".
      LOCAL IS "{{ ansible_facts['ansible_local']['local']['a']['v1'] }}".
      Nextvar "{{ hostvars }}" Nextvar "{{ group_names }}".
      Nextvar "{{ groups }}" Nextvar "{{ inventory_hostname }}".



#!/bin/sh
ansible all -m debug -a 'var=hostvars'


---
- name: Test
hosts: localhost
tasks:
- name: Debug
    debug:
      var: hostvars

页: [1]
查看完整版本: ANSIBLE6-ANSIBLE LOCAL FACTS