TPeters
Flight Engineer
Flight Engineer
  • 357 Views

Indentation in included files?

An unexpected finding I like to share.

With include_files, YAML files are included at run-time.

Given that indentation is syntactically relevant in YAML, I would expect that the indentation of the included file must match that of the playbook that includes it.

However I find that in an included file the "- name" can start at the first column, and need not be indented one indentation more than the "  - tasks: " line in the playbook that includes it.

This of course prevents a lot of problems with how people prefer to indent their playbooks.

Is this feature specified somewhere? I didn't find it.

 

Labels (1)
1 Reply
Chetan_Tiwary_
Moderator
Moderator
  • 250 Views

Hello @TPeters ! 

I think that the documentation for the include_files directive does not specifically mention this feature, but it does say that the included file "must be a valid YAML file". This means that the included file must follow the YAML syntax rules, which include the rule that indentation is significant. However, the documentation does not specify that the indentation of the included file must match the indentation of the playbook that includes it. 

It is recommended to use the same indentation to have a homogeneous readability. 

@Travis 

0 Kudos
Join the discussion
You must log in to join this conversation.