- name: install yum deps for arm!!!
  shell: dnf install -y python-urlgrabber pyxattr yum-metadata-parser
  when: ansible_distribution == "Fedora" and ansible_machine == "armv7l" and ansible_distribution_version|int >= 22

- name: install yum from Fedora 23 for arm!!!
  shell: dnf install -y https://kojipkgs.fedoraproject.org//packages/yum/3.4.3/506.fc23/noarch/yum-3.4.3-506.fc23.noarch.rpm python-dnf 
  when: ansible_distribution == "Fedora" and ansible_machine == "armv7l" and ansible_distribution_version|int >= 22

- name: install yum if it has been dropped from our distribution -- Fedora 22 uses dnf!!!
  shell: dnf install -y yum
  when: ansible_distribution == "Fedora" and ansible_distribution_version|int >= 22 and ansible_machine != "armv7l"

- name: get the createrepo program
  package: name=createrepo
           state=present
  when: is_redhat

- name: Create local repo
  shell: createrepo {{ yum_packages_dir }}
  when: is_redhat

- name: Install local repo file.
  template: dest=/etc/yum.repos.d/iiab-local.repo
            src=local.repo
            owner=root
            mode=0644
  when: is_redhat

- name: Install yum packages
  package: name={{ item }}
           state=present
  with_items:
   - yum-utils
   - createrepo
   - wpa_supplicant
   - linux-firmware
   - syslog
   - xml-common
  when: is_redhat

- name: Install yum packages for Debian
  package: name={{ item }}
           state=present
  with_items:
    - inetutils-syslogd
    - wpasupplicant
  when: is_debuntu

- name: Install common packages
  package: name={{ item }}
           state=present
  with_items:
   - acpid
   - mlocate
   - rsync
   - htop
   - etckeeper
   - python-passlib
   - usbmount
   - net-tools
   - openssh-server
   - sudo
   - logrotate
   - make
   - tar
   - unzip
   - bzip2
   - i2c-tools
   - bridge-utils
   - usbutils
   - hostapd
   - wget
   - openssl   #FC 18 does not supply, but pear requires
   - gawk
   - sqlite3

- name: Update common packages (not debian
  package: name={{ item }}
           state=latest
  with_items:
   - NetworkManager
   - glibc # CVE-2015-7547
   - bash
   - iptables
  when: is_redhat

- name: Update common packages  (debian)
  package: name={{ item }}
           state=latest
  with_items:
   - libc6
   - bash
   - iptables
  when: is_debuntu


# instuctions state to start with a fully updated system before starting, stop using
# ansible as a crutch for developers not following the directions and taking short-cuts

#- name: If version of Network manager has changed, subsequent nmcli commands will fail,restart now
#  service: name=NetworkManager
#           state=restarted
#  when: not installing
# the above should use a handler - all reboots should wait until all 
# mods are preformed

- name: Install optional exFAT packages for CentOS
  shell: yum --enablerepo=li-nux-ro install exfat-utils fuse-exfat
  when: exFAT_enabled == "True" and ansible_distribution == "CentOS"
