Skip to content

Commit

Permalink
k8s_exec: add argument to support pod with multiple containers
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanCacqueray committed Nov 12, 2019
1 parent d7e1881 commit b4ce4e5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ansible/modules/clustering/k8s/k8s_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
- The pod name
type: str
required: yes
container:
description:
- The name of the container in the pod to connect to. Defaults to only container if there is only one container in the pod.
type: str
required: no
command:
description:
- The command to execute
Expand Down Expand Up @@ -109,6 +114,7 @@ def argspec(self):
spec = copy.deepcopy(AUTH_ARG_SPEC)
spec['namespace'] = {'type': 'str'}
spec['pod'] = {'type': 'str'}
spec['container'] = {'type': 'str'}
spec['command'] = {'type': 'str'}
return spec

Expand All @@ -122,6 +128,7 @@ def main():
api.connect_get_namespaced_pod_exec,
module.params["pod"],
module.params["namespace"],
container=module.params.get("container"),
command=shlex.split(module.params["command"]),
stdout=True,
stderr=True,
Expand Down

0 comments on commit b4ce4e5

Please sign in to comment.