mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
d6e2f1846a
commit
ca1514cf2a
17 changed files with 23 additions and 54 deletions
|
@ -32,15 +32,13 @@ from ansible.utils.path import makedirs_safe
|
|||
|
||||
BOOL_TRUE = frozenset([ "true", "t", "y", "1", "yes", "on" ])
|
||||
|
||||
# copied from utils, avoid circular reference fun :)
|
||||
def mk_boolean(value):
|
||||
ret = value
|
||||
if not isinstance(value, bool):
|
||||
if value is None:
|
||||
return False
|
||||
val = str(value)
|
||||
if val.lower() in BOOL_TRUE:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
ret = False
|
||||
ret = (str(value).lower() in BOOL_TRUE)
|
||||
return ret
|
||||
|
||||
def shell_expand(path, expand_relative_paths=False):
|
||||
'''
|
||||
|
|
|
@ -22,15 +22,13 @@ __metaclass__ = type
|
|||
import fnmatch
|
||||
|
||||
from ansible.compat.six import iteritems
|
||||
|
||||
from ansible import constants as C
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.playbook.block import Block
|
||||
from ansible.playbook.task import Task
|
||||
from ansible.playbook.role_include import IncludeRole
|
||||
|
||||
from ansible.utils.boolean import boolean
|
||||
boolean = C.mk_boolean
|
||||
|
||||
__all__ = ['PlayIterator']
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ from ansible.errors import AnsibleParserError, AnsibleUndefinedVariable
|
|||
from ansible.module_utils._text import to_text
|
||||
from ansible.playbook.attribute import Attribute, FieldAttribute
|
||||
from ansible.parsing.dataloader import DataLoader
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.constants import mk_boolean as boolean
|
||||
from ansible.utils.vars import combine_vars, isidentifier
|
||||
|
||||
try:
|
||||
|
|
|
@ -34,7 +34,8 @@ from ansible.errors import AnsibleError
|
|||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.playbook.attribute import FieldAttribute
|
||||
from ansible.playbook.base import Base
|
||||
from ansible.utils.boolean import boolean
|
||||
|
||||
boolean = C.mk_boolean
|
||||
|
||||
__all__ = ['PlayContext']
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ import os.path
|
|||
import re
|
||||
import tempfile
|
||||
|
||||
from ansible.constants import mk_boolean as boolean
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils._text import to_native, to_text
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.utils.hashing import checksum_s
|
||||
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ import os
|
|||
import stat
|
||||
import tempfile
|
||||
|
||||
from ansible.constants import mk_boolean as boolean
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.utils.hashing import checksum
|
||||
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ __metaclass__ = type
|
|||
import os
|
||||
import base64
|
||||
|
||||
from ansible.constants import mk_boolean as boolean
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.utils.hashing import checksum, checksum_s, md5, secure_hash
|
||||
from ansible.utils.path import makedirs_safe
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ __metaclass__ = type
|
|||
|
||||
import os
|
||||
|
||||
from ansible.constants import mk_boolean as boolean
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
|
|
@ -20,8 +20,8 @@ __metaclass__ = type
|
|||
|
||||
from ansible.compat.six import iteritems, string_types
|
||||
|
||||
from ansible.constants import mk_boolean as boolean
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.utils.vars import isidentifier
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
|
|
@ -22,9 +22,10 @@ import os.path
|
|||
from ansible.playbook.play_context import MAGIC_VARIABLE_MAPPING
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.plugins import connection_loader
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible import constants as C
|
||||
|
||||
boolean = C.mk_boolean
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ from ansible.errors import AnsibleError
|
|||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.hashing import checksum_s
|
||||
from ansible.utils.boolean import boolean
|
||||
|
||||
boolean = C.mk_boolean
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import os
|
|||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.constants import mk_boolean as boolean
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
|
|
@ -35,9 +35,9 @@ from ansible.errors import AnsibleOptionsError
|
|||
from ansible.module_utils.basic import BOOLEANS
|
||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||
from ansible.plugins.connection import ConnectionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.utils.path import unfrackpath, makedirs_safe
|
||||
|
||||
boolean = C.mk_boolean
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
|
|
|
@ -125,7 +125,7 @@ from jinja2.exceptions import UndefinedError
|
|||
from ansible.compat.six import string_types
|
||||
from ansible.errors import AnsibleFileNotFound, AnsibleLookupError, AnsibleUndefinedVariable
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.constants import mk_boolean as boolean
|
||||
|
||||
class LookupModule(LookupBase):
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ from ansible.compat.six import string_types
|
|||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.utils.listify import listify_lookup_plugin_terms
|
||||
from ansible.utils.boolean import boolean
|
||||
from ansible.constants import mk_boolean as boolean
|
||||
|
||||
FLAGS = ('skip_missing',)
|
||||
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
def boolean(value):
|
||||
val = str(value)
|
||||
if val.lower() in [ "true", "t", "y", "1", "yes" ]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
@ -13,5 +13,5 @@ test_hash:
|
|||
# variables used for conditional testing
|
||||
test_bare: true
|
||||
test_bare_var: 123
|
||||
test_bare_nested_good: "{{test_bare_var}} == 123"
|
||||
test_bare_nested_good: "test_bare_var == 123"
|
||||
test_bare_nested_bad: "{{test_bare_var}} == 321"
|
||||
|
|
Loading…
Reference in a new issue