51CTO博客已为您找到关于ansible -m shell -a的相关内容,包含IT学习相关文档代码介绍、相关教程视频课程,以及ansible -m shell -a问答内容。更多ansible -m shell -a相关解答可以来51CTO博客参与分享和学习,帮助广大IT技术人实现成长和进步。
在Ansible中,"-m shell -a"这个关键词表示使用shell模块执行命令。通过这个关键词,管理员可以在目标主机上执行任意的shell命令,比如查看文件内容、修改文件权限、安装软件包等等。这为管理员提供了非常灵活的自动化管理能力。 在实际应用中,"-m shell -a"通常会和其他模块一起使用,比如"-m yum -a"安装软件包、...
ansible web -m shell -a'echo "123" | passwd --stdin alex'# 批量创建密码 ansible192.168.107.131-m shell -a'bash a.sh'# 执行远程文件方式一 ansible192.168.107.131-m shell -a'/root/a.sh'# 执行远程文件方式二,文件必须有执行权限, 需要 chmod +x ansible192.168.107.131-m shell -a'/root/a...
groups 指定加入附加组 shell 指定用户shell password 指定用户密码 state 指定用户状态absent 删除用户 remove 如果是yes删除用户家目录 expires 指定用户的过期时间 date -d 2020-05-20 +%s(获取对应日期的unix时间戳) ansible yu -m user -a "name=test group=test1 shell=/sbin/nologin" file模块 远程管理文...
ansible all -m shell -a 'getenforce'的意思是获取服务器的selinux状态。
ansible all-m shell-a'useradd alex' 2)对所有主机,重置alex用户密码为China123 ansible all-m shell-a'echo China123 |passwd --stdin alex' 3)、对webser这个组里的所有主机显示$hostname ansible webser-m shell-a'echo $HOSTNAME' 4)、将默认模块由command修改为shell模块(shell模块可以替代command) ...
-m 模块名称,默认command模块 -a or --args模块参数 其它参数 -i inventory文件路径,或可执行脚本 -k 使用交互式登陆密码 -e 定义变量 -v 显示详细信息 二、双引号" " 单引号' '对执行结果的影响 执行以下命令来查看ansible的执行结果 1)shell
默认command模块 -a or --args模块参数 其它参数 -i inventory文件路径,或可执行脚本 -k 使用交互式登陆密码 -e 定义变量 -v 显示详细信息 二、双引号" " 单引号' '对执行结果的影响 执行以下命令来查看ansible的执行结果 1)shell ansible web -m shell -a "...
1# ansible tests -m shell -a 'ps -ef| grep ftp' 2# ansible tests -m shell -a 'ss -tln| grep 21' 8 .支持管道,raw,shell模块 1 # ansible tests -m raw -a 'ss -tln| grep 21' 5 其他命令 1 .查看帮助 列出所有已安装模块 ...
ansible test -m shell -a "ps aux | wc -l" #进程数量 ansible test -m shell -a "who" #登陆信息 ansible test -m shell -a "touch /tmp/txt.txt" 使用shell模块创建文件会有Warning警告提示,正常!!! 5)script模块 script模块会把-a后面的脚本拷贝到被管理端主机,然后执行这个脚本。