---
- name: Unblock wlan
  command: rfkill unblock wlan
  when: ansible_architecture == 'x86_64'
  ignore_errors: yes

- name: Install hostapd
  apt: name=hostapd state=latest
  when: ansible_architecture == 'x86_64'

- name: Remove sysVinit startup file
  file: path=/etc/init.d/hostapd state=absent

- include_vars: group_vars/{{ ansible_architecture }}.yml

- name: Copy hostapd.conf file
  template: src=hostapd.conf.j2 dest=/etc/hostapd/hostapd.conf owner=root group=root mode=755 backup=yes

- name: Copy hosts file
  template: src=hosts.j2 dest=/etc/hosts owner=root group=root mode=755 backup=yes

- name: Copy startup script
  copy: src=hostapd dest=/etc/systemd/system/hostapd.service owner=root group=root mode=664

- name: Enable service hostapd
  service: name=hostapd enabled=yes

- name: Start hostapd
  service: name=hostapd state=started

---
- name: Unblock wlan
  command: rfkill unblock wlan
  when: ansible_architecture == 'x86_64'
  ignore_errors: yes

- name: Install hostapd
  apt: name=hostapd state=latest
  when: ansible_architecture == 'x86_64' or ansible_architecture == 'armv7l'

- name: Remove sysVinit startup file
  file: path=/etc/init.d/hostapd state=absent
  when: ansible_architecture == 'armhf'

- include_vars: group_vars/{{ ansible_architecture }}.yml

- name: Copy hostapd.conf file
  template: src=hostapd.conf.j2 dest=/etc/hostapd/hostapd.conf owner=root group=root mode=755 backup=yes

- name: Copy hosts file
  template: src=hosts.j2 dest=/etc/hosts owner=root group=root mode=755 backup=yes

- name: Copy startup script
  copy: src=hostapd dest=/etc/systemd/system/hostapd.service owner=root group=root mode=664

- name: Enable service hostapd
  service: name=hostapd enabled=yes

- name: Start hostapd
  service: name=hostapd state=started

Add compatibility with raspberry pi
Add compatibility with raspberry pi
