ansible_distribution_major_version on the CLI

49 views
Skip to first unread message

Reece Webb

unread,
Feb 1, 2016, 5:59:48 PM2/1/16
to Ansible Project
Greets,

Hopefully this is a ridiculously simple question...

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?

Thanks,
Reece

Brian Coca

unread,
Feb 1, 2016, 6:01:03 PM2/1/16
to Ansible Project
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.

You need a playbook.

--
Brian Coca

Reece Webb

unread,
Feb 2, 2016, 10:24:35 AM2/2/16
to Ansible Project
Well that's annoying. Thanks for the explanation.

Reece

Reply all
Reply to author
Forward
0 new messages