pearofducks / ansible-vim

A vim plugin for syntax highlighting Ansible's common filetypes
MIT License
796 stars 98 forks source link

FR - use structured map instead of folded scalar in generated UltiSnips #42

Closed halberom closed 7 years ago

halberom commented 7 years ago

folded scalar, or any form of key=value in yaml in many cases fails to maintain type.

e.g.

---
- hosts: localhost
  connection: local
  gather_facts: False
  tasks:
    - set_fact: >
        myvar=123

    - debug: >
        msg={{ myvar is number }}
PLAY [localhost] **********************************************************************************************************************

TASK [set_fact] ***********************************************************************************************************************
ok: [localhost]

TASK [debug] **************************************************************************************************************************
ok: [localhost] => {
    "msg": false
}

PLAY RECAP ****************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0

It is better to use a structured map format

---
- hosts: localhost
  connection: local
  gather_facts: False
  tasks:
    - set_fact:
        myvar: 123

    - debug: 
         msg: "{{ myvar is number }}"

See a really good write up about it here - https://www.jeffgeerling.com/blog/yaml-best-practices-ansible-playbooks-tasks

halberom commented 7 years ago

wow, never mind, just noticed the parser args for the generate.py script.