
    Vh                         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d Zd Zd Zedk(  r e        yy)    )absolute_importdivisionprint_functiona  
module: atomic_container
short_description: Manage the containers on the atomic host platform
description:
  - Manage the containers on the atomic host platform.
  - Allows to manage the lifecycle of a container on the atomic host platform.
deprecated:
  removed_in: 13.0.0
  why: Project Atomic was sunset by the end of 2019.
  alternative: There is none.
author: "Giuseppe Scrivano (@giuseppe)"
requirements:
  - atomic
notes:
  - According to U(https://projectatomic.io/) the project has been sunset around 2019/2020, in favor of C(podman) and Fedora CoreOS.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: none
  diff_mode:
    support: none
options:
  backend:
    description:
      - Define the backend to use for the container.
    required: true
    choices: ["docker", "ostree"]
    type: str
  name:
    description:
      - Name of the container.
    required: true
    type: str
  image:
    description:
      - The image to use to install the container.
    required: true
    type: str
  rootfs:
    description:
      - Define the rootfs of the image.
    type: str
  state:
    description:
      - State of the container.
    choices: ["absent", "latest", "present", "rollback"]
    default: "latest"
    type: str
  mode:
    description:
      - Define if it is an user or a system container.
    choices: ["user", "system"]
    type: str
  values:
    description:
      - Values for the installation of the container.
      - This option is permitted only with mode 'user' or 'system'.
      - The values specified here will be used at installation time as --set arguments for atomic install.
    type: list
    elements: str
    default: []
a  
- name: Install the etcd system container
  community.general.atomic_container:
    name: etcd
    image: rhel/etcd
    backend: ostree
    state: latest
    mode: system
    values:
      - ETCD_NAME=etcd.server

- name: Uninstall the etcd system container
  community.general.atomic_container:
    name: etcd
    image: rhel/etcd
    backend: ostree
    state: absent
    mode: system
z{
msg:
  description: The command standard output.
  returned: always
  type: str
  sample: 'Using default tag: latest ...'
N)AnsibleModule)	to_nativec                 4   |dk(  rdgng }|dk(  rdgng }|rd|z  gng }	| j                  d      }
|
dd|z  d	|z  g|z   |z   |	z   |z   |gz   }| j                  |d
      \  }}}|dk7  r| j                  ||       y d|v xs d|v }| j                  ||       y )Nsystemz--systemuserz--userz--rootfs=%satomicinstall--storage=%sz	--name=%sFcheck_rcr   rcmsg
ExtractingCopying blobr   changedget_bin_pathrun_command	fail_json	exit_json)modulemoderootfs	containerimagevalues_listbackendsystem_list	user_listrootfs_list
atomic_binargsr   outerrr   s                   v/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/atomic_container.py
do_installr+   o   s    "&("2:,K"fn
"I.4=6)*"K$$X.J	>G#;[9=TUXccfoor}}  AL  L  PU  OV  VD%%dU%;LBS	QwBC(#%>3)>S'2    c                     | j                  d      }|ddd|z  g|z   |gz   }| j                  |d      \  }}}|dk7  r| j                  ||       y d	|v xs d
|v }	| j                  ||	       y )Nr   
containersupdatez--rebase=%sFr   r   r   r   r   r   r   )
r   r   r    r!   r&   r'   r   r(   r)   r   s
             r*   	do_updater0   }   s    $$X.Jh0EFTXaWbbD%%dU%;LBS	QwBC(#%>3)>S'2r,   c                     | j                  d      }|dd|z  |g}| j                  |d      \  }}}|dk7  r| j                  ||       | j                  |d	       y )
Nr   	uninstallr   Fr   r   r   Tr   r   )r   namer"   r&   r'   r   r(   r)   s           r*   do_uninstallr4      sm    $$X.J^g%=tDD%%dU%;LBS	QwBC(
d+r,   c                     | j                  d      }|dd|g}| j                  |d      \  }}}|dk7  r| j                  ||       y d|v }| j                  ||	       y )
Nr   r.   rollbackFr   r   r   zRolling backr   r   )r   r3   r&   r'   r   r(   r)   r   s           r*   do_rollbackr7      sr    $$X.Jj$7D%%dU%;LBS	QwBC( C'S'2r,   c                    | j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                   d   }| j                  d      }t        d	d	d	
      | _        |r|D 	cg c]  }	d|	z  	 c}	ng }
|ddddddd|z  dd|z  g
}| j	                  |d      \  }}}|dk7  r| j                  ||       y ||v }|dk(  r|r| j                  |d       y |dv r|st        | |||||
|       y |dk(  rt        | |||
       y |dk(  r$|s| j                  dd       y t        | ||       y |dk(  rt        | |       y y c c}	w )Nr   r3   r    r   valuesr"   stater   C)LANGLC_ALLLC_MESSAGESz--set=%sr.   listz
--no-truncz-nz--allz-fz
backend=%szcontainer=%sFr   r   r   presentr   )latestr@   rA   absentzThe container is not presentr6   )paramsr   dictrun_command_environ_updater   r   r   r+   r0   r4   r7   )r   r   r3   r    r   r9   r"   r:   r&   xr!   r'   r   r(   r)   r@   s                   r*   corerG      s   == D== DMM'"E]]8$F]]8$FmmI&GMM'"E$$X.J(,#cs(SF%6<62a:>2"KflD'4Q]`gQgimo}  AE  pE  FD%%dU%;LBS	QwBC(ckG	gS%0
(
('64uk7K	(	&${3	(	!?Ow/	*	FD! 
) 3s   E.c                  
   t        t        t        ddg      t        d      t        d      t               t        dg d      t        dd	d
g      t        dg d                  } | j                  d   $| j                  d   dk(  r| j                  d       | j	                  dd      }	 t        |        y # t        $ r;}| j                  dt        |      z  t        j                                Y d }~y d }~ww xY w)Nr
   r	   )choicesT)requiredrA   )r@   rB   rA   r6   )defaultrI   dockerostree)rJ   rI   r?   str)typerK   elements)r   r3   r    r   r:   r"   r9   )argument_specr9   r   rK   z1values is supported only with user or system mode)r   r   z&Unanticipated error running atomic: %s)r   	exception)
r   rD   rC   r   r   rG   	Exceptionr   	traceback
format_exc)r   dummyes      r*   mainrX      s    vx01t$%6x1\]$80DEVR%@

F }}X*v}}V/D	/QPQ 48ExV xE	RST`i`t`t`vwwxs   2B> >	D1C==D__main__)
__future__r   r   r   rO   __metaclass__DOCUMENTATIONEXAMPLESRETURNrT   ansible.module_utils.basicr   +ansible.module_utils.common.text.convertersr   r+   r0   r4   r7   rG   rX   __name__ r,   r*   <module>rc      sh    A @>@(
  4 A33,3!"Hx2 zF r,   