ansible-playbook-常用

匿名 (未验证) 提交于 2019-12-03 00:39:02

创建软链: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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!