ansible-命令

ansible 拷贝文件命令

ansible all -m copy -a 'src=/home/finance/icc_deploy/other/jdk1.8.0_231.tar.gz dest=/tmp/'
-m : 指定模块
-a 参数
all 表示所有主机

shell 模块命令

ansible all -m shell -b -a 'tar -zxf /tmp/jdk1.8.0_231.tar.gz -C /opt'
-b : 执行sudo切换身份操作

 

hosts 配置文件

【test】
192.168.10.1
192.168.10.2
【test:vars】
ansible_ssh_user=root
ansible_ssh_pass="1234"
ansible_ssh_port=22

[test2]
name1 ansible_ssh_host=192.168.8.111 ansible_ssh_user="root" ansible_ssh_pass="123456" ansible_ssh_port=22
name2 ansible_ssh_host=192.168.8.222 ansible_ssh_user="root" ansible_ssh_pass="123456" ansible_ssh_port=22

 

posted @ 2024-04-22 21:04  huxl1  阅读(2)  评论(0编辑  收藏  举报