saltstack 学习之cp模块
【基本介绍】
这里简单介绍cp模块,cp实现文件的推送和拉取。
【基本配置】
cp.push - 获取minion的文件到master机器
Push a file from the minion up to the master, the file will be saved to the salt master in the master's minion files cachedir (defaults to /var/cache/salt/master/minions/minion-id/files)
Since this feature allows a minion to push a file up to the master server it is disabled by default for security purposes. To enable, set file_recv to True in the master configuration file, and restart the master.
配置支持从minion拉取文件,并配置cache目录。
# Allow minions to push files to the master. This is disabled by default, for
# security purposes.
file_recv: True
# Directory to store job and cache data:
cachedir: /var/cache/salt/master
[root@vpn ~]# salt xxx cp.push /usr/local/scripts/cut_nglog.sh
xx:
True
[root@vpn ~]# ls -l /var/cache/salt/master/minions/xxx/files/usr/local/scripts/cut_nglog.sh
-rw-r--r-- 1 root root 2099 Oct 15 18:05 /var/cache/salt/master/minions/xxx/files/usr/local/scripts/cut_nglog.sh
cp.push_dir拉取minion上的目录到master上面,类似cp.push
file.get_file - 推送master的文件到minion机器
Used to get a single file from the salt master
[root@vpn ~]# salt xxx cp.get_file salt://xx.sls /root/ttt
xxx:
/root/ttt
[root@xxx ~]# ls -l /root/ttt
-rw-r--r-- 1 root root 29 Oct 15 18:14 /root/ttt
类似于salt-cp
salt-cp '*' [ options ] SOURCE DEST
[root@vpn ~]# salt-cp xxx /root/salt/nagios.log /root/ttt
{'xxx': {'/root/ttt': True}}
【其他模块】
其他模块参照
http://salt.readthedocs.org/en/latest/ref/modules/all/salt.modules.cp.html#salt.modules.cp.get_file
【参考引用】
http://rfyiamcool.blog.51cto.com/1030776/1360468
https://salt.readthedocs.org/en/v0.17.1/ref/cli/salt-cp.html
分享到:
相关推荐
Item source.txt dest/dest.txtCopy a filecp -r ./source ./destCopy-Item ./source ./dest -RecurseRecursively copy from one folder to anothermv ./source.txt ./dest/dest.txtMove-Item ./source.txt ./dest/...
(3)Completely remove all compiled files under osdrv directory, and the generated images: make OSDRV_CROSS=arm-hisiv100nptl-linux CHIP=hi3521 distclean make OSDRV_CROSS=arm-hisiv100nptl-linux CHIP=hi...
6. 命令行工具:在操作系统中,如Windows的CMD或PowerShell,Linux的Terminal,以及macOS的Terminal,都有内置的命令行工具如`copy`(Windows)或`cp`(Unix-like系统),能快速执行文件复制操作,支持批量处理和...
- `cp -R source_directory destination_directory`:递归复制目录。 - `cp -p source_file destination`:复制文件时保持原有的元数据(如权限、修改时间)。 - **mv (Move)** - `mv source destination`:...
$ hardlink -husage: hardlink [-h] [-d] [-f] [-q | -v] src dstCopy files and merge directories using hard links.positional arguments: src Source file or directory. Follow symbolic links. dst ...
1. **cp (Copy)** - `cp file_from file_to`: 复制文件。 2. **ln (Link)** - `ln [-s] source linkname`: 创建硬链接或软链接(符号链接)。 3. **ls (List)** - `ls [directory]`: 列出当前目录或指定目录下的...
5. `cp` - Copy:对文件或文件夹进行复制,可以使用 `cp -r` 选项来递归复制文件夹。 6. `mv` - Move:对文件或文件夹进行移动,可以使用 `mv` 命令来重命名文件或文件夹。 目录管理 7. `pwd` - Print Working ...
`cp`(Copy) **用途:** 复制文件或目录。 - **基本用法:** - `cp <source> <destination>`: 复制文件。 - `cp -r <source> <destination>`: 递归复制目录。 - **示例:** ```bash # 复制名为"source_file....
然后通过 `chmod +x copy_files.sh` 给脚本添加执行权限,即可通过 `./copy_files.sh` 来运行。 5. **错误处理和日志记录**: 在执行复制操作时,可能遇到权限问题或其他错误。为了解决这些问题,可以在脚本中...
files directory may be changed after Drupal is installed). In some cases, you may need to create the directory and modify its permissions manually. Use the following commands (from the installation...
- **cp (Copy files and directories)** - **功能**: 复制文件或目录。 - **语法**: - 复制文件: `cp file1 file2` - 复制目录: `cp -R dir1 dir2` - **mv (Move or rename files)** - **功能**: 移动文件或...
- **Manipulating Files** Common file manipulation commands include `cp` (copy), `mv` (move or rename), `rm` (remove), and `touch` (create or update file timestamps). **Working With Directories** - **...
Files.copy(sourceDir, targetDir, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES); ``` 在C#中,可以使用`System.IO`命名空间下的`File`和`Directory`类进行文件和目录的复制。 ```...
# Upload all files in directory "phpbb_root" with their structure to your # phpBB root directory # # Remember to upload all the language files and template files to all your # language packs and ...
Read and write excel XML files in windows-1251, CP866, UTF-8, UTF-16 (Little Endian and Big Endian) encodings Save and Load Open Document Format (ODS) as directory (Lazarus/Delphi) and as packed ...
用法Usage: cpx <source> <dest> [options] Copy files, watching for changes. <source> The glob of target files. <dest> The path of a destination directory.Options: -c, --command <command> A command text...
cp 复制文件或目录 (copy)** - `cp source target`:复制文件或目录。 - `cp -r /source/directory /target/directory`:递归复制整个目录及其子目录。 - `cp -p file1 file2`:复制文件时保持原始文件属性不变。 ...
g) Copy a file : cp (5 marks) i.e.: file1 file2 h) Display the usage of storage space:sum (10 marks) Display the usage of the 16MB space. You need to list how many blocks are used and how many ...