ansible playbook yaml 实例
- hosts: iplist
remote_user: tomcat
gather_facts: false
tasks:
- name: enter /opt directory
shell: cd /opt
- name: create tomcat directory
file: dest=/opt/tomcat mode=755 state=directory
#- name: touch a file
# shell: cd /opt/tomcat;touch a.txt
- name: add some msg
lineinfile: dest=/opt/tomcat/a.txt line='export JAVA_HOME=/usr/java/jdk1.7.0
_55' create=yes state=present mode=0555
- name: get result
shell: cat /opt/tomcat/a.txt
tags:
- lscmd
register: lscmd_result
ignore_errors: True
- name: add new file where lscmd sucess
file: path=/opt/tomcat/b.txt state=touch
tags:
- new_file
when: lscmd_result|success
标签:opt,name,tomcat,yaml,ansible,playbook,file,txt,lscmd From: https://blog.csdn.net/lisanmengmeng/article/details/143423022