# when: ansible conditional's based on distribution major version

**URL:** <https://forum.ansible.com/t/when-ansible-conditionals-based-on-distribution-major-version/31140>\
**Category:** Ansible Project\
**Created:** [August 27, 2019, 3:06pm UTC](https://forum.ansible.com/t/when-ansible-conditionals-based-on-distribution-major-version/31140 "2019-08-27T15:06:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeffrey\_Agnitsch](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@Jeffrey\_Agnitsch](https://forum.ansible.com/u/Jeffrey_Agnitsch)\
**Post date:** [August 27, 2019, 3:06pm UTC](https://forum.ansible.com/t/when-ansible-conditionals-based-on-distribution-major-version/31140/1 "2019-08-27T15:06:56Z")

</div>

I am trying to copy over .rpm files based on the major version of the operating system I believe I am referencing the ansible\_facts part incorrectly does anyone have an example of the right way?

tasks:

- name: Copy kernel RHEL6  
copy:  
src: /etc/ansible/files/individual\_files/test/kernel-2.6.32-754.15.3.el6.x86\_64.rpm  
dest: /tmp/kernel-2.6.32-754.15.3.el6.x86\_64.rpm  
owner: root  
group: root  
mode: 0644  
when: ansible\_facts[‘distribution\_major\_version’] == ‘6’

- name: Copy kernel RHEL6 firmware  
copy:  
src: /etc/ansible/files/individual\_files/test/kernel-firmware-2.6.32-754.15.3.el6.noarch.rpm  
dest: /tmp/kernel-firmware-2.6.32-754.15.3.el6.noarch.rpm  
owner: root  
group: root  
mode: 0644  
when: ansible\_facts[‘ansible\_distribution\_major\_version’] == ‘6’

- name: Copy kernel RHEL7  
copy:  
src: /etc/ansible/files/individual\_files/rhel7/kernel-3.10.0-1062.el7.x86\_64.rpm  
dest: /tmp/kernel-3.10.0-1062.el7.x86\_64.rpm  
owner: root  
group: root  
mode: 0644  
when: ansible\_facts[‘ansible\_distribution\_major\_version’] == ‘7’

- name: Copy kernel RHEL7 firmware  
copy:  
src: /etc/ansible/files/individual\_files/rhel7/linux-firmware-20190429-72.gitddde598.el7.noarch.rpm  
dest: /tmp/linux-firmware-20190429-72.gitddde598.el7.noarch.rpm  
owner: root  
group: root  
mode: 0644  
when: ansible\_facts[‘ansible\_distribution\_major\_version’] == ‘7’

---

<div class="post-metadata">

**Author:** ![Michael\_M1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_M1](https://forum.ansible.com/u/Michael_M1)\
**Post date:** [August 27, 2019, 3:28pm UTC](https://forum.ansible.com/t/when-ansible-conditionals-based-on-distribution-major-version/31140/2 "2019-08-27T15:28:40Z")

</div>

Jeffrey,

Try:

when: ansible\_distribution\_major\_version == '7'

---

<div class="post-metadata">

**Author:** ![Jeffrey\_Agnitsch](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@Jeffrey\_Agnitsch](https://forum.ansible.com/u/Jeffrey_Agnitsch)\
**Post date:** [August 27, 2019, 3:43pm UTC](https://forum.ansible.com/t/when-ansible-conditionals-based-on-distribution-major-version/31140/3 "2019-08-27T15:43:56Z")

</div>

That worked thank you very much!
