码迷,mamicode.com
首页 > 其他好文 > 详细

ansible-playbook-常用

时间:2018-07-04 17:39:41      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:sts   directory   art   start   out   Owner   tty   目录   playbook   

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

 

同步目录synchronize 和建目录:

 

- 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 }}"

 

ansible-playbook-常用

标签:sts   directory   art   start   out   Owner   tty   目录   playbook   

原文地址:https://www.cnblogs.com/Qing-840/p/9264160.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!