bash 如何使用 Ansible chmod +xa 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40505772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to chmod +x a file with Ansible?
提问by Atlantic0
What is the best way to chmod + x a file with ansible.
使用ansible chmod + xa 文件的最佳方法是什么?
Converting the following script to ansible format.
将以下脚本转换为 ansible 格式。
mv /tmp/metadata.sh /usr/local/bin/meta.sh
chmod +x /usr/local/bin/meta.sh
This is what I have so far..
这是我到目前为止..
- name: move /tmp/metadata.sh to /usr/local/bin/metadata.sh
command: mv /tmp/metadata.sh /usr/local/bin/metadata.sh
回答by heemayl
ansible
has mode
parameter in file
module exactly for this purpose.
ansible
为此mode
,file
模块中有参数。
To add execute permission for everyone (i.e. chmod a+x
on command line):
为所有人添加执行权限(即chmod a+x
在命令行上):
- name: Changing perm of "/foo/bar.sh", adding "+x"
file: dest=/foo/bar.sh mode=a+x
Symbolic modes are supported since version 1.8, on a prior version you need to use the octal bits.
从 1.8 版开始支持符号模式,在之前的版本中您需要使用八进制位。