This commit fixes#9620 for file.recurse states. The bug report was for
file.managed, but the same issue would be encountered in file.recurse
states.
Also, some of the input validation for file.recurse has been improved
and cleaned up.
If file.managed state has a source param which is a list, and none of
the URIs in that list are found, a traceback occurs. This commit
modifies salt.modules.file.source_list to raise an exception when source
is a list and no matches are found, and then catches that exception in
the file.managed state so that Salt can return gracefully with a False
result and meaningful error message.
- Adds ability to specify which version of ruby to install gems into
- Similar feature to the rvm version
- Allows installing and managing multiple ruby versions
This replaces references to Hydrogen (in versionadded/versionchanged
directives as well as a few other mentions), to reflect the actual
release number of 2014.1.0.
In pull request #9599, I added code to make salt.utils.copyfile() set
the ownership and permissions of the new file to those of the
pre-existing file. However, this raises an exception when the
destination file doesn't exist, which happens on file.managed states
which are creating new files.
This commit fixes that regression.
state.highstate on it.
2014-01-07 01:45:43,315 [salt.minion ][INFO ] User sudo_ubuntu Executing command state.highstate with jid 20140107014542797484
2014-01-07 01:45:43,332 [salt.minion ][WARNING ] The minion function caused an exception: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/salt/minion.py", line 626, in _thread_return
'''
File "/usr/local/lib/python2.7/dist-packages/salt/modules/state.py", line 237, in highstate
conflict = running()
File "/usr/local/lib/python2.7/dist-packages/salt/modules/state.py", line 91, in running
active = __salt__['saltutil.is_running']('state.*')
File "/usr/local/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 365, in is_running
'''
File "/usr/local/lib/python2.7/dist-packages/salt/modules/saltutil.py", line 396, in running
continue
AttributeError: 'module' object has no attribute 'os_is_running'
2014-01-07 01:45:43,333 [salt.minion ][INFO ] Returning information for job: 20140107014542797484
The get_{uid,gid,user,group,mode} functions duplicate a lot of work done
in file.stats. this commit changes file.stats slightly to support
getting uid/gid of broken symlinks (code that was in get_{uid,gid}), and
then uses file.stats to supply the uid, gid, etc. for the get_*
functions.
Additionally, the "follow_symlinks" behavior in file.stats is opposite
from everywhere else in the file module, so the default value for this
parameter has been changed to True, and refs to this function from the
file state has been manually passed as False to preserve backwards
compatibility.
When salt.utils.copyfile() uses shutil.move() to move the target file to
the destination, the ownership/permissions from the original file that
existed at the destination path are not preserved. For security reasons,
files cached locally and compared to existing files in file.managed
states are created with ownership of root:root (or user:primarygroup, if
the master is running as non-root), with a mode of 600.
Normally, this would not be an issue since
salt.modules.file.check_perms() is invoked to correct the ownership and
permissions. However, recent modifications to that function have
resulted in the ownership/permissions not being modified if these
parameters are passed to check_perms() as None.
Since the user, group, and mode default to None in file.managed states,
if they are not explicitly defined in a state, this results in is the
newly-created file overwriting the old file, and the
ownership/permissions being left untouched.
This commit modifies salt.utils.copyfile() to restore the old file's
ownership and permissions after shutil.move is invoked to replace the
old file with the new one.
Fixes#9527.