ansible-playbook-常用
Posted qing-840
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ansible-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-常用的主要内容,如果未能解决你的问题,请参考以下文章
ansible自动运维工具之ansible-playbook详解