Ansible的一些常用小操作
1、检查Ansible节点的运行实践(uptime)
ansible -m command -a "uptime" 'web-servers'
2、查看节点的内核版本
ansible -m command -a "uname -r" 'web-servers'
3、给节点批量增加用户
ansible -m command -a "useradd test" 'web-servers'
查看被添加的用户
ansible -m command -a "grep test /etc/passwd" 'web-servers'
4、使用df 命令收集所有节点的硬盘使用信息,并保存到/tmp/command-output.txt文件中
ansible -m command -a "df -Th" 'web-servers' > /tmp/command-output.txt
查看各节点的磁盘使用情况
cat /tmp/command-output.txt