From 35cd2b44a56c0d4baf020bfb4b5ee9e37a97b106 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 5 Nov 2017 13:22:37 -0500 Subject: [PATCH] iiab_wireless_lan_iface is defined for machines without wifi --- roles/network/tasks/debian.yml | 2 +- roles/network/tasks/hostapd.yml | 6 +++--- roles/network/tasks/restart.yml | 10 +++++----- roles/network/templates/hostapd/hostapd.conf.j2 | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/roles/network/tasks/debian.yml b/roles/network/tasks/debian.yml index 6fe93a197..889c10dde 100644 --- a/roles/network/tasks/debian.yml +++ b/roles/network/tasks/debian.yml @@ -71,7 +71,7 @@ - name: restart hostapd when wifi is present service: name=hostapd state=restarted - when: iiab_wireless_lan_iface != "none" and hostapd_enabled and iiab_network_mode != "Appliance" + when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance" #- name: dhcp_server may be affected - starting - user choice # service: name={{ dhcp_service2 }} state=started diff --git a/roles/network/tasks/hostapd.yml b/roles/network/tasks/hostapd.yml index 2d6953613..33b9d8727 100644 --- a/roles/network/tasks/hostapd.yml +++ b/roles/network/tasks/hostapd.yml @@ -4,12 +4,12 @@ owner=root group=root mode=0644 - when: iiab_wireless_lan_iface != "none" + when: discovered_wireless_iface is defined - name: Disable the Access Point Hostapd program service: enabled=no name=hostapd.service - when: iiab_wireless_lan_iface == "none" or iiab_network_mode == "Appliance" or not hostapd_enabled + when: not iiab_wireless_lan_iface is defined or iiab_network_mode == "Appliance" or not hostapd_enabled - name: Use custom systemd unit file to start hostapd template: src=hostapd/hostapd.service.j2 @@ -21,4 +21,4 @@ - name: Enable the Access Point Hostapd program service: enabled=yes name=hostapd.service - when: iiab_wireless_lan_iface != "none" and iiab_network_mode != "Appliance" and hostapd_enabled + when: iiab_wireless_lan_iface is defined and iiab_network_mode != "Appliance" and hostapd_enabled diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index fe30fe6ec..af0808dc4 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -1,6 +1,6 @@ -- name: restart hostapd when wifi is present - service: name=hostapd state=started - when: iiab_wireless_lan_iface != "none" and hostapd_enabled +#- name: restart hostapd when wifi is present +# service: name=hostapd state=started +# when: iiab_wireless_lan_iface is defined and hostapd_enabled - name: Start named service service: name={{ dns_service }} @@ -50,13 +50,13 @@ - name: Checking if wifi slave is active waiting {{ hostapd_wait }} seconds shell: brctl show br0 | grep {{ iiab_wireless_lan_iface }} - when: iiab_wireless_lan_iface != "none" and iiab_lan_iface == "br0" and hostapd_enabled + when: iiab_wireless_lan_iface is defined and iiab_lan_iface == "br0" and hostapd_enabled register: wifi_slave - name: Restart hostapd if wifi slave is inactive service: name=hostapd.service state=restarted - when: iiab_wireless_lan_iface != "none" and iiab_lan_iface == "br0" and hostapd_enabled + when: iiab_wireless_lan_iface is defined and iiab_lan_iface == "br0" and hostapd_enabled - name: dhcp_server may be affected - starting - user choice service: name={{ dhcp_service2 }} diff --git a/roles/network/templates/hostapd/hostapd.conf.j2 b/roles/network/templates/hostapd/hostapd.conf.j2 index e09fc693f..fa1ce62cb 100644 --- a/roles/network/templates/hostapd/hostapd.conf.j2 +++ b/roles/network/templates/hostapd/hostapd.conf.j2 @@ -1,6 +1,6 @@ # Basic configuration -interface={{ iiab_wireless_lan_iface }} +interface={% if iiab_wireless_lan_iface is defined %} {{ iiab_wireless_lan_iface }} {% endif %} ssid={{ host_ssid }} channel={{ host_channel }} {%if iiab_lan_iface == "br0" %} @@ -28,4 +28,4 @@ wpa_key_mgmt=WPA-PSK wpa_passphrase={{ hostapd_password }} # Use AES, instead of TKIP rsn_pairwise=CCMP -{% endif %} \ No newline at end of file +{% endif %}