|
4 | 4 | # Copyright (c) 2023, Takuya Nishimura <@nishipy> |
5 | 5 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
6 | 6 | from __future__ import absolute_import, division, print_function |
| 7 | +from ansible_collections.containers.podman.plugins.module_utils.podman.common import run_podman_command |
| 8 | +from ansible.module_utils.basic import AnsibleModule |
| 9 | +from ansible.module_utils._text import to_text |
| 10 | +from ansible.module_utils.six import string_types |
| 11 | +import shlex |
7 | 12 | __metaclass__ = type |
8 | 13 |
|
9 | 14 | DOCUMENTATION = r''' |
|
67 | 72 |
|
68 | 73 | EXAMPLES = r''' |
69 | 74 | - name: Execute a command with workdir |
70 | | - containers.podman.podman_container_exec: |
| 75 | + containers.podman.podman_container_exec: |
71 | 76 | name: ubi8 |
72 | 77 | command: "cat redhat-release" |
73 | 78 | workdir: /etc |
74 | 79 |
|
75 | 80 | - name: Execute a command with a list of args and enviroment variables |
76 | | - containers.podman.podman_container_exec: |
| 81 | + containers.podman.podman_container_exec: |
77 | 82 | name: test_container |
78 | 83 | argv: |
79 | | - - /bin/sh |
80 | | - - -c |
81 | | - - echo $HELLO $BYE |
| 84 | + - /bin/sh |
| 85 | + - -c |
| 86 | + - echo $HELLO $BYE |
82 | 87 | env: |
83 | | - HELLO: hello world |
84 | | - BYE: goodbye world |
| 88 | + HELLO: hello world |
| 89 | + BYE: goodbye world |
85 | 90 |
|
86 | 91 | - name: Execute command in background by using detach |
87 | | - containers.podman.podman_container_exec: |
| 92 | + containers.podman.podman_container_exec: |
88 | 93 | name: detach_container |
89 | 94 | command: "cat redhat-release" |
90 | 95 | detach: true |
|
115 | 120 | - The ID of the exec session. |
116 | 121 | ''' |
117 | 122 |
|
118 | | -import shlex |
119 | | -from ansible.module_utils.six import string_types |
120 | | -from ansible.module_utils._text import to_text |
121 | | -from ansible.module_utils.basic import AnsibleModule |
122 | | -from ansible_collections.containers.podman.plugins.module_utils.podman.common import run_podman_command |
123 | | - |
124 | 123 |
|
125 | 124 | def run_container_exec(module: AnsibleModule) -> dict: |
126 | 125 | ''' |
|
0 commit comments