创建软链:file:
- name: create link
hosts: "{{hosts_ip}}"
tasks:
- name: create link
file: src={{src_path}} dest={{dest_link_path}} state=link
运行脚本:
- name: restart jetty
hosts: "{{hosts_ip}}"
tasks:
- name: restart jetty
shell: "{{shell_message}}"
register: ret
- name: display variable
debug: msg="{{ ret.stdout_lines }}"
重启jt或者java:shell:
- name: restart jetty
hosts: "{{hosts_ip}}"
tasks:
- name: restart jetty
shell: "set -m && /opt/bin/jt 2"
register: ret
- name: display variable
debug: msg="{{ ret.stdout_lines }}"
- name: rsync learning
hosts: "{{hosts_ip}}"
tasks:
- name: mkdir dir
file: path="{{dest_path}}" state=directory mode=0755 owner=dev
- name: rsync server dir
synchronize: src="{{src_path}}" dest="{{dest_path}}" recursive=yes rsync_opts=--exclude-from={{src_path}}/exclude.txt
register: ret
- name: display variable
debug: msg="{{ ret.stdout_lines }}"
原文:https://www.cnblogs.com/Qing-840/p/9264160.html