Skip to content

Instantly share code, notes, and snippets.

@pcn
Created April 17, 2018 19:58
Show Gist options
  • Select an option

  • Save pcn/3a89341813f04dbb45cf63580dc25eb8 to your computer and use it in GitHub Desktop.

Select an option

Save pcn/3a89341813f04dbb45cf63580dc25eb8 to your computer and use it in GitHub Desktop.
What is the 11th argument?

This is about as close as I can get to the documentation for the file.managed execution module.

Here is the example:

salt '*' file.manage_file \
  /etc/httpd/conf.d/httpd.conf \
  '' \
  '{}' \
  salt://http/httpd.conf \
  '{hash_type: 'md5', 'hsum': <md5sum>}' \
  root \
  root \
  '755' \
  base \
  ''

Which is 10 arguments s far as I can tell. So I use the equivalent here, and I am asked for 11 arguments, but I have no idea which one I'm missing based on the documentation or the output?

 salt-ssh -c configdir '*cron*' -i --state-output=mixed --roster-file configdir/roster file.manage_file /etc/salt/pki/minion/minion_master.pub '' '{}' salt://minion_master.pub '{hash_type: md5, hsum: e559fb3b733fcb241f1d9ead6b4c2ef6}' root root 755 base ''
cron-1:
    ----------
    retcode:
        0
    stderr:
        Passed invalid arguments: manage_file() takes at least 11 arguments (10 given).
        
        Usage:
    stdout:
        Checks the destination against what was retrieved with get_managed and
            makes the appropriate modifications (if necessary).
        
            name
                location to place the file
        
            sfn
                location of cached file on the minion
        
                This is the path to the file stored on the minion. This file is placed
                on the minion using cp.cache_file.  If the hash sum of that file
                matches the source_sum, we do not transfer the file to the minion
                again.
        
                This file is then grabbed and if it has template set, it renders the
                file to be placed into the correct place on the system using
                salt.files.utils.copyfile()
        
            ret
                The initial state return data structure. Pass in ``None`` to use the
                default structure.
        
            source
                file reference on the master
        
            source_hash
                sum hash for source
        
            user
                user owner
        
            group
                group owner
        
            backup
                backup_mode
        
            attrs
                attributes to be set on file: '' means remove all of them
        
                .. versionadded:: 2018.3.0
        
            makedirs
                make directories if they do not exist
        
            template
                format of templating
        
            show_changes
                Include diff in state return
        
            contents:
                contents to be placed in the file
        
            dir_mode
                mode for directories created with makedirs
        
            skip_verify : False
                If ``True``, hash verification of remote file sources (``http://``,
                ``https://``, ``ftp://``) will be skipped, and the ``source_hash``
                argument will be ignored.
        
                .. versionadded:: 2016.3.0
        
            keep_mode : False
                If ``True``, and the ``source`` is a file from the Salt fileserver (or
                a local file on the minion), the mode of the destination file will be
                set to the mode of the source file.
        
                .. note:: keep_mode does not work with salt-ssh.
        
                    As a consequence of how the files are transferred to the minion, and
                    the inability to connect back to the master with salt-ssh, salt is
                    unable to stat the file as it exists on the fileserver and thus
                    cannot mirror the mode on the salt-ssh minion
        
            encoding
                If specified, then the specified encoding will be used. Otherwise, the
                file will be encoded using the system locale (usually UTF-8). See
                https://docs.python.org/3/library/codecs.html#standard-encodings for
                the list of available encodings.
        
                .. versionadded:: 2017.7.0
        
            encoding_errors : 'strict'
                Default is ```'strict'```.
                See https://docs.python.org/2/library/codecs.html#codec-base-classes
                for the error handling schemes.
        
                .. versionadded:: 2017.7.0
        
            CLI Example:
        
            .. code-block:: bash
        
                salt '*' file.manage_file /etc/httpd/conf.d/httpd.conf '' '{}' salt://http/httpd.conf '{hash_type: 'md5', 'hsum': <md5sum>}' root root '755' base ''
        
            .. versionchanged:: 2014.7.0
                ``follow_symlinks`` option added
        
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment