mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 22:51:23 -07:00
parent
d5ad3093d6
commit
51b595992b
11 changed files with 75 additions and 78 deletions
|
@ -19,10 +19,10 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import select
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
import select
|
import sys
|
||||||
|
|
||||||
from ansible.module_utils.six import PY2, PY3
|
from ansible.module_utils.six import PY2, PY3
|
||||||
from ansible.module_utils._text import to_bytes
|
from ansible.module_utils._text import to_bytes
|
||||||
|
|
|
@ -67,6 +67,7 @@ codeCodes = {
|
||||||
'normal': u'0',
|
'normal': u'0',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def parsecolor(color):
|
def parsecolor(color):
|
||||||
"""SGR parameter string for the specified color name."""
|
"""SGR parameter string for the specified color name."""
|
||||||
matches = re.match(r"color(?P<color>[0-9]+)"
|
matches = re.match(r"color(?P<color>[0-9]+)"
|
||||||
|
@ -77,12 +78,13 @@ def parsecolor(color):
|
||||||
if matches.group('color'):
|
if matches.group('color'):
|
||||||
return u'38;5;%d' % int(matches.group('color'))
|
return u'38;5;%d' % int(matches.group('color'))
|
||||||
if matches.group('rgb'):
|
if matches.group('rgb'):
|
||||||
return u'38;5;%d' % (16 + 36 * int(matches.group('red'))
|
return u'38;5;%d' % (16 + 36 * int(matches.group('red')) +
|
||||||
+ 6 * int(matches.group('green'))
|
6 * int(matches.group('green')) +
|
||||||
+ int(matches.group('blue')))
|
int(matches.group('blue')))
|
||||||
if matches.group('gray'):
|
if matches.group('gray'):
|
||||||
return u'38;5;%d' % (232 + int(matches.group('gray')))
|
return u'38;5;%d' % (232 + int(matches.group('gray')))
|
||||||
|
|
||||||
|
|
||||||
def stringc(text, color):
|
def stringc(text, color):
|
||||||
"""String in color."""
|
"""String in color."""
|
||||||
|
|
||||||
|
@ -92,7 +94,6 @@ def stringc(text, color):
|
||||||
else:
|
else:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
# --- end "pretty"
|
|
||||||
|
|
||||||
def colorize(lead, num, color):
|
def colorize(lead, num, color):
|
||||||
""" Print 'lead' = 'num' in 'color' """
|
""" Print 'lead' = 'num' in 'color' """
|
||||||
|
@ -101,6 +102,7 @@ def colorize(lead, num, color):
|
||||||
s = stringc(s, color)
|
s = stringc(s, color)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
def hostcolor(host, stats, color=True):
|
def hostcolor(host, stats, color=True):
|
||||||
if ANSIBLE_COLOR and color:
|
if ANSIBLE_COLOR and color:
|
||||||
if stats['failures'] != 0 or stats['unreachable'] != 0:
|
if stats['failures'] != 0 or stats['unreachable'] != 0:
|
||||||
|
@ -110,4 +112,3 @@ def hostcolor(host, stats, color=True):
|
||||||
else:
|
else:
|
||||||
return u"%-37s" % stringc(host, C.COLOR_OK)
|
return u"%-37s" % stringc(host, C.COLOR_OK)
|
||||||
return u"%-26s" % host
|
return u"%-26s" % host
|
||||||
|
|
||||||
|
|
|
@ -18,24 +18,25 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import errno
|
||||||
import fcntl
|
import fcntl
|
||||||
import textwrap
|
import getpass
|
||||||
|
import locale
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import textwrap
|
||||||
import time
|
import time
|
||||||
import locale
|
|
||||||
import logging
|
|
||||||
import getpass
|
|
||||||
import errno
|
|
||||||
from struct import unpack, pack
|
from struct import unpack, pack
|
||||||
from termios import TIOCGWINSZ
|
from termios import TIOCGWINSZ
|
||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.utils.color import stringc
|
|
||||||
from ansible.module_utils._text import to_bytes, to_text
|
from ansible.module_utils._text import to_bytes, to_text
|
||||||
|
from ansible.utils.color import stringc
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -58,11 +59,14 @@ if C.DEFAULT_LOG_PATH:
|
||||||
else:
|
else:
|
||||||
print("[WARNING]: log file at %s is not writeable and we cannot create it, aborting\n" % path, file=sys.stderr)
|
print("[WARNING]: log file at %s is not writeable and we cannot create it, aborting\n" % path, file=sys.stderr)
|
||||||
|
|
||||||
b_COW_PATHS = (b"/usr/bin/cowsay",
|
b_COW_PATHS = (
|
||||||
|
b"/usr/bin/cowsay",
|
||||||
b"/usr/games/cowsay",
|
b"/usr/games/cowsay",
|
||||||
b"/usr/local/bin/cowsay", # BSD path for cowsay
|
b"/usr/local/bin/cowsay", # BSD path for cowsay
|
||||||
b"/opt/local/bin/cowsay", # MacPorts path for cowsay
|
b"/opt/local/bin/cowsay", # MacPorts path for cowsay
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Display:
|
class Display:
|
||||||
|
|
||||||
def __init__(self, verbosity=0):
|
def __init__(self, verbosity=0):
|
||||||
|
|
|
@ -17,14 +17,17 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import multiprocessing
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import tempfile
|
import tempfile
|
||||||
import multiprocessing
|
|
||||||
import time
|
import time
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
from ansible import constants as C
|
||||||
|
from ansible.errors import AnsibleError
|
||||||
|
from ansible.module_utils._text import to_text, to_bytes
|
||||||
|
|
||||||
PASSLIB_AVAILABLE = False
|
PASSLIB_AVAILABLE = False
|
||||||
try:
|
try:
|
||||||
import passlib.hash
|
import passlib.hash
|
||||||
|
@ -53,8 +56,8 @@ try:
|
||||||
from keyczar.keys import AesKey
|
from keyczar.keys import AesKey
|
||||||
except PowmInsecureWarning:
|
except PowmInsecureWarning:
|
||||||
display.system_warning(
|
display.system_warning(
|
||||||
"The version of gmp you have installed has a known issue regarding " + \
|
"The version of gmp you have installed has a known issue regarding "
|
||||||
"timing vulnerabilities when used with pycrypto. " + \
|
"timing vulnerabilities when used with pycrypto. "
|
||||||
"If possible, you should update it (i.e. yum update gmp)."
|
"If possible, you should update it (i.e. yum update gmp)."
|
||||||
)
|
)
|
||||||
warnings.resetwarnings()
|
warnings.resetwarnings()
|
||||||
|
@ -65,10 +68,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from ansible import constants as C
|
|
||||||
from ansible.errors import AnsibleError
|
|
||||||
from ansible.module_utils._text import to_text, to_bytes
|
|
||||||
|
|
||||||
__all__ = ['do_encrypt']
|
__all__ = ['do_encrypt']
|
||||||
|
|
||||||
_LOCK = multiprocessing.Lock()
|
_LOCK = multiprocessing.Lock()
|
||||||
|
@ -100,6 +99,7 @@ def do_encrypt(result, encrypt, salt_size=None, salt=None):
|
||||||
# impact calling code.
|
# impact calling code.
|
||||||
return to_text(result, errors='strict')
|
return to_text(result, errors='strict')
|
||||||
|
|
||||||
|
|
||||||
def key_for_hostname(hostname):
|
def key_for_hostname(hostname):
|
||||||
# fireball mode is an implementation of ansible firing up zeromq via SSH
|
# fireball mode is an implementation of ansible firing up zeromq via SSH
|
||||||
# to use no persistent daemons or key management
|
# to use no persistent daemons or key management
|
||||||
|
@ -152,12 +152,13 @@ def key_for_hostname(hostname):
|
||||||
fh.close()
|
fh.close()
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
|
||||||
def keyczar_encrypt(key, msg):
|
def keyczar_encrypt(key, msg):
|
||||||
return key.Encrypt(msg.encode('utf-8'))
|
return key.Encrypt(msg.encode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
def keyczar_decrypt(key, msg):
|
def keyczar_decrypt(key, msg):
|
||||||
try:
|
try:
|
||||||
return key.Decrypt(msg)
|
return key.Decrypt(msg)
|
||||||
except key_errors.InvalidSignatureError:
|
except key_errors.InvalidSignatureError:
|
||||||
raise AnsibleError("decryption failed")
|
raise AnsibleError("decryption failed")
|
||||||
|
|
||||||
|
|
|
@ -32,4 +32,3 @@ def pct_to_int(value, num_items, min_value=1):
|
||||||
return int((value_pct / 100.0) * num_items) or min_value
|
return int((value_pct / 100.0) * num_items) or min_value
|
||||||
else:
|
else:
|
||||||
return int(value)
|
return int(value)
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ notes:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
# Documentation fragment for E-Series
|
# Documentation fragment for E-Series
|
||||||
ESERIES = """
|
ESERIES = """
|
||||||
options:
|
options:
|
||||||
|
|
|
@ -18,6 +18,7 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from errno import EEXIST
|
from errno import EEXIST
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
from ansible.module_utils._text import to_bytes, to_native, to_text
|
||||||
|
@ -49,6 +50,7 @@ def unfrackpath(path, follow=True):
|
||||||
|
|
||||||
return to_text(final_path, errors='surrogate_or_strict')
|
return to_text(final_path, errors='surrogate_or_strict')
|
||||||
|
|
||||||
|
|
||||||
def makedirs_safe(path, mode=None):
|
def makedirs_safe(path, mode=None):
|
||||||
'''Safe way to create dirs in muliprocess/thread environments.
|
'''Safe way to create dirs in muliprocess/thread environments.
|
||||||
|
|
||||||
|
@ -70,6 +72,7 @@ def makedirs_safe(path, mode=None):
|
||||||
if e.errno != EEXIST:
|
if e.errno != EEXIST:
|
||||||
raise AnsibleError("Unable to create local directories(%s): %s" % (to_native(rpath), to_native(e)))
|
raise AnsibleError("Unable to create local directories(%s): %s" % (to_native(rpath), to_native(e)))
|
||||||
|
|
||||||
|
|
||||||
def basedir(source):
|
def basedir(source):
|
||||||
""" returns directory for inventory or playbook """
|
""" returns directory for inventory or playbook """
|
||||||
|
|
||||||
|
@ -86,4 +89,3 @@ def basedir(source):
|
||||||
dname = os.path.abspath(dname)
|
dname = os.path.abspath(dname)
|
||||||
|
|
||||||
return dname
|
return dname
|
||||||
|
|
||||||
|
|
|
@ -44,4 +44,3 @@ def check_for_controlpersist(ssh_executable):
|
||||||
|
|
||||||
_HAS_CONTROLPERSIST[ssh_executable] = has_cp
|
_HAS_CONTROLPERSIST[ssh_executable] = has_cp
|
||||||
return has_cp
|
return has_cp
|
||||||
|
|
||||||
|
|
|
@ -23,15 +23,15 @@ import ast
|
||||||
import random
|
import random
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from json import dumps
|
|
||||||
from collections import MutableMapping
|
from collections import MutableMapping
|
||||||
|
from json import dumps
|
||||||
|
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
|
||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
from ansible.errors import AnsibleError, AnsibleOptionsError
|
from ansible.errors import AnsibleError, AnsibleOptionsError
|
||||||
from ansible.parsing.splitter import parse_kv
|
from ansible.module_utils.six import iteritems, string_types
|
||||||
from ansible.module_utils._text import to_native, to_text
|
from ansible.module_utils._text import to_native, to_text
|
||||||
|
from ansible.parsing.splitter import parse_kv
|
||||||
|
|
||||||
|
|
||||||
_MAXSIZE = 2 ** 32
|
_MAXSIZE = 2 ** 32
|
||||||
|
@ -51,6 +51,7 @@ def get_unique_id():
|
||||||
("%012x" % cur_id)[:12],
|
("%012x" % cur_id)[:12],
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
def _validate_mutable_mappings(a, b):
|
def _validate_mutable_mappings(a, b):
|
||||||
"""
|
"""
|
||||||
Internal convenience function to ensure arguments are MutableMappings
|
Internal convenience function to ensure arguments are MutableMappings
|
||||||
|
|
|
@ -806,13 +806,4 @@ lib/ansible/template/__init__.py
|
||||||
lib/ansible/template/safe_eval.py
|
lib/ansible/template/safe_eval.py
|
||||||
lib/ansible/template/template.py
|
lib/ansible/template/template.py
|
||||||
lib/ansible/template/vars.py
|
lib/ansible/template/vars.py
|
||||||
lib/ansible/utils/cmd_functions.py
|
|
||||||
lib/ansible/utils/color.py
|
|
||||||
lib/ansible/utils/display.py
|
|
||||||
lib/ansible/utils/encrypt.py
|
|
||||||
lib/ansible/utils/helpers.py
|
|
||||||
lib/ansible/utils/listify.py
|
|
||||||
lib/ansible/utils/path.py
|
|
||||||
lib/ansible/utils/ssh_functions.py
|
|
||||||
lib/ansible/utils/vars.py
|
|
||||||
lib/ansible/vars/manager.py
|
lib/ansible/vars/manager.py
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue