[root@xinxi-server ansible]# ansible or -m ping
47.106.123.191 | SUCCESS => {
"changed": false,
"ping": "pong"
}
120.79.83.150 | SUCCESS => {
"changed": false,
"ping": "pong"
}
118.31.62.194 | SUCCESS => {
"changed": false,
"ping": "pong"
}
ansible Client -m command -a "free -m"
ansible Client -m script -a "/home/test.sh 12 34"
ansible Client -m copy -a "src=/home/test.sh dest=/tmp/ owner=root group=root mode=0755"
ansible 118.31.62.194 -m stat -a "path=/home/test.sh"
ansible 118.31.62.194 -m get_url -a "url=http://soft.vpser.net/lnmp/lnmp1.5.tar.gz dest=/home mode=0755 force=yes"
ansible 118.31.62.194 -m yum -a "name=npm state=latest"
ansible Client -m cron -a "name='check dirs' hour='5,2' job='ls / > /home/test.txt'"
[root@iz tmp]# crontab -l
#Ansible: check dirs
* 5,2 * * * ls / > /home/test.txt
---
- hosts: aliyun
remote_user: root
tasks:
- name: install git
yum: name=git state=latest
- name: clone lnmp
shell: "cd /home;git clone https://user123:pass123@gitee.com/linzening/lnmp"
- name: install lnmp
shell: "cd /home/lnmp/;bash install.sh lnmp"
- name: install redis
shell: "cd /home/lnmp/;bash addons.sh 5"
- name: install mysql
shell: "cd /home/lnmp/tools;bash rpm_mysql8_0_12.sh"
- name: install myweb
shell: "cd /home/lnmp/tools;bash deploy_myweb.sh"
...