
    Vh1                     t    d dl mZmZmZ eZdZdZd dlm	Z	 ddl
mZ ddl
mZ d Zd	 Zd
 Zedk(  r e        yy)    )absolute_importdivisionprint_functiona$  
---
module: podman_containers
author:
  - "Sagi Shnaidman (@sshnaidm)"
version_added: '1.4.0'
short_description: Manage podman containers in a batch
description:
  - Manage groups of podman containers
requirements:
  - "podman"
options:
  containers:
    description:
    - List of dictionaries with data for running containers for podman_container module.
    required: True
    type: list
    elements: dict
  debug:
    description:
    - Return additional information which can be helpful for investigations.
    type: bool
    default: False
a  
- name: Run three containers at once
  podman_containers:
    containers:
      - name: alpine
        image: alpine
        command: sleep 1d
      - name: web
        image: nginx
      - name: test
        image: python:3.10-alpine
        command: python -V
)AnsibleModule   )PodmanManager)set_container_optsc           
         t        d | D              }t        d | D              }g }g }g }d}i }d}d}	| D ]u  }
d|
v r|
d   r||
d   z  }d|
v r|
d   r||
d   z  }d|
v r|
d   r|j                  |
d          d|
v r|
d   }d|
v r|
d   ||
d   d	   <   d
|
v r||
d
   z  }d|
v sn|	|
d   z  }	w ||||||	|d}|r||d<   |r~dx}}|j                         D ]_  \  }}|dj                  t	        |      dt	        |d         dg      z  }|dj                  t	        |      dt	        |d         dg      z  }a ||d|d<   |S )Nc              3   @   K   | ]  }|j                  d d        yw)changedFNget.0is     w/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/containers/podman/plugins/modules/podman_containers.py	<genexpr>zcombine.<locals>.<genexpr>6   s     ;a!%%	5);   c              3   @   K   | ]  }|j                  d d        yw)failedFNr   r   s     r   r   zcombine.<locals>.<genexpr>7   s     9Ax'9r    actionspodman_actions	containerpodman_versiondiffNamestderrstdout)r   r   r   r   
containersr   r   z: before
after)r!   r#   )anyappenditemsjoinstr)resultsr   r   r   r   r    r   diffsr   r   r   totalr!   r#   kvs                   r   combiner.   5   s   ;7;;G999FGNJNEFF ">a	lq|#Gq Q'7%8a 011N!+an-q /0NQ;,-fIE!K.()q=ak!Fq=ak!F"" ( E "0KKM 	DDAqbggs1vtS8-=tDEEFRWWc!fdC'
OTBCCE	D 
f L    c                 .    | d   dv r| d   sd| d   z  S y y )Nstate)startedpresentimagez+State '%s' required image to be configured! )r   s    r   check_input_strictr6   f   s0    33Ig<N<y?QQQ =O3r/   c            	         t        t        t        ddd      t        dd            d	      } g }| j                  d
   D ]y  }t        |      }| j                  d   xs |d   |d<   t	        |      }|r| j                  d|d   d|       t        | |      j                         }|j                  |       { t        |      } | j                  di | y )NlistdictT)typeelementsrequiredboolF)r:   default)r    debug)argument_specsupports_check_moder    r?   zFailed to run container namez
 because: )msgr5   )r   r9   paramsr	   r6   	fail_jsonr   executer%   r.   	exit_json)moduler)   r   options_dict
test_inputrestotal_resultss          r   mainrM   k   s    &4HFE2
 !F G]]<0 	))4 &g 6 O,w:OW'5
@LV@TV`a  cFL199;s G$MF%}%r/   __main__N)
__future__r   r   r   r:   __metaclass__DOCUMENTATIONEXAMPLESansible.module_utils.basicr   (module_utils.podman.podman_container_libr   r	   r.   r6   rM   __name__r5   r/   r   <module>rV      sQ   
 A @2 5 D I.bR
&0 zF r/   