Repository: ansible/ansible

Issue:
interfaces_file doesn't understand source-directory
<!---
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 (interfaces_file_source_directory 60751bce19) last updated 2018/03/22 19:44:17 (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 = ./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 -->

interfaces_file does not handle source-directory keyword. It supports "source-dir" which is not documented but not "source-directory" which is.

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:

```
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

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? -->

Interface file is successfully parsed.

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
TASK [parse interfaces file] ***************************************************
fatal: [knothole]: FAILED! => {
    "changed": false
}

MSG:

misplaced option source-directory /etc/network/interfaces.d
 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
@@ -193,6 +193,9 @@ def read_interfaces_lines(module, line_strings):
         elif words[0] == "source-dir":
             lines.append(lineDict(line))
             currently_processing = "NONE"
+        elif words[0] == "source-directory":
+            lines.append(lineDict(line))
+            currently_processing = "NONE"
         elif words[0] == "iface":
             currif = {
                 "pre-up": [],


Test patch: