I’m trying to put together a one-liner (# ansible all -m copy…) that will copy a file to a linux host only if the OS is a specific version… RHEL7, for example, skipping any RHEL5. “ansible_distribution_major_version” seems to be the fact I’m interested in, but how do I use it outside of a playbook?
Your problem here is that the adhoc command only runs a single task,
so you cannot run 'setup' (what runs when you gather_facts) to get the
info you need, also adhoc tasks do not have a way to add a when:
condition.