首页 > 代码库 > sls语法:创建file,创建文件夹
sls语法:创建file,创建文件夹
http://blog.kukafei520.net/html/2014/942.html
/tmp/aaa.txt: file.managed
/tmp/salt_test: file.directory: - user: chen - group: chen - mode: 755 - makedirs: True
查询history 添加时间显示出来:
/etc/profile: file.append: - text: - export HISTTIMEFORMAT="%F %T `whoami` "
====================原文被谷歌和谐,备份下==================================================================
最近一直在使用saltstack,每次使用到file模块都还需要去查文档,今天在此记录,以便以后使用
文档:http://docs.saltstack.com/ref/states/all/salt.states.file.html
本文中用的top.sls
/srv/salt/top.slstest: ‘minion1‘: - file
创建
1. 空文件
/srv/salt/test/file.sls /tmp/a.txt: file.managed
2. 根据模板文件生成文件
/srv/salt/test/file.sls/tmp/a.txt: file.managed: - source: salt://files/a.txt/srv/salt/test/files/a.txtjust a test
3. 根据变量生成文件
/srv/salt/test/file.sls/tmp/a.txt: file.managed: - source: salt://files/a.txt - template: jinja/srv/salt/test/files/a.txt{{ pillar[‘os‘] }}
4. 创建多个文件
/srv/salt/test/file.sls{% set create_files = [‘/tmp/a‘, ‘/tmp/b‘, ‘/tmp/c‘] %}{% for eachfile in create_files %}{{eachfile}}: file.managed: - source: salt://files/tmp - template: jinja {% endfor %}
删除
/srv/salt/test/file.sls/tmp/a.txt: file.absent
添加内容
/srv/salt/test/file.sls /tmp/a.txt: file.append: - text: - ‘this is append line1‘ - ‘this is append line2‘
重命名
/srv/salt/test/file.sls /tmp/new: file.rename: - source: /tmp/old
目录
/srv/salt/test/file.sls /var/log/httpd: file.directory: - user: root - group: root - dir_mode: 755 - file_mode: 644 - recurse: - user - group - modesed/srv/salt/test/file.sls/etc/yum.repos.d/epel.repo: file.sed: - before: 1 - after: 0 - limit: ^enabled=
软连
/srv/salt/test/file.sls /tmp/new: file.symlink: - target: /tmp/old
是否存在
/srv/salt/test/file.sls /tmp/new: file.exists
dd
sls语法:创建file,创建文件夹
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。