ansible 命令
# /etc/ansible/dydg#vim /etc/ansible/dydg/sa.yml # (1)无变量配置
---
- hosts: all
user: root
tasks:
- name:Download tar package
get_url:url=http://192.168.24.14/sa/sa.tar.gz dest=/tmpsha256sum=3c4585d5e5eaff1e94db11ce7190e24fc8a2754940cec3057effc61489c4a5cd
tags:
-downsa
- name: tarzxvf *.tar.gz file
shell:tar zxvf /tmp/sa.tar.gz -C /tmp
tags:
- tarxsa
- name: Runthe script
shell:chmod +x /tmp/sa/*.sh
shell:/tmp/sa/os.sh
tags:
- runsa
#vim /etc/ansible/dydg/sa.yml #(2)带变量配置
---
- hosts: all
user: root
vars:
GETURL:"http://192.168.24.14/sa"
TARFILE:"sa"
TMPPATCH:"/tmp"
SHFILE:"os.sh"
tasks:
- name:Download `TARFILE`.tar.gz package
get_url:url="`GETURL`/`TARFILE`.tar.gz" dest=`TMPPATCH` sha256sum=b6f482b3c26422299f06524086d1f087e1d93f2748be18542945bca4c2df1569
tags:
-downsa
- name: tarzxvf `TARFILE`.tar.gz file
shell:tar zxvf "`TMPPATCH`/`TARFILE`.tar.gz" -C `TMPPATCH`
tags:
-tarxsa
- name: Run`SHFILE` script
shell:"`TMPPATCH`/`TARFILE`/`SHFILE`"
tags:
- runsa
页:
[1]