Having trouble with your yaml code for ansible, docker, or others?

Try this on for size:

$ pip install yamllint

~/.vimrc:

" auto yaml lint on write and auto setup standards
augroup yaml
  autocmd! BufWritePost \*.yml :make
  au FileType yaml setlocal tabstop=2 shiftwidth=2 softtabstop=2 autoindent expandtab makeprg=yamllint\\ %
augroup END

This will automatically setup standards for yaml to always match the correct syntax. It will also lint your yaml every time you save to the file.

Further reading