Saltstack's file Management

Source: Internet
Author: User

1.managed File Management

/srv/salt/file/managed.sls

/tmp/hyxc:  file.managed:    - Source:      -salt://files/hyxc      -salt://files/ HWG     - makedirs:true#    -replace:false    - user:root    - Group : Root    -mode:644
-Backup:minion -Template:jinja

Execute the following command to complete the source file management

' test82.salt.cn ' State.sls file.managed

If the file exists before, and the source file is changed relative to it, the backup file of the file can be seen in/var/cache/salt/minion/file_backup/after management

2.append File Management

/srv/salt/file/append.sls

/tmp/hyxc:  file.append:    -Text: |          HYXC

Execute the following command to add a line at the end of the file

' test82.salt.cn ' State.sls file.append

3.recurse Recursive management files

/srv/salt/file/recurse.sls

/tmp/HWG:  file.recurse:    -source:salt://files/HWG    - user:nobody    -  Group:nobody    -file_mode:644    -dir_mode:755    - include_empty:ture#     -Clean:ture #     -Exclude_pat: [email protected] (hh)#    -include_pat: [Email protected] (ss) 

Execute the following command to complete the file recursion management

' test82.salt.cn ' State.sls file.recurse

4.directory Catalog Management

/srv/salt/file/directory.sls

/tmp/HWG:  file.directory:    - user:root    - group:root    -dir_mode:755    -file_mode:644    - makedirs:true    - recurse:      - user      - Group       -mode

Create a directory by executing the following command

' test82.salt.cn ' State.sls file.directory

5.absent Deleting files or directories

/srv/salt/file/absent.sls

/tmp/HWG:  file.absent:    -Name:/TMP/HWG

Execute the following command to delete the file

' test82.salt.cn ' State.sls file.absent

or perform the following on the command line

' * ' file.remove/tmp/hyxc

6. Note the specified line of the file, uncomment with uncomment

/srv/salt/file/comment.sls

/tmp/hyxc:  file.comment:    -regex: ^text 2    - backup:. bak    #

Command line execute the following command to complete the comment

' test82.salt.cn ' State.sls file.comment

7.rename Renaming files

/srv/salt/file/rename.sls

/tmp/Jim:  file.rename:    -Source:/TMP/HWG

The command line implements the following command to rename

' test82.salt.cn ' State.sls file.rename

8.replace Replace file contents

/srv/salt/file/replace.sls

/tmp/hyxc:  file.replace:    -Pattern: |        Jim    -REPL: |        Hyxc

The command line executes the following command to replace

' test82.salt.cn ' State.sls file.replace

or the command line directly executes the following

' *  ' file.replace/path/to/file pattern='=' repl=':'

9.exists Check if file exists

/srv/salt/file/exists.sls

/tmp/hyxc:  file.exists:    -Name:/TMP/HYXC

command line to perform the following command check

' test82.salt.cn ' State.sls file.exists

or execute the following command directly at the command line

' test82.salt.cn ' file.file_exists/etc/passwd

10. Command line Execution command

Change a file belongs to the main genus Group

' * ' file.chown/etc/passwd root root

Change file group

' * ' file.chgrp/etc/passwd root

Saltstack's file Management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.