yet another markup language -- 另外的一种标记语言
yaml 语法:
序列:同一个类型的数据有多个,用"-" 来区分,叫序列
映射:价值对,用":"来表示
经典例子:
name: jame smiths
sex: male
age: 28
spource:
name: jane smiths
age: 25
sex: female
children:
- name: aaa smiths
age: 5
sex: male
- name: bbb smiths
age: 2
sex: female
playbook的经典例子:
- hosts: webserver
vars:
- username: "jj"
- say: "love"
tasks:
- name: create new user {{ username }}
user: name={{ username }}
- name: copy hosts to /opt/{{ say }}
copy: src=/etc/hosts dest=/tmp/{{ ansible_default_ipv4.address }}.txt ######setup模块中的变量
notify: restart nginx
handlers:
- name: restart nginx
service: name=nginx state=restarted
vars:就类似于我们在shell中定义了一个变量,后面频繁的引用这个变量,这个是同理的,我们定义了很多变量来保存,后面只需要引用变量即可。
弄清楚来龙去脉,整理成拓扑图,安装这张图来表达,也许就是出口成章(结构化思维)吧。