博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
saltstack 从minion传送文件到master及minion文件后端minionfs系统
阅读量:6236 次
发布时间:2019-06-22

本文共 3530 字,大约阅读时间需要 11 分钟。

演示如下:
  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端的,其它函数功能参考

https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.cp.html#salt.modules.cp.push

# 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

转载地址:http://pfkia.baihongyu.com/

你可能感兴趣的文章
php小代码(转)
查看>>
Windows内核编程之:返回状态值
查看>>
Xeon Phi之MIC编程知识点
查看>>
jigloo安装和介绍
查看>>
Linux下配置SSL (转)
查看>>
《转》程序员每年要做的十件事
查看>>
Android实现XML解析技术
查看>>
asp.net使用include包含文件
查看>>
迪米特法则
查看>>
Sql Server数据库自增长字段标识列的插入或更新修改操作办法
查看>>
CentOS,Fedora,Debian,Ubuntu,SuSE——我到底爱谁
查看>>
js方法call和apply实例解析
查看>>
也谈读书和书籍选择问题(C#)
查看>>
Jquery 数组操作(转)
查看>>
【BZOJ】1093: [ZJOI2007]最大半连通子图(tarjan+拓扑序)
查看>>
老码农教你学英语
查看>>
博客转发小工具2
查看>>
simple_html_dom使用小结
查看>>
Unity手游之路<七>角色控制器
查看>>
puma vs passenger vs rainbows! vs unicorn vs thin 适用场景 及 performance
查看>>