mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 11:10:21 -07:00
Merge pull request #12400 from mcsalgado/dict_default_argument
Fix mutable default argument
This commit is contained in:
commit
b44bc608e7
3 changed files with 11 additions and 3 deletions
|
@ -81,7 +81,10 @@ def get_file_parser(hostsfile, groups, loader):
|
||||||
class InventoryDirectory(object):
|
class InventoryDirectory(object):
|
||||||
''' Host inventory parser for ansible using a directory of inventories. '''
|
''' Host inventory parser for ansible using a directory of inventories. '''
|
||||||
|
|
||||||
def __init__(self, loader, groups=dict(), filename=C.DEFAULT_HOST_LIST):
|
def __init__(self, loader, groups=None, filename=C.DEFAULT_HOST_LIST):
|
||||||
|
if groups is None:
|
||||||
|
groups = dict()
|
||||||
|
|
||||||
self.names = os.listdir(filename)
|
self.names = os.listdir(filename)
|
||||||
self.names.sort()
|
self.names.sort()
|
||||||
self.directory = filename
|
self.directory = filename
|
||||||
|
|
|
@ -38,7 +38,10 @@ class InventoryParser(object):
|
||||||
with their associated hosts and variable settings.
|
with their associated hosts and variable settings.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, loader, groups=dict(), filename=C.DEFAULT_HOST_LIST):
|
def __init__(self, loader, groups=None, filename=C.DEFAULT_HOST_LIST):
|
||||||
|
if groups is None:
|
||||||
|
groups = dict()
|
||||||
|
|
||||||
self._loader = loader
|
self._loader = loader
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,9 @@ from ansible.module_utils.basic import json_dict_bytes_to_unicode
|
||||||
class InventoryScript:
|
class InventoryScript:
|
||||||
''' Host inventory parser for ansible using external inventory scripts. '''
|
''' Host inventory parser for ansible using external inventory scripts. '''
|
||||||
|
|
||||||
def __init__(self, loader, groups=dict(), filename=C.DEFAULT_HOST_LIST):
|
def __init__(self, loader, groups=None, filename=C.DEFAULT_HOST_LIST):
|
||||||
|
if groups is None:
|
||||||
|
groups = dict()
|
||||||
|
|
||||||
self._loader = loader
|
self._loader = loader
|
||||||
self.groups = groups
|
self.groups = groups
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue