Repository: ansible/ansible

Issue:
(P1) nxos_ospf_vrf module sends invalid command
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
 - nxos_ospf_vrf

##### NXOS VERSION
7.0(3)I5(3)

##### ANSIBLE VERSION
```
ansible 2.4.0 (devel b93b9e68d7) last updated 2017/07/26 14:52:17 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/ansible']
  ansible python module location = /root/agents-ci/ansible/lib/ansible
  executable location = /root/agents-ci/ansible/bin/ansible
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
```

##### OS / ENVIRONMENT
Ubuntu 14.04

##### SUMMARY
The `nxos_ospf_vrf` module sends an invalid command using the following playbook.  Problem exists for both `nxapi` and `cli`
```yaml
---
- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_ospf_vrf sanity test"

- name: "Enable feature OSPF"
  nxos_feature:
    feature: ospf
    state: enabled
    provider: "{{ connection }}"
  ignore_errors: yes

- block:
  - name: Configure ospf vrf
    nxos_ospf_vrf: &config
      ospf: 1
      timer_throttle_spf_start: 50
      timer_throttle_spf_hold: 1000
      timer_throttle_spf_max: 2000
      timer_throttle_lsa_start: 60
      timer_throttle_lsa_hold: 1100
      timer_throttle_lsa_max: 3000
      vrf: test
      state: present
      provider: "{{ connection }}"
    register: result

  - assert: &true
      that:
        - "result.changed == true"

  - name: "Check Idempotence"
    nxos_ospf: *config
    register: result

  - assert: &false
      that:
        - "result.changed == false"

  rescue:
  - name: "Disable feature OSPF"
    nxos_feature:
      feature: ospf
      state: disabled
      provider: "{{ connection }}"
    ignore_errors: yes

  always:
  - name: Unconfigure ospf vrf
    nxos_ospf_vrf: &unconfig
      ospf: 1
      state: absent
      provider: "{{ connection }}"
    register: result

  - assert: *true

  - name: "Check Idempotence"
    nxos_ospf: *unconfig
    register: result

  - assert: *false

  - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_ospf_vrf sanity test"
```

```shell
TASK [nxos_ospf_vrf : debug] ************************************************************************************************************************************************************************************************************************************
task path: /root/agents-ci/ansible/test/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml:2
ok: [n9k.example.com] => {
    "msg": "START TRANSPORT:cli nxos_ospf_vrf sanity test"
}

TASK [nxos_ospf_vrf : Enable feature OSPF] **********************************************************************************************************************************************************************************************************************
task path: /root/agents-ci/ansible/test/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml:4
<n9k.example.com> connection transport is cli
<n9k.example.com> using connection plugin network_cli
<n9k.example.com> socket_path: /root/.ansible/pc/4cc10f215f
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/basic.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/nxos.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/_text.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/parsing/__init__.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/pycompat24.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/six/__init__.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/connection.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/network_common.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/urls.py
Using module file /root/agents-ci/ansible/lib/ansible/modules/network/nxos/nxos_feature.py
<n9k.example.com> ESTABLISH LOCAL CONNECTION FOR USER: root
<n9k.example.com> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1501177595.03-269280703013175 `" && echo ansible-tmp-1501177595.03-269280703013175="` echo $HOME/.ansible/tmp/ansible-tmp-1501177595.03-269280703013175 `" ) && sleep 0'
<n9k.example.com> PUT /tmp/tmpIr4cde TO /root/.ansible/tmp/ansible-tmp-1501177595.03-269280703013175/nxos_feature.py
<n9k.example.com> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1501177595.03-269280703013175/ /root/.ansible/tmp/ansible-tmp-1501177595.03-269280703013175/nxos_feature.py && sleep 0'
<n9k.example.com> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1501177595.03-269280703013175/nxos_feature.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1501177595.03-269280703013175/" > /dev/null 2>&1 && sleep 0'
changed: [n9k.example.com] => {
    "changed": true, 
    "commands": [
        "feature ospf"
    ], 
    "failed": false, 
    "invocation": {
        "module_args": {
            "config": null, 
            "feature": "ospf", 
            "host": null, 
            "include_defaults": null, 
            "password": null, 
            "port": null, 
            "provider": null, 
            "save": null, 
            "ssh_keyfile": null, 
            "state": "enabled", 
            "timeout": 10, 
            "transport": "cli", 
            "use_ssl": null, 
            "username": null, 
            "validate_certs": null
        }
    }
}

TASK [nxos_ospf_vrf : Configure ospf vrf] ***********************************************************************************************************************************************************************************************************************
task path: /root/agents-ci/ansible/test/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml:12
<n9k.example.com> connection transport is cli
<n9k.example.com> using connection plugin network_cli
<n9k.example.com> socket_path: /root/.ansible/pc/4cc10f215f
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/basic.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/netcfg.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/nxos.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/_text.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/parsing/__init__.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/pycompat24.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/six/__init__.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/network_common.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/connection.py
Using module_utils file /root/agents-ci/ansible/lib/ansible/module_utils/urls.py
Using module file /root/agents-ci/ansible/lib/ansible/modules/network/nxos/nxos_ospf_vrf.py
<n9k.example.com> ESTABLISH LOCAL CONNECTION FOR USER: root
<n9k.example.com> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1501177597.52-53233907747449 `" && echo ansible-tmp-1501177597.52-53233907747449="` echo $HOME/.ansible/tmp/ansible-tmp-1501177597.52-53233907747449 `" ) && sleep 0'
<n9k.example.com> PUT /tmp/tmpL1tkiO TO /root/.ansible/tmp/ansible-tmp-1501177597.52-53233907747449/nxos_ospf_vrf.py
<n9k.example.com> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1501177597.52-53233907747449/ /root/.ansible/tmp/ansible-tmp-1501177597.52-53233907747449/nxos_ospf_vrf.py && sleep 0'
<n9k.example.com> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1501177597.52-53233907747449/nxos_ospf_vrf.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1501177597.52-53233907747449/" > /dev/null 2>&1 && sleep 0'
fatal: [n9k.example.com]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "auto_cost": null, 
            "config": null, 
            "default_metric": null, 
            "host": null, 
            "include_defaults": "True", 
            "log_adjacency": null, 
            "ospf": "1", 
            "password": null, 
            "port": null, 
            "provider": null, 
            "router_id": null, 
            "save": false, 
            "ssh_keyfile": null, 
            "state": "present", 
            "timeout": 10, 
            "timer_throttle_lsa_hold": "1100", 
            "timer_throttle_lsa_max": "3000", 
            "timer_throttle_lsa_start": "60", 
            "timer_throttle_spf_hold": "1000", 
            "timer_throttle_spf_max": "2000", 
            "timer_throttle_spf_start": "50", 
            "transport": "cli", 
            "use_ssl": null, 
            "username": null, 
            "validate_certs": null, 
            "vrf": "test"
        }
    }, 
    "msg": "ospf 1\r\r\n                             ^\r\n% Invalid command at '^' marker.\r\n\rn9k-109(config-router-vrf)# "
}

```


Discussion:
cc @GGabriele @jedelman8 @privateip @rahushen @rcarrillocruz @trishnaguha
[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/nxos/nxos_ntp.py b/lib/ansible/modules/network/nxos/nxos_ntp.py
--- a/lib/ansible/modules/network/nxos/nxos_ntp.py
+++ b/lib/ansible/modules/network/nxos/nxos_ntp.py
@@ -135,16 +135,16 @@
 
 
 def execute_show_command(command, module, command_type='cli_show'):
-    if module.params['transport'] == 'cli':
-        if 'show run' not in command:
-            command += ' | json'
-        cmds = [command]
-        body = run_commands(module, cmds)
-    elif module.params['transport'] == 'nxapi':
-        cmds = [command]
-        body = run_commands(module, cmds)
+    if 'show run' not in command:
+        output = 'json'
+    else:
+        output = 'text'
 
-    return body
+    commands = [{
+        'command': command,
+        'output': output,
+    }]
+    return run_commands(module, commands)
 
 
 def flatten_list(command_lists):
@@ -170,7 +170,7 @@ def get_ntp_source(module):
             else:
                 source_type = 'source'
             source = output[0].split()[2].lower()
-        except AttributeError:
+        except (AttributeError, IndexError):
             source_type = None
             source = None
 
@@ -327,7 +327,6 @@ def main():
     warnings = list()
     check_args(module, warnings)
 
-
     server = module.params['server'] or None
     peer = module.params['peer'] or None
     key_id = module.params['key_id']
diff --git a/lib/ansible/modules/network/nxos/nxos_ospf_vrf.py b/lib/ansible/modules/network/nxos/nxos_ospf_vrf.py
--- a/lib/ansible/modules/network/nxos/nxos_ospf_vrf.py
+++ b/lib/ansible/modules/network/nxos/nxos_ospf_vrf.py
@@ -146,7 +146,6 @@
 
 PARAM_TO_COMMAND_KEYMAP = {
     'vrf': 'vrf',
-    'ospf': 'ospf',
     'router_id': 'router-id',
     'default_metric': 'default-metric',
     'log_adjacency': 'log-adjacency-changes',


Test patch:
diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml
--- a/test/integration/nxos.yaml
+++ b/test/integration/nxos.yaml
@@ -240,6 +240,14 @@
             failed_modules: "{{ failed_modules }} + [ 'nxos_vxlan_vtep' ]"
             test_failed: true
 
+    - block:
+      - include_role:
+          name: nxos_ntp
+        when: "limit_to in ['*', 'nxos_ntp']"
+      rescue:
+        - set_fact:
+            failed_modules: "{{ failed_modules }} + [ 'nxos_ntp' ]"
+            test_failed: true
     - block:
       - include_role:
           name: nxos_ospf
@@ -249,6 +257,15 @@
             failed_modules: "{{ failed_modules }} + [ 'nxos_ospf' ]"
             test_failed: true
 
+    - block:
+      - include_role:
+          name: nxos_ospf_vrf
+        when: "limit_to in ['*', 'nxos_ospf_vrf']"
+      rescue:
+        - set_fact:
+            failed_modules: "{{ failed_modules }} + [ 'nxos_ospf_vrf' ]"
+            test_failed: true
+
     - block:
       - include_role:
           name: nxos_interface_ospf
diff --git a/test/integration/targets/nxos_ntp/defaults/main.yaml b/test/integration/targets/nxos_ntp/defaults/main.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ntp/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/nxos_ntp/meta/main.yml b/test/integration/targets/nxos_ntp/meta/main.yml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ntp/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+  - prepare_nxos_tests
diff --git a/test/integration/targets/nxos_ntp/tasks/cli.yaml b/test/integration/targets/nxos_ntp/tasks/cli.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ntp/tasks/cli.yaml
@@ -0,0 +1,15 @@
+---
+- name: collect all cli test cases
+  find:
+    paths: "{{ role_path }}/tests/cli"
+    patterns: "{{ testcase }}.yaml"
+  register: test_cases
+
+- name: set test_items
+  set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+  include: "{{ test_case_to_run }}"
+  with_items: "{{ test_items }}"
+  loop_control:
+    loop_var: test_case_to_run
diff --git a/test/integration/targets/nxos_ntp/tasks/main.yaml b/test/integration/targets/nxos_ntp/tasks/main.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ntp/tasks/main.yaml
@@ -0,0 +1,7 @@
+---
+# Use block to ensure that both cli and nxapi tests
+# will run even if there are failures or errors.
+- block:
+  - { include: cli.yaml, tags: ['cli'] }
+  always:
+  - { include: nxapi.yaml, tags: ['nxapi'] }
diff --git a/test/integration/targets/nxos_ntp/tasks/nxapi.yaml b/test/integration/targets/nxos_ntp/tasks/nxapi.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ntp/tasks/nxapi.yaml
@@ -0,0 +1,28 @@
+---
+- name: collect all nxapi test cases
+  find:
+    paths: "{{ role_path }}/tests/nxapi"
+    patterns: "{{ testcase }}.yaml"
+  register: test_cases
+
+- name: set test_items
+  set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: enable nxapi
+  nxos_config:
+    lines:
+      - feature nxapi
+      - nxapi http port 80
+    provider: "{{ cli }}"
+
+- name: run test case
+  include: "{{ test_case_to_run }}"
+  with_items: "{{ test_items }}"
+  loop_control:
+    loop_var: test_case_to_run
+
+- name: disable nxapi
+  nxos_config:
+    lines:
+      - no feature nxapi
+    provider: "{{ cli }}"
diff --git a/test/integration/targets/nxos_ntp/tests/cli/sanity.yaml b/test/integration/targets/nxos_ntp/tests/cli/sanity.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ntp/tests/cli/sanity.yaml
@@ -0,0 +1,4 @@
+---
+- set_fact: connection="{{ cli }}"
+
+- import_tasks: targets/nxos_ntp/tests/common/sanity.yaml
diff --git a/test/integration/targets/nxos_ntp/tests/common/sanity.yaml b/test/integration/targets/nxos_ntp/tests/common/sanity.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ntp/tests/common/sanity.yaml
@@ -0,0 +1,56 @@
+---
+- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_ntp sanity test"
+
+- name: Setup - Remove ntp if configured
+  nxos_ntp: &remove
+    server: 1.2.3.4
+    key_id: 32
+    prefer: disabled
+    vrf_name: management
+    source_addr: 5.5.5.5
+    state: absent
+    provider: "{{ connection }}"
+  ignore_errors: yes
+
+- block:
+
+  - name: Configure ntp
+    nxos_ntp: &config
+      server: 1.2.3.4
+      key_id: 32
+      prefer: enabled
+      vrf_name: management
+      source_addr: 5.5.5.5
+      state: present
+      provider: "{{ connection }}"
+    register: result
+
+  - assert: &true
+      that:
+        - "result.changed == true"
+
+  - name: Idempotence Check
+    nxos_ntp: *config
+    register: result
+
+  - assert: &false
+      that:
+        - "result.changed == false"
+
+  - name: Remove ntp config
+    nxos_ntp: *remove
+    register: result
+
+  - assert: *true
+
+  - name: Remove Idempotence Check
+    nxos_ntp: *remove
+    register: result
+
+  - assert: *false
+
+  always:
+  - name: Remove ntp config
+    nxos_ntp: *remove
+
+  - debug: msg="END TRANSPORT:{{ connection.transport }} nxos_ntp sanity test"
diff --git a/test/integration/targets/nxos_ntp/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_ntp/tests/nxapi/sanity.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ntp/tests/nxapi/sanity.yaml
@@ -0,0 +1,4 @@
+---
+- set_fact: connection="{{ nxapi }}"
+
+- import_tasks: targets/nxos_ntp/tests/common/sanity.yaml
diff --git a/test/integration/targets/nxos_ospf_vrf/defaults/main.yaml b/test/integration/targets/nxos_ospf_vrf/defaults/main.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ospf_vrf/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/nxos_ospf_vrf/meta/main.yml b/test/integration/targets/nxos_ospf_vrf/meta/main.yml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ospf_vrf/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+  - prepare_nxos_tests
diff --git a/test/integration/targets/nxos_ospf_vrf/tasks/cli.yaml b/test/integration/targets/nxos_ospf_vrf/tasks/cli.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ospf_vrf/tasks/cli.yaml
@@ -0,0 +1,15 @@
+---
+- name: collect all cli test cases
+  find:
+    paths: "{{ role_path }}/tests/cli"
+    patterns: "{{ testcase }}.yaml"
+  register: test_cases
+
+- name: set test_items
+  set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case
+  include: "{{ test_case_to_run }}"
+  with_items: "{{ test_items }}"
+  loop_control:
+    loop_var: test_case_to_run
diff --git a/test/integration/targets/nxos_ospf_vrf/tasks/main.yaml b/test/integration/targets/nxos_ospf_vrf/tasks/main.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ospf_vrf/tasks/main.yaml
@@ -0,0 +1,7 @@
+---
+# Use block to ensure that both cli and nxapi tests
+# will run even if there are failures or errors.
+- block:
+  - { include: cli.yaml, tags: ['cli'] }
+  always:
+  - { include: nxapi.yaml, tags: ['nxapi'] }
diff --git a/test/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml b/test/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ospf_vrf/tasks/nxapi.yaml
@@ -0,0 +1,28 @@
+---
+- name: collect all nxapi test cases
+  find:
+    paths: "{{ role_path }}/tests/nxapi"
+    patterns: "{{ testcase }}.yaml"
+  register: test_cases
+
+- name: set test_items
+  set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: enable nxapi
+  nxos_config:
+    lines:
+      - feature nxapi
+      - nxapi http port 80
+    provider: "{{ cli }}"
+
+- name: run test case
+  include: "{{ test_case_to_run }}"
+  with_items: "{{ test_items }}"
+  loop_control:
+    loop_var: test_case_to_run
+
+- name: disable nxapi
+  nxos_config:
+    lines:
+      - no feature nxapi
+    provider: "{{ cli }}"
diff --git a/test/integration/targets/nxos_ospf_vrf/tests/cli/sanity.yaml b/test/integration/targets/nxos_ospf_vrf/tests/cli/sanity.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ospf_vrf/tests/cli/sanity.yaml
@@ -0,0 +1,4 @@
+---
+- set_fact: connection="{{ cli }}"
+
+- import_tasks: targets/nxos_ospf_vrf/tests/common/sanity.yaml
diff --git a/test/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml b/test/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ospf_vrf/tests/common/sanity.yaml
@@ -0,0 +1,64 @@
+---
+- debug: msg="START TRANSPORT:{{ connection.transport }} nxos_ospf_vrf sanity test"
+
+- name: "Enable feature OSPF"
+  nxos_feature:
+    feature: ospf
+    state: enabled
+    provider: "{{ connection }}"
+  ignore_errors: yes
+
+- block:
+  - name: Configure ospf vrf
+    nxos_ospf_vrf: &config
+      ospf: 1
+      router_id: 1.1.1.1
+      timer_throttle_spf_start: 50
+      timer_throttle_spf_hold: 1000
+      timer_throttle_spf_max: 2000
+      timer_throttle_lsa_start: 60
+      timer_throttle_lsa_hold: 1100
+      timer_throttle_lsa_max: 3000
+      vrf: test
+      state: present
+      provider: "{{ connection }}"
+    register: result
+
+  - assert: &true
+      that:
+        - "result.changed == true"
+
+  - name: "Check Idempotence"
+    nxos_ospf_vrf: *config
+    register: result
+
+  - assert: &false
+      that:
+        - "result.changed == false"
+
+  rescue:
+  - name: "Disable feature OSPF"
+    nxos_feature:
+      feature: ospf
+      state: disabled
+      provider: "{{ connection }}"
+    ignore_errors: yes
+
+  always:
+  - name: Unconfigure ospf vrf
+    nxos_ospf_vrf: &unconfig
+      ospf: 1
+      vrf: test
+      state: absent
+      provider: "{{ connection }}"
+    register: result
+
+  - assert: *true
+
+  - name: "Check Idempotence"
+    nxos_ospf_vrf: *unconfig
+    register: result
+
+  - assert: *false
+
+- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_ospf_vrf sanity test"
diff --git a/test/integration/targets/nxos_ospf_vrf/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_ospf_vrf/tests/nxapi/sanity.yaml
new file mode 100644
--- /dev/null
+++ b/test/integration/targets/nxos_ospf_vrf/tests/nxapi/sanity.yaml
@@ -0,0 +1,4 @@
+---
+- set_fact: connection="{{ nxapi }}"
+
+- import_tasks: targets/nxos_ospf_vrf/tests/common/sanity.yaml
diff --git a/test/units/modules/network/nxos/test_nxos_ospf_vrf.py b/test/units/modules/network/nxos/test_nxos_ospf_vrf.py
--- a/test/units/modules/network/nxos/test_nxos_ospf_vrf.py
+++ b/test/units/modules/network/nxos/test_nxos_ospf_vrf.py
@@ -59,7 +59,6 @@ def test_nxos_ospf_vrf_present(self):
                          sorted(['router ospf 1',
                                  'vrf test',
                                  'timers throttle lsa 60 1100 3000',
-                                 'ospf 1',
                                  'timers throttle spf 50 1000 2000',
                                  'vrf test']))