Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1825187
  • 博文数量: 276
  • 博客积分: 1574
  • 博客等级: 上尉
  • 技术积分: 2894
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-26 23:23
个人简介

生活的美妙在于,不知道一下秒是惊艳还是伤神,时光流转,珍惜现在的拥有的时光

文章分类

全部博文(276)

文章存档

2017年(17)

2016年(131)

2015年(63)

2013年(2)

2012年(32)

2011年(31)

分类: 架构设计与优化

2016-04-27 10:48:56

演示如下:

  1. vagrant@saltminion1:/tmp$ touch talen.txt
  2. vagrant@saltminion1:/tmp$ echo This is a test . > talen.txt


  1. vagrant@saltmaster:/var/cache/salt/master$ sudo salt '*' test.ping
  2. minion2:
  3.     True
  4. minion1:
  5.     True
  6. vagrant@saltmaster:/var/cache/salt/master$ sudo salt '*' cp.push /tmp/talen.txt
  7. minion2:
  8.     False
  9. minion1:
  10.     True
  11. vagrant@saltmaster:/var/cache/salt/master$ cd /var/cache/salt/master/minions/minion
  12. minion1/ minion2/
  13. vagrant@saltmaster:/var/cache/salt/master/minions$ tree
  14. .
  15. ├── minion1
  16. │   ├── files
  17. │   │   └── tmp
  18. │   │   └── talen.txt
  19. │   └── mine.p
  20. └── minion2
  21.     └── mine.p

  22. 4 directories, 3 files

有时,我们需要传送在minion上产生的文件.
salt已经有从minion上传送文件到master的特性.默认因为安全性问题,没有启用.
修改master启用这个特性.
file_recv: True

点击(此处)折叠或打开

  1. vagrant@saltmaster:~ $ vim /etc/salt/master

  2. # Allow minions to push files to the master. This is disabled by default, for
  3. # security purposes.
  4. #file_recv: False
  5. file_recv: True

salt-cp cp模块是minion端的,其它函数功能参考


# File Server Backend
#文件服务后端
#
# Salt supports a modular fileserver backend system, this system allows
# the salt master to link directly to third party systems to gather and
# manage the files available to minions. Multiple backends can be
# configured and will be searched for the requested file in the order in which
# they are defined here. The default setting only enables the standard backend
# "roots" which uses the "file_roots" option.
#salt支持一个模块化的文件服务后端系统,这个系统允许master直接链接到第三方平台系统收集和管理minions上的文件.请求文件将按定义的多个后端的顺序查询.默认使用file_roots选项只启用了最基本的roots.
#fileserver_backend:
#  - roots
#
# To use multiple backends list them in the order they are searched:
#fileserver_backend:
#  - git
#  - roots
#按顺序列出要查询的后端列表.
#
#如果你想让file_server允许追踪软链接文件系统树,取消下面的注释.默认是开启的,当前默认只应用于默认的文件服务后端.
# Uncomment the line below if you do not want the file_server to follow
# symlinks when walking the filesystem tree. This is set to True
# by default. Currently this only applies to the default roots
# fileserver_backend.
#fileserver_followsymlinks: False
#
# Uncomment the line below if you do not want symlinks to be
# treated as the files they are pointing to. By default this is set to
# False. By uncommenting the line below, any detected symlink while listing
# files on the Master will not be returned to the Minion.
#fileserver_ignoresymlinks: True
#
# By default, the Salt fileserver recurses fully into all defined environments
# to attempt to find files. To limit this behavior so that the fileserver only
# traverses directories with SLS files and special Salt directories like _modules,
# enable the option below. This might be useful for installations where a file root
# has a very large number of files and performance is impacted. Default is False.
# fileserver_limit_traversal: False
#
# The fileserver can fire events off every time the fileserver is updated,
# these are disabled by default, but can be easily turned on by setting this
# flag to True
#fileserver_events: False




如果想使用minion上的文件系统,简单启用两个参数
fileserver_backend:
  - roots
  - minion

file_recv: True
从下面的执行可以看到,当我们从minion1服务器上传文件到master后,minion1的上传目录/tmp已经可以在其它minions上看到了.
其它minions可以从minion1上共享的目录下载文件.

点击(此处)折叠或打开

  1. vagrant@saltmaster:~$ sudo salt '*' cp.list_master_dirs
  2. minion2:
  3.     - .
  4.     - common
  5.     - minion1/tmp
  6. minion1:
  7.     - .
  8.     - common
  9.     - minion1/tmp
  10. vagrant@saltmaster:~$ sudo salt 'minion2' cp.get_file salt://minion1/tmp/talen.txt /tmp/talen.2.txt
  11. minion2:
  12.     /tmp/talen.2.txt
  13. vagrant@saltminion2:~$ ll /tmp/talen.2.txt
  14. -rw-r--r-- 1 root root 17 Apr 27 03:47 /tmp/talen.2.txt


阅读(4175) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~