mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-05 07:54:00 -07:00
Feature/add ansible play hosts all (#17498)
* refactor ignore_limits_and_restrictions into ignore_limits and ignore_limitations * add ansible_play_hosts_all * update docs re ansible_play_hosts_all * only use play.hosts when is has a value * replace ansible_play_hosts with ansible_play_hosts_all * remove unnecessary var
This commit is contained in:
parent
52bf021904
commit
4650d8910e
5 changed files with 24 additions and 27 deletions
|
@ -20,19 +20,17 @@ from __future__ import (absolute_import, division, print_function)
|
|||
__metaclass__ = type
|
||||
|
||||
import collections
|
||||
import sys
|
||||
|
||||
from jinja2 import Undefined as j2undefined
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.inventory.host import Host
|
||||
from ansible.template import Templar
|
||||
|
||||
STATIC_VARS = [
|
||||
'inventory_hostname', 'inventory_hostname_short',
|
||||
'inventory_file', 'inventory_dir', 'playbook_dir',
|
||||
'ansible_play_hosts', 'play_hosts', 'groups', 'ungrouped', 'group_names',
|
||||
'ansible_version', 'omit', 'role_names'
|
||||
'inventory_hostname', 'inventory_hostname_short',
|
||||
'inventory_file', 'inventory_dir', 'playbook_dir',
|
||||
'ansible_play_hosts', 'play_hosts', 'groups',
|
||||
'ungrouped', 'group_names', 'ansible_version', 'omit', 'role_names'
|
||||
]
|
||||
|
||||
try:
|
||||
|
@ -103,15 +101,15 @@ class HostVars(collections.Mapping):
|
|||
return self._find_host(host_name) is not None
|
||||
|
||||
def __iter__(self):
|
||||
for host in self._inventory.get_hosts(ignore_limits_and_restrictions=True):
|
||||
for host in self._inventory.get_hosts(ignore_limits=True, ignore_restrictions=True):
|
||||
yield host
|
||||
|
||||
def __len__(self):
|
||||
return len(self._inventory.get_hosts(ignore_limits_and_restrictions=True))
|
||||
return len(self._inventory.get_hosts(ignore_limits=True, ignore_restrictions=True))
|
||||
|
||||
def __repr__(self):
|
||||
out = {}
|
||||
for host in self._inventory.get_hosts(ignore_limits_and_restrictions=True):
|
||||
for host in self._inventory.get_hosts(ignore_limits=True, ignore_restrictions=True):
|
||||
name = host.name
|
||||
out[name] = self.get(name)
|
||||
return repr(out)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue