mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-03-08 02:25:20 +01:00
Compare commits
12 commits
9998f50b29
...
3d713bcf77
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d713bcf77 | ||
|
|
e929aad539 | ||
|
|
0847977d12 | ||
|
|
2a1fb334ee | ||
|
|
af870d0b83 | ||
|
|
8e900e5218 | ||
|
|
45d8819b7c | ||
|
|
6782f88e39 | ||
|
|
119bba68a6 | ||
|
|
d0e01dd77f | ||
|
|
b1db0b8276 | ||
|
|
8e645bb9ce |
9 changed files with 94 additions and 32 deletions
|
|
@ -211,8 +211,6 @@ stages:
|
|||
test: rhel/9.1
|
||||
- name: FreeBSD 13.2
|
||||
test: freebsd/13.2
|
||||
- name: FreeBSD 12.4
|
||||
test: freebsd/12.4
|
||||
- stage: Remote_2_14
|
||||
displayName: Remote 2.14
|
||||
dependsOn: []
|
||||
|
|
@ -227,8 +225,6 @@ stages:
|
|||
test: rhel/8.6
|
||||
- name: FreeBSD 13.2
|
||||
test: freebsd/13.2
|
||||
- name: FreeBSD 12.4
|
||||
test: freebsd/12.4
|
||||
|
||||
## Finally
|
||||
|
||||
|
|
|
|||
2
changelogs/fragments/197-acl-fix-performance.yml
Normal file
2
changelogs/fragments/197-acl-fix-performance.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- acl - Fix module performance (https://github.com/ansible-collections/ansible.posix/pull/197).
|
||||
2
changelogs/fragments/421-remove-deprecation-warning.yml
Normal file
2
changelogs/fragments/421-remove-deprecation-warning.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
trivial:
|
||||
- synchronize - instantiate the connection plugin without the ``new_stdin`` argument, which is deprecated in ansible-core 2.15 (https://github.com/ansible-collections/ansible.posix/pull/421).
|
||||
2
changelogs/fragments/504-firewalld_info-warning.yaml
Normal file
2
changelogs/fragments/504-firewalld_info-warning.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- firewalld_info - Only warn about ignored zones, when there are zones ignored.
|
||||
|
|
@ -284,9 +284,6 @@ class ActionModule(ActionBase):
|
|||
# told (via delegate_to) that a different host is the source of the
|
||||
# rsync
|
||||
if not use_delegate and remote_transport:
|
||||
# Create a connection to localhost to run rsync on
|
||||
new_stdin = self._connection._new_stdin
|
||||
|
||||
# Unlike port, there can be only one shell
|
||||
localhost_shell = None
|
||||
for host in C.LOCALHOST:
|
||||
|
|
@ -315,7 +312,11 @@ class ActionModule(ActionBase):
|
|||
localhost_executable = C.DEFAULT_EXECUTABLE
|
||||
self._play_context.executable = localhost_executable
|
||||
|
||||
new_connection = connection_loader.get('local', self._play_context, new_stdin)
|
||||
try:
|
||||
new_connection = connection_loader.get('local', self._play_context)
|
||||
except TypeError:
|
||||
# Needed for ansible-core < 2.15
|
||||
new_connection = connection_loader.get('local', self._play_context, self._connection._new_stdin)
|
||||
self._connection = new_connection
|
||||
# Override _remote_is_local as an instance attribute specifically for the synchronize use case
|
||||
# ensuring we set local tmpdir correctly
|
||||
|
|
|
|||
|
|
@ -141,9 +141,13 @@ acl:
|
|||
|
||||
import os
|
||||
import platform
|
||||
import fcntl
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.compat import selectors
|
||||
from ansible.module_utils.common.text.converters import to_native, to_text, to_bytes
|
||||
from ansible.module_utils.six import b
|
||||
|
||||
|
||||
def split_entry(entry):
|
||||
|
|
@ -223,7 +227,7 @@ def build_command(module, mode, path, follow, default, recursive, recalculate_ma
|
|||
return cmd
|
||||
|
||||
|
||||
def acl_changed(module, cmd):
|
||||
def acl_changed(module, cmd, check_rc=True):
|
||||
'''Returns true if the provided command affects the existing ACLs, false otherwise.'''
|
||||
# FreeBSD do not have a --test flag, so by default, it is safer to always say "true"
|
||||
if platform.system().lower() == 'freebsd':
|
||||
|
|
@ -231,11 +235,63 @@ def acl_changed(module, cmd):
|
|||
|
||||
cmd = cmd[:] # lists are mutables so cmd would be overwritten without this
|
||||
cmd.insert(1, '--test')
|
||||
lines = run_acl(module, cmd)
|
||||
module._acl_changed = False
|
||||
|
||||
for line in lines:
|
||||
if not line.endswith('*,*'):
|
||||
return True
|
||||
def _process_stdout_from_pipe(proc, _acl_module=module):
|
||||
stdout = b''
|
||||
try:
|
||||
selector = selectors.DefaultSelector()
|
||||
except (IOError, OSError):
|
||||
# Failed to detect default selector for the given platform
|
||||
# Select PollSelector which is supported by major platforms
|
||||
selector = selectors.PollSelector()
|
||||
|
||||
selector.register(proc.stdout, selectors.EVENT_READ)
|
||||
if os.name == 'posix':
|
||||
fcntl.fcntl(proc.stdout.fileno(), fcntl.F_SETFL, fcntl.fcntl(proc.stdout.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK)
|
||||
|
||||
while True:
|
||||
events = selector.select(1)
|
||||
for key, event in events:
|
||||
b_chunk = key.fileobj.read()
|
||||
if b_chunk == b(''):
|
||||
selector.unregister(key.fileobj)
|
||||
if key.fileobj == proc.stdout:
|
||||
stdout = b_chunk
|
||||
if _acl_module._acl_changed:
|
||||
continue
|
||||
lines = []
|
||||
for l in stdout.splitlines():
|
||||
lines.append(l.strip())
|
||||
for line in lines:
|
||||
if not line.endswith(b'*,*'):
|
||||
proc.terminate()
|
||||
_acl_module._acl_changed = True
|
||||
proc.returncode = 0
|
||||
|
||||
# only break out if no pipes are left to read or
|
||||
# the pipes are completely read and
|
||||
# the process is terminated
|
||||
if (not events or not selector.get_map()) and proc.poll() is not None:
|
||||
break
|
||||
# No pipes are left to read but process is not yet terminated
|
||||
# Only then it is safe to wait for the process to be finished
|
||||
# NOTE: Actually proc.poll() is always None here if no selectors are left
|
||||
elif not selector.get_map() and proc.poll() is None:
|
||||
proc.wait()
|
||||
# The process is terminated. Since no pipes to read from are
|
||||
# left, there is no need to call select() again.
|
||||
break
|
||||
|
||||
try:
|
||||
(rc, out, err) = module.run_command(
|
||||
cmd, check_rc=check_rc,
|
||||
before_communicate_callback=_process_stdout_from_pipe)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=to_native(e))
|
||||
|
||||
if module._acl_changed:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
|
@ -356,7 +412,10 @@ def main():
|
|||
|
||||
if changed and not module.check_mode:
|
||||
run_acl(module, command)
|
||||
msg = "%s is present" % entry
|
||||
if recursive:
|
||||
msg = "%s is present recursively" % entry
|
||||
else:
|
||||
msg = "%s is present" % entry
|
||||
|
||||
elif state == 'absent':
|
||||
entry = build_entry(etype, entity, use_nfsv4_acls)
|
||||
|
|
@ -368,15 +427,23 @@ def main():
|
|||
|
||||
if changed and not module.check_mode:
|
||||
run_acl(module, command, False)
|
||||
msg = "%s is absent" % entry
|
||||
if recursive:
|
||||
msg = "%s is absent recursively" % entry
|
||||
else:
|
||||
msg = "%s is absent" % entry
|
||||
|
||||
elif state == 'query':
|
||||
msg = "current acl"
|
||||
|
||||
acl = run_acl(
|
||||
module,
|
||||
build_command(module, 'get', path, follow, default, recursive, recalculate_mask)
|
||||
)
|
||||
if recursive:
|
||||
acl = []
|
||||
warn = "Not showing resulting acls in the recursive mode"
|
||||
module.exit_json(changed=changed, msg=msg, acl=acl, warnings=warn)
|
||||
else:
|
||||
acl = run_acl(
|
||||
module,
|
||||
build_command(module, 'get', path, follow, default, recursive, recalculate_mask)
|
||||
)
|
||||
|
||||
module.exit_json(changed=changed, msg=msg, acl=acl)
|
||||
|
||||
|
|
|
|||
|
|
@ -356,8 +356,9 @@ def main():
|
|||
specified_zones = module.params['zones']
|
||||
collect_zones = list(set(specified_zones) & set(all_zones))
|
||||
ignore_zones = list(set(specified_zones) - set(collect_zones))
|
||||
warn.append(
|
||||
'Please note: zone:(%s) have been ignored in the gathering process.' % ','.join(ignore_zones))
|
||||
if ignore_zones:
|
||||
warn.append(
|
||||
'Please note: zone:(%s) have been ignored in the gathering process.' % ','.join(ignore_zones))
|
||||
else:
|
||||
collect_zones = get_all_zones(client)
|
||||
|
||||
|
|
|
|||
|
|
@ -831,7 +831,7 @@ def main():
|
|||
# handle mount on boot. To avoid mount option conflicts, if 'noauto'
|
||||
# specified in 'opts', mount module will ignore 'boot'.
|
||||
opts = args['opts'].split(',')
|
||||
if 'noauto' in opts:
|
||||
if module.params['boot'] and 'noauto' in opts:
|
||||
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")
|
||||
elif not module.params['boot']:
|
||||
args['boot'] = 'no'
|
||||
|
|
|
|||
|
|
@ -62,16 +62,7 @@ else
|
|||
retry pip install "https://github.com/ansible/ansible/archive/stable-${ansible_version}.tar.gz" --disable-pip-version-check
|
||||
fi
|
||||
|
||||
if [ "${SHIPPABLE_BUILD_ID:-}" ]; then
|
||||
export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible"
|
||||
SHIPPABLE_RESULT_DIR="$(pwd)/shippable"
|
||||
TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/ansible/posix"
|
||||
mkdir -p "${TEST_DIR}"
|
||||
cp -aT "${SHIPPABLE_BUILD_DIR}" "${TEST_DIR}"
|
||||
cd "${TEST_DIR}"
|
||||
else
|
||||
export ANSIBLE_COLLECTIONS_PATHS="${PWD}/../../../"
|
||||
fi
|
||||
export ANSIBLE_COLLECTIONS_PATHS="${PWD}/../../../"
|
||||
|
||||
# START: HACK install dependencies
|
||||
if [ "${ansible_version}" == "2.9" ] || [ "${ansible_version}" == "2.10" ]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue