Devel branch FYI: only_if, when_* properly removed!

Hi all,

It’s time to clean out some legacy features that have not been needed for many many months.

As you have seen in the deprecation warnings previously, when_ and only_if features slated for removal for 1.5 have been removed from the 1.5 development branch. Use the “when” statement, it’s much nicer and has been the suggested form in docs and example content for some time. While you could use legacy forms in 1.4.X with warnings, this is no longer possible.

I don’t think anyone should even remember what “only_if” was, but definitely exorcise that demon if you have it lurking around too :slight_smile:

Similarly, include + with_items (don’t ask) which was similarly deprecated also now generates an error. Use “with_together” plus “with_nested” to loop inside the task file if you have this construct and have not already fixed it.

If you turned deprecation warnings off rather than fixing things, this is a good reason to not turn deprecation warnings off, and you can now take care of the above :slight_smile:

The only deprecated feature really remaining at this time (i.e. the only thing we plan to deprecate) is the “old style $variables”. These are slated to continue to be operational in 1.5, and removed during the 1.6 development cycle, at which case I’ll be very happy – they involve a lot of custom code.

While it is said one of the fatal blunders is to not fight a land war in Asia (I do hope the Princess Bride is quotable here, to my Asian friends I would never attempt such a thing and you should watch the movie anyway), another is writing your own templating system :slight_smile:

I’m very happy with the Ansible language as it stands now – very close to my original vision for what it should be, it feels happy and non-frustrating where it took a while to get conditionals ironed out. So I hope this will be our last language feature deprecation for some time and we’ve offered everyone a reasonably smooth upgrade path. We definitely want to continue to keep backwards compatibility very clean, and it’s also important to us to have a very streamlined, easy to write language.

Here’s a quick review of the upgrades:

Before:
when_integer: “{{ x }} != 5”

Transitional (1.2) – still valid, but unnecessary:
when: “{{ x }} != 5”
Now:
when: x != 5

Before (having to fall back to only_if to compare things of different types), ouch:
only_if: “{{ x }} != 5 and ‘{{ favcolor }}’ != ‘red’”
Transitional (1.2) – still valid, but unneccessary:
when: “{{ x }} != 5 and {{ favcolor }} != ‘red’”
Now:
when: “x !=5 and favcolor != ‘red’”

Note: I somewhat mispoke about being totally happy with syntax. I’m still not entirely happy with the lookup plugin syntax for when people need to do {{ lookup(‘module’, ‘x=1 y=2’) }}, etc. But we can fix that in other ways while still keeping that syntax around, and I have no plans to deprecate that when we do.

Thanks!

I shed a single tear for include/with_items :frowning:

but nice to get rid of cruft!

* goes to change his plays *