Awesome new deprecation warnings and YAML helper messages on 1.4 (devel) branch

Hi list!

I’ve added some very nice things for you on the 1.4 branch.

Normally I’d post this on -devel but a lot of people like to run from devel, so I figured I would share.

First off, there are some common YAML gotchas people encounter:

  • unbalanced quotes
  • colons that need to be quoted
  • starting a line with a {{
  • starting a line with a ’ and not ending the line with it

That’s really about it as far as I know.

In these cases, the system will now tell you when you get this kind of error exactly what it thinks you need to do to fix it. Useful!

Also, a lot of people run into trouble where they read an old blog post that references something archaic like “only_if” or “when_integer”, things that we built while we were still getting the hang of where we wanted to be. These all output nice deprecation warnings. There’s also an include + a with_items and a forward looking message about legacy variable usage, which will be gone in 1.6 after making it do everything everybody wants. (Yes, no need to reply about references or recursive usage, we’ve got you covered).

Deprecation warnings are purple if you have colors turned on, and can be disabled completely in ansible.cfg if you want.

The first variable replacement of an old style var will complain, but if you have many forks you might get this message more than once. In that case, just turn off the warning in ansible.cfg.

Note that the deprecation warning also tells you how to turn off the warning – I was thinking ahead so we don’t have to answer that question either :slight_smile:

In all, I hope everyone enjoys these and it improves everybody’s initial experience with ansible – whether having a few small YAML gotchas here or there or referring to an old blog post about syntax we don’t encourage.

I am also going to try to add a helper to suggest not to put a “{{ foo }}” in a when statement because foo is enough, and maybe a message about folks that try to put multiple actions in a task (though that one is a bit harder to detect).

If anybody hits any problems with these detectors misfiring or causing trouble (aside from maybe getting a duplicate message about legacy vars), let me know.

Thanks!

Excellent improvement! Thank you :slight_smile:

thanks for posting here :slight_smile: