官术网_书友最值得收藏!

YAML syntax for writing Ansible playbooks

Ansible playbooks are written in YAML, which stands for YAML Ain't Markup Language

According to the official document (http://yaml.org/spec/current.html):

YAML Ain’t Markup Language (abbreviated YAML) is a data serialization language designed to be human-friendly and work well with modern programming languages for everyday tasks.

Ansible uses YAML because it is easier for humans to read and write than other common data formats, such as XML or JSON. All YAML files (regardless of their association with Ansible or not) can optionally begin with --- and end with .... This is part of the YAML format and indicates the start and end of a document.

YAML files should end with .yaml or .yml. YAML is case sensitive.
You can also use linters, such as www.yamllint.com, or your text editor plugins for linting YAML syntax, which help you to troubleshoot any syntax errors and so on. 

Here is an example of a simple playbook to showcase YAML syntax from Ansible documentation (http://docs.ansible.com/ansible/playbooks_intro.html#playbook-language-example):

- hosts: webservers
  vars:
    http_port: 80
    max_clients: 200
  remote_user: root
tasks: - name: Ensure apache is at the latest version yum:
name: httpd
state: latest
- name: Write the apache config file template:
src: /srv/httpd.j2
dest: /etc/httpd.conf

notify: - restart apache
- name: Ensure apache is running (and enable it at boot) service:
name: httpd
state: started
enabled: yes
handlers: - name: Restart apache service:
name: httpd
state: restarted
主站蜘蛛池模板: 手游| 灵川县| 潞城市| 克山县| 津市市| 花莲县| 盖州市| 汉寿县| 喀什市| 新巴尔虎右旗| 合水县| 七台河市| 沅江市| 遂川县| 定远县| 渭源县| 惠来县| 南靖县| 长丰县| 鸡泽县| 台山市| 朝阳市| 剑河县| 天长市| 富民县| 宝山区| 呼图壁县| 沾化县| 邢台县| 乐平市| 民权县| 永宁县| 万安县| 从化市| 略阳县| 泊头市| 孙吴县| 株洲县| 丹凤县| 商都县| 柳江县|