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

[ansible] Fix docker shell plugin #1253

Merged
merged 4 commits into from
Dec 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions ansible/shell_plugins/docker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
from __future__ import (absolute_import, division)
__metaclass__ = type

DOCUMENTATION = '''
name: sh
msosyak marked this conversation as resolved.
Show resolved Hide resolved
plugin_type: shell
short_description: "docker shell plugin"
version_added: historical
description:
- This module allows you to execute commands directly in docker on the remote host
extends_documentation_fragment:
- shell_common
'''

import os
import re
import pipes
Expand Down Expand Up @@ -29,7 +40,7 @@ def join_path(self, *args):

return super(ShellModule, self).join_path(*args)

def build_module_command(self, env_string, shebang, cmd, arg_path=None, rm_tmp=None):
def build_module_command(self, env_string, shebang, cmd, arg_path=None):
# assert(self.container_name)
argv = shlex.split(shebang.replace("#!", ""))
assert(argv[0] == 'docker')
Expand All @@ -51,13 +62,7 @@ def build_module_command(self, env_string, shebang, cmd, arg_path=None, rm_tmp=N
pre = ''.join('docker exec {1} mkdir -p {0}; docker cp {0}/. {1}:{0}; '
msosyak marked this conversation as resolved.
Show resolved Hide resolved
.format(dtemp, self.container_name) for dtemp in self.dtemps)

if rm_tmp:
post = ''.join('docker exec {1} rm -rf {0}; '
.format(dtemp, self.container_name) for dtemp in self.dtemps)
else:
post = ''

return pre + super(ShellModule, self).build_module_command('', shebang_env, cmd, arg_path, rm_tmp) + '; ' + post
return pre + super(ShellModule, self).build_module_command('', shebang_env, cmd, arg_path)

def checksum(self, path, python_interp):
"""
Expand Down