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