Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove provider (and transport, where applicable) from consideration when not using connection=local #39555

Merged
merged 4 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ansible/plugins/action/bigip.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(f5_provider_spec, self._task.args)

Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/action/dellos10.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(dellos10_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/action/dellos6.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(dellos6_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/action/dellos9.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(dellos9_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)
Expand Down
4 changes: 4 additions & 0 deletions lib/ansible/plugins/action/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
if self._task.args.get('transport'):
display.warning('transport is unnecessary when using network_cli and will be ignored')
del self._task.args['transport']
elif self._play_context.connection == 'local':
provider = load_provider(eos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli'
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/action/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(ios_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/action/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using {0} and will be ignored'.format(self._play_context.connection))
del self._task.args['provider']
else:
return {'failed': True, 'msg': 'Connection type %s is not valid for this module' % self._play_context.connection}

Expand Down
3 changes: 2 additions & 1 deletion lib/ansible/plugins/action/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def run(self, tmp=None, task_vars=None):
elif self._play_context.connection in ('netconf', 'network_cli'):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using connection=%s and will be ignored' % self._play_context.connection)
display.warning('provider is unnecessary when using %s and will be ignored' % self._play_context.connection)
del self._task.args['provider']

if (self._play_context.connection == 'network_cli' and self._task.action not in CLI_SUPPORTED_MODULES) or \
(self._play_context.connection == 'netconf' and self._task.action == 'junos_netconf'):
Expand Down
3 changes: 2 additions & 1 deletion lib/ansible/plugins/action/net_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def run(self, tmp=None, task_vars=None):
else:
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using connection=%s and will be ignored' % play_context.connection)
display.warning('provider is unnecessary when using %s and will be ignored' % play_context.connection)
del self._task.args['provider']

if play_context.connection == 'network_cli':
# make sure we are in the right cli context which should be
Expand Down
4 changes: 4 additions & 0 deletions lib/ansible/plugins/action/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
if self._task.args.get('transport'):
display.warning('transport is unnecessary when using network_cli and will be ignored')
del self._task.args['transport']
elif self._play_context.connection == 'local':
provider = load_provider(nxos_provider_spec, self._task.args)
transport = provider['transport'] or 'cli'
Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/action/sros.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(sros_provider_spec, self._task.args)

Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/action/vyos.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def run(self, tmp=None, task_vars=None):
provider = self._task.args.get('provider', {})
if any(provider.values()):
display.warning('provider is unnecessary when using network_cli and will be ignored')
del self._task.args['provider']
elif self._play_context.connection == 'local':
provider = load_provider(vyos_provider_spec, self._task.args)
pc = copy.deepcopy(self._play_context)
Expand Down
11 changes: 11 additions & 0 deletions test/integration/targets/eos_smoke/tests/cli/misc_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@
provider: "{{ cli }}"
become: no

# Test that transport values are properly ignored
- name: wrong transport specified
eos_command:
commands: show version
transport: eapi

- name: wrong transport specified in provider
eos_command:
commands: show version
provider: "{{ eapi }}"

when: "ansible_connection != 'local'"
17 changes: 17 additions & 0 deletions test/integration/targets/nxos_smoke/tests/cli/misc_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- debug: msg="START cli/misc_tests.yaml on connection={{ ansible_connection }}"


- block:
# Test that transport values are properly ignored
- name: wrong transport specified
eos_command:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be nxos_command

commands: show version
transport: nxapi

- name: wrong transport specified in provider
eos_command:
commands: show version
provider: "{{ nxapi }}"

when: "ansible_connection != 'local'"