This PR should not have been merged, as there are very good reasons for
keeping the mongodb_database and mongodb_user state modules separate.
Additionally, role management was already supported at the time the PR
was merged.
Since this PR has not been in an official release of Salt, I'm reverting
it now to prevent any confusion.
Modifies the fibre_channel.py grain for linux to allow mocking. You
can't mock a file handle used in a for loop.
Fixes the mocking in test_windows_iscsi_iqn_grains. Apparently, you
can't stack multiple mocks in the same with statement.
This helper was part of a PR that did not get ported into the 2018.3.0rc1
branch, but to help with code re-use this commit adds the helper to
2018.3.0rc1.
For reasons I can't explain, in `salt.utils.json.find_json()` using
`.splitlines()` will sometimes convert a unicode string into a list of
str types on Python 2. So, that's weird. This can be triggered in
salt-ssh whenever there are non-ascii chars in the return data.
[DEBUG] raw = u'{"local": {"return": {"foo": "\xf6\xe4\xfc"}}}'
[DEBUG] raw.splitlines() = ['{"local": {"return": {"foo": "\xc3\xb6\xc3\xa4\xc3\xbc"}}}']
To resolve this, the UnicodeDecodeError is caught and reattempted with a
decoded list.
Additionally, this fixes a performance oversight. We process the string
one line at a time but we are iterating a number of times equal to the
length of the string. This means that we will nearly always end up doing
a bunch of extra list slices resulting in empty lists, which when joined
and loaded will produce ValueErrors, which we are catching and ignoring.
By enumerating over the split string, we ensure that we only iterate at
most a number of times equal to the amount of lines in the string.
Prior to this change, this state would update the uid/gid. This change
may have been accidental, and can cause problems with file ownership. A
uid/gid change must now be explicitly requested via two new arguments to
the `user.present` state.
A salt-call run already compiles pillar before executing the specified
function. Therefore, a performance improvement was made to re-use that
initial pillar data when running states. However, when we just re-use
that pillar data, we lose the ability to have custom external pillar
modules gain access to CLI pillar overrides. Therefore, this commit
changes the code in the state compiler which gathers/re-uses the pillar
data so that it only re-uses the existing in-memory pillar data when no
CLI pillar overrides were passed.