
    Vh                     t    d dl mZmZmZ eZdZdZdZd dl	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_functionaH  
module: atomic_image
short_description: Manage the container images on the atomic host platform
description:
  - Manage the container images on the atomic host platform.
  - Allows to execute the commands specified by the RUN label in the container image when present.
deprecated:
  removed_in: 13.0.0
  why: Project Atomic was sunset by the end of 2019.
  alternative: There is none.
author:
  - Saravanan KR (@krsacme)
notes:
  - According to U(https://projectatomic.io/) the project has been sunset around 2019/2020, in favor of C(podman) and Fedora CoreOS.
requirements:
  - atomic
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: none
  diff_mode:
    support: none
options:
  backend:
    description:
      - Define the backend where the image is pulled.
    choices: ['docker', 'ostree']
    type: str
  name:
    description:
      - Name of the container image.
    required: true
    type: str
  state:
    description:
      - The state of the container image.
      - The state V(latest) will ensure container image is upgraded to the latest version and forcefully restart container,
        if running.
    choices: ['absent', 'latest', 'present']
    default: 'latest'
    type: str
  started:
    description:
      - Start or stop the container.
    type: bool
    default: true
a)  
- name: Execute the run command on rsyslog container image (atomic run rhel7/rsyslog)
  community.general.atomic_image:
    name: rhel7/rsyslog
    state: latest

- name: Pull busybox to the OSTree backend
  community.general.atomic_image:
    name: busybox
    state: latest
    backend: ostree
z{
msg:
  description: The command standard output.
  returned: always
  type: str
  sample: 'Using default tag: latest ...'
N)AnsibleModule)	to_nativec                     | j                  d      }|dd|g}| j                  |d      \  }}}|dk7  r| j                  ||       y	d|v ryy	)
Natomicupdatez--forceFcheck_rcr   rcmsgzImage is up to dateT)get_bin_pathrun_command	fail_json)moduleimage
atomic_binargsr   outerrs          r/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/atomic_image.py
do_upgrader   V   sj    $$X.J)U3D%%dU%;LBS	QwBC(  
#	%    c                     | j                   d   }| j                   d   }| j                   d   }| j                   d   }d}t        ddd      | _        | j                  d      }i }i }d	}	|r|d
k(  s|dk(  r|dd|z  |g}
| j	                  |
d      \  }	}}|	d	k  r| j                  |	|       y d}|r8|dd|z  |g}
| j	                  |
d      \  }	}}|	d	k  r| j                  |	|       d|v xs d|v }| j                  ||z   |       y |dk(  rQ|ddd|z  |g}
| j	                  |
d      \  }	}}|	d	k  r| j                  |	|       y d|v}| j                  ||       y |d
k(  s|dk(  r|dk(  rt        | |      }|r|d|g}
n|d|g}
n
|dk(  r|d|g}
| j	                  
d      \  }	}}|	d	k  r| j                  |	|       y |	dk(  rd|v r| j                  ||       y |rd|v r| j                  ||       y | j                  |d        y )!NnamestatestartedbackendFC)LANGLC_ALLLC_MESSAGESr	   r   presentlatestpullz--storage=%sr   r    run
ExtractingzCopying blob)r   changedabsentimagesdeletezUnable to findinstall	uninstall   zalready present)restultr+   zContainer is running)resultr+   T)paramsdictrun_command_environ_updater   r   r   	exit_jsonr   )r   r   r   r   r    is_upgradedr   r   r   r   r   out_runr+   s                r   corer:   b   s   MM&!EMM'"EmmI&GmmI&GK(,#cs(SF%$$X.J
C
C	
BI(!2(@%HD!--dU-CLBSAv  BC 0& 	# &~/GOD'-'9'9$'9'O$BAv((BC(8&#-F31F  cGmg F 	 h(NW4LeTD!--dU-CLBSAv  BC 0 	 +#5  S' :	Uh.H$VU3Ku-D	51D	(	K/%%dU%;LBS	AvBC(	q&#-k:	+s2[9S$/r   c                  ^   t        t        t        dddg      t        dd      t        ddg d	      t        d
d                  } | j                  dd      }	 t        |        y # t        $ r8}| j                  t        |      t        j                                Y d }~y d }~ww xY w)Nstrdockerostree)typechoicesT)r?   requiredr&   )r,   r&   r%   )r?   defaultr@   bool)r?   rB   )r    r   r   r   )argument_specr	   )rA   )r   	exception)	r   r5   r   r:   	Exceptionr   r   	traceback
format_exc)r   dummyes      r   mainrK      s    eh-AB540E8=\]fd3	
F 48EMV MYq\Y5I5I5KLLMs   A+ +	B,4.B''B,__main__)
__future__r   r   r   r?   __metaclass__DOCUMENTATIONEXAMPLESRETURNrG   ansible.module_utils.basicr   +ansible.module_utils.common.text.convertersr   r   r:   rK   __name__ r   r   <module>rV      sY    A @/b
  4 A	;0|M& zF r   