centos 7.2 安装ansible
2018-06-06 本文已影响23人
stormzhai
1、安装ansible
yum -y install ansible
2、配置
vi /etc/ansible/hosts
[web]
web1 ansible_ssh_port=22 ansible_ssh_host=10.0.0.1 ansible_ssh_user=root ansible_ssh_pass=vagrant
3、命令
ansible web -a 'ls /home'
ansible web -m ping
ansible web -m copy -a "src=/tmp/server dest=/tmp/server"
ansible web -m file -a "dest=/tmp/server mode=755 owner=root group=root"
ansible web -m yum -a "name=ntpd state=installed"
4、ansible-playbook
ansible-playbook mysql_delete.yml -e "host=web user=root"
想要测试某条任务
- name: ChunkMgn | create set | ck_new_set
shell: cd {{ chunkkeeper.bin }} && ./ChunkMgn create {{ superadmin.username }} {{ set.id }} {{ set.hosts }}
tags:
- test
ansible-playbook mysql_install.yml -e "host=web user=root" --tags=test
5、安装mysql(centos7.2测试)
mysql安装文件地址
密码: 36qf