I think you want 'ansible_distribution == "CentOS"'. "ansible_os_family" should be "RedHat" for both CentOS and RHEL.
--Steve On Thu, Mar 28, 2019 at 11:17 AM <computerprosupp...@gmail.com> wrote: > I am trying to use conditionals to determine if I run a task, It seems > that the when conditional does not work for some tasks. Is there a syntax > error here or am i formatting my yaml incorrectly. Any and all examples of > working conditionals would be apprecitated. > > > ansible-> cat copy-file.yml > --- > - name: Copy rpm to script to remote server based upon distro and distro > version number . redhat 6 or 7 > hosts: all > become: yes > strategy: free > gather_facts: True > tasks: > - name: Copying file with owner and permissions > copy: > src: /etc/ansible/rpms/CentOS6.rpm > dest: /scripts/CentOS6.rpm > owner: ansible > group: ansible > mode: 0740 > #when: (ansible_facts['distribution'] == "CentOS" and > ansible_facts['distribution_major_version'] == "6") > when: ansible_os_family == "CentOS" and distribution_major_version == > "6" > # (ansible_facts['distribution'] == "Debian" and > ansible_facts['distribution_major_version'] == "7") > > - name: httpd version check > command: /scirpts/software.bin > ignore_errors: yes > register: output > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to ansible-project+unsubscr...@googlegroups.com. > To post to this group, send email to ansible-project@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/0d3984fa-a081-4859-b652-c7411c4253ec%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/0d3984fa-a081-4859-b652-c7411c4253ec%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAFbiokfPxgDHzz-5C5MZkkZ-0ipf_gyPtqwGVdcP_pt2v4e%2BWQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.