# ansible\_distribution\_major\_version on the CLI

**URL:** <https://forum.ansible.com/t/ansible-distribution-major-version-on-the-cli/20411>\
**Category:** Ansible Project\
**Created:** [February 1, 2016, 10:57pm UTC](https://forum.ansible.com/t/ansible-distribution-major-version-on-the-cli/20411 "2016-02-01T22:57:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reece\_Webb](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@Reece\_Webb](https://forum.ansible.com/u/Reece_Webb)\
**Post date:** [February 1, 2016, 10:57pm UTC](https://forum.ansible.com/t/ansible-distribution-major-version-on-the-cli/20411/1 "2016-02-01T22:57:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 1, 2016, 11:00pm UTC](https://forum.ansible.com/t/ansible-distribution-major-version-on-the-cli/20411/2 "2016-02-01T23:00:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Reece\_Webb](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@Reece\_Webb](https://forum.ansible.com/u/Reece_Webb)\
**Post date:** [February 2, 2016, 3:24pm UTC](https://forum.ansible.com/t/ansible-distribution-major-version-on-the-cli/20411/3 "2016-02-02T15:24:35Z")

</div>

Well that's annoying. Thanks for the explanation.

Reece
