ansible 指南

本地执行

https://cloud.tencent.com/developer/ask/28078

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# 方法1: 
- name: check out a git repository
  local_action: 
    module: git
    repo: git://foosball.example.org/path/to/repo.git
    dest: /local/path

---
# 方法2: 
- name: check out a git repository
  local_action: git
  args:
    repo: git://foosball.example.org/path/to/repo.git
    dest: /local/path

判断目标状态 / 判断目标是否存在

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
- stat: path=/path/to/something 
    register: p 

# 判断目标是否为文件夹
- debug: msg="Path exists and is a directory" 
    when: p.stat.isdir is defined and p.stat.isdir 

# 判断目标是否为文件夹
- debug: msg="Path exists" 
    when: p.stat.exists