Repository: ansible/ansible

Issue:
In junos_config  if diff is empty changed is set to True
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
junos_config

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
2.4
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### 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.
-->

##### SUMMARY
<!--- Explain the problem briefly -->

##### 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.
-->
Run below playbook twice. For second run `changed` should be `False`
<!--- Paste example playbooks or commands between quotes below -->
```yaml
- name: configure multiple commands
  junos_config:
    lines:
      - 'set system host-name {{ inventory_hostname_short }}'
      - 'set interfaces lo0 unit 0 family inet address 1.1.1.1/32'
    provider: "{{ netconf }}"
  register: result
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
For second run changed is set to`true`
<!--- Paste verbatim command output between quotes below -->
```
changed: [vsrx01] => {
    "changed": true,
    "diff": {
        "prepared": ""
    },
    "invocation": {
        "module_args": {
            "backup": false,
            "comment": "configured by junos_config",
            "confirm": 0,
            "host": null,
            "lines": [
                "set system host-name vsrx01",
                "set interfaces lo0 unit 0 family inet address 1.1.1.1/32"
            ],
            "password": null,
            "port": null,
            "provider": {
                "host": "vsrx01",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": null,
                "ssh_keyfile": null,
                "timeout": null,
                "transport": "netconf",
                "username": "ansible"
            },
            "replace": null,
            "rollback": null,
            "src": null,
            "src_format": null,
            "ssh_keyfile": null,
            "timeout": 10,
            "transport": null,
            "update": "merge",
            "username": null,
            "zeroize": false
        }
    }
}
```

In junos_config  if diff is empty changed is set to True
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
junos_config

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
2.4
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->

##### 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.
-->

##### SUMMARY
<!--- Explain the problem briefly -->

##### 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.
-->
Run below playbook twice. For second run `changed` should be `False`
<!--- Paste example playbooks or commands between quotes below -->
```yaml
- name: configure multiple commands
  junos_config:
    lines:
      - 'set system host-name {{ inventory_hostname_short }}'
      - 'set interfaces lo0 unit 0 family inet address 1.1.1.1/32'
    provider: "{{ netconf }}"
  register: result
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
For second run changed is set to`true`
<!--- Paste verbatim command output between quotes below -->
```
changed: [vsrx01] => {
    "changed": true,
    "diff": {
        "prepared": ""
    },
    "invocation": {
        "module_args": {
            "backup": false,
            "comment": "configured by junos_config",
            "confirm": 0,
            "host": null,
            "lines": [
                "set system host-name vsrx01",
                "set interfaces lo0 unit 0 family inet address 1.1.1.1/32"
            ],
            "password": null,
            "port": null,
            "provider": {
                "host": "vsrx01",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": null,
                "ssh_keyfile": null,
                "timeout": null,
                "transport": "netconf",
                "username": "ansible"
            },
            "replace": null,
            "rollback": null,
            "src": null,
            "src_format": null,
            "ssh_keyfile": null,
            "timeout": 10,
            "transport": null,
            "update": "merge",
            "username": null,
            "zeroize": false
        }
    }
}
```



Discussion:
cc @Qalthos
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
cc @Qalthos
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/network/junos/junos_config.py b/lib/ansible/modules/network/junos/junos_config.py
--- a/lib/ansible/modules/network/junos/junos_config.py
+++ b/lib/ansible/modules/network/junos/junos_config.py
@@ -348,7 +348,7 @@ def main():
 
     else:
         diff = configure_device(module, warnings)
-        if diff is not None:
+        if diff:
             if module._diff:
                 result['diff'] = {'prepared': diff}
             result['changed'] = True


Test patch: