Repository: ansible/ansible

Issue:
interfaces_file fails to parse allow-* including allow-hotplug
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and devel branch are affected too.
Always add information AFTER of these html comments.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest -->
 - Bug Report


##### COMPONENT NAME
<!---
Insert below this comment the name of the module, plugin, task or feature.
Do not include extra details here, e.g. "vyos_command" not "the network module vyos_command" or the full path
-->
interfaces_file

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.6.0 (devel c3ab6cb9b1) last updated 2018/03/23 10:34:51 (GMT -600)
  config file = /home/schallee/devel/ansible/src/ansible.cfg
  configured module search path = [u'/home/schallee/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/schallee/devel/ansible/src/lib/ansible
  executable location = /home/schallee/devel/ansible/src/bin/ansible
  python version = 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516]

```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"
Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
ANSIBLE_SSH_CONTROL_PATH_DIR(/home/schallee/devel/ansible/src/ansible.cfg) = ~/.ssh/controls
CACHE_PLUGIN(/home/schallee/devel/ansible/src/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/schallee/devel/ansible/src/ansible.cfg) = cache
CACHE_PLUGIN_TIMEOUT(/home/schallee/devel/ansible/src/ansible.cfg) = 3600
COMMAND_WARNINGS(/home/schallee/devel/ansible/src/ansible.cfg) = True
DEFAULT_FORKS(/home/schallee/devel/ansible/src/ansible.cfg) = 10
DEFAULT_GATHERING(/home/schallee/devel/ansible/src/ansible.cfg) = smart
DEFAULT_STDOUT_CALLBACK(/home/schallee/devel/ansible/src/ansible.cfg) = debug
DEPRECATION_WARNINGS(/home/schallee/devel/ansible/src/ansible.cfg) = True
##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
Debian Stretch amd64
##### SUMMARY
<!--- Explain the problem briefly -->

interfacdes_file fails to parse allow- lines. It should handle lines with a first word 'allow-\w+' however the current implementation only allows lines that with 'allow-' which are invalid. The most common example is 'allow-hotplug' which causes interfaces_file to fail.

https://manpages.debian.org/stretch/ifupdown/interfaces.5.en.html

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
- hosts: all
  tasks:
    - name: parse interfaces file
      interfaces_file:
      register: interfaces_output
```
Eample interfaces file triggering the issue:

```
allow-hotplug eth0
iface eth0 inet dhcp

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

interfaces_file successfully parses the file.


##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->

```
fatal: [knothole]: FAILED! => {
    "changed": false
}

MSG:

misplaced option allow-hotplug eth0
 in line 3
```



Discussion:

Resolving patch:
diff --git a/lib/ansible/modules/system/interfaces_file.py b/lib/ansible/modules/system/interfaces_file.py
--- a/lib/ansible/modules/system/interfaces_file.py
+++ b/lib/ansible/modules/system/interfaces_file.py
@@ -216,7 +216,7 @@ def read_interfaces_lines(module, line_strings):
         elif words[0] == "auto":
             lines.append(lineDict(line))
             currently_processing = "NONE"
-        elif words[0] == "allow-":
+        elif words[0].startswith("allow-"):
             lines.append(lineDict(line))
             currently_processing = "NONE"
         elif words[0] == "no-auto-down":


Test patch: