yml indentation quirkness

Hi Team,

I have a bug in the code that is simple to fix but hard to find out. It took me almost 30 minutes to see but it is due to the fact that yml indentation syntax quirkness!

Lets see the block below

  • block:
  • name: disable sssd service for non production nodes by all means
    service: name=sssd state=stopped enabled=no
    ignore_errors: True
  • shell: “chmod -x /init.d/sssd.sh || true”
  • shell: “kill ps -ef|grep '/usr/sbin/sssd' | grep -v grep | awk '{print $2}' || true”
  • name: remove the sss service from nsswitch.conf
    replace: dest=/etc/nsswitch.conf regexp=‘^(.*) sss$’ replace=‘\1’ backup=yes
    when: host_type not in [ ‘production’, ‘livepreview’ ]

You see the fact that after the - it must be a space (right?) so the when condition allied to the whole block needs to be match with exactly the b of the block. Or course if I set tab width to 2 it would be it if the start of the line press tab, but if I set tab to any other size, it wont, I need to align it exactly two spaces!

After a long block the alignment does not look good anymore and harder to spot out indentation error.

Can I do something like -[TAB]block and from that only use TAB so it does not matter TAB size, I can always use tab for indentation?

You're better off wth spaces than tabs:

    http://yaml.org/spec/current.html#id2519916

You may be able to have your text editor insert spaces when you hit the
tab key, if that's what you want. Google turned up recommendations for vi
and Emacs, or search for your editor of choice.

                                      -Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.