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

Docker shell module failed in the latest sonic-mgmt #1243

Closed
msosyak opened this issue Nov 28, 2019 · 7 comments · Fixed by #1253
Closed

Docker shell module failed in the latest sonic-mgmt #1243

msosyak opened this issue Nov 28, 2019 · 7 comments · Fixed by #1253

Comments

@msosyak
Copy link
Contributor

msosyak commented Nov 28, 2019

Description
The task with sell type docker always fails on the latest sonic-mgmt, example:

- name: Gather information from lldp
  lldp:
  vars:
    ansible_shell_type: docker
    ansible_python_interpreter: docker exec -i lldp python

Steps to reproduce the issue:

  1. run dip_sip or lag_2 CT

Describe the results you received:

TASK [test : Gathering peer VM information from lldp] **************************
task path: /var/user/jenkins/bfn-sonic-mgmt/ansible/roles/test/tasks/lag_2.yml:26
Thursday 28 November 2019  10:28:47 +0000 (0:00:00.263)       0:00:26.753 ***** 
The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 145, in run
    res = self._execute()
  File "/usr/local/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 612, in _execute
    self._set_connection_options(variables, templar)
  File "/usr/local/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 1012, in _set_connection_options
    self._set_plugin_options('shell', final_vars, templar, task_keys)
  File "/usr/local/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 978, in _set_plugin_options
    plugin.set_options(task_keys=task_keys, var_options=options)
  File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/shell/__init__.py", line 70, in set_options
    env = self.get_option('environment')
  File "/usr/local/lib/python2.7/dist-packages/ansible/plugins/__init__.py", line 60, in get_option
    raise KeyError(to_native(e))
KeyError: 'Requested entry (plugin_type: shell plugin: docker setting: environment ) was not defined in configuration.'

fatal: [cab18-2-dut]: FAILED! => {
    "msg": "Unexpected failure during module execution.", 
    "stdout": ""
}

Describe the results you expected:

Additional information you deem important:

**Output of `show version`:**

```

SONiC Software Version: SONiC.HEAD.488-dirty-20191127.082217
Distribution: Debian 9.11
Kernel: 4.9.0-9-2-amd64
Build commit: 7622a30d
Build date: Wed Nov 27 11:15:51 UTC 2019
Built by: johnar@jenkins-worker-11

```

**Attach debug file `sudo generate_dump`:**

```
(paste your output here)
```
@msosyak
Copy link
Contributor Author

msosyak commented Nov 28, 2019

I have tried to update the python docker module to the latest as we still have docker-py=1.6.0 when ansible requires docker>= 1.7.0 but this did not help me.
https://docs.ansible.com/ansible/latest/scenario_guides/guide_docker.html#requirements

@msosyak
Copy link
Contributor Author

msosyak commented Nov 28, 2019

As lldp module is run on sonic host with custom python interpreter ansible_python_interpreter: docker exec -i lldp python I've tried to commend ansible_shell_type: docker and this helps me.

@msosyak
Copy link
Contributor Author

msosyak commented Nov 28, 2019

@nazariig I see you are the author of this line ansible_shell_type: docker
Could you comment?

@nazariig
Copy link
Contributor

nazariig commented Nov 28, 2019

@nazariig I see you are the author of this line ansible_shell_type: docker
Could you comment?

@msosyak This module allows you to execute commands directly in docker on the remote host (inventory)
plugin: https://github.com/Azure/sonic-mgmt/blob/master/ansible/shell_plugins/docker.py
FYI: https://docs.ansible.com/ansible/latest/plugins/shell.html

@nazariig
Copy link
Contributor

nazariig commented Nov 28, 2019

@msosyak please check this: #1213 and #1225

@msosyak msosyak changed the title lldp module failed in the latest sonic-mgmt Docker shell module failed in the latest sonic-mgmt Nov 29, 2019
@lguohan
Copy link
Contributor

lguohan commented Dec 2, 2019

@qiluo-msft is the original author of docker shell plugin, i think i might break the plugin when upgrading 2.8.7. I do not know if it is still necessary. if you are able to run the lldp module successfully, then we no longer need ansible_shell_type: docker

@lguohan
Copy link
Contributor

lguohan commented Dec 2, 2019

I did some test. for lldp module, you can remove both lines.

    ansible_shell_type: docker
    ansible_python_interpreter: docker exec -i lldp python

I think we have lldpctl in sonic base image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants