
    Vh                     n    d dl mZmZmZ eZdZd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: pkg5_publisher
author: "Peter Oliver (@mavit)"
short_description: Manages Solaris 11 Image Packaging System publishers
description:
  - IPS packages are the native packages in Solaris 11 and higher.
  - This modules will configure which publishers a client will download IPS packages from.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: none
  diff_mode:
    support: none
options:
  name:
    description:
      - The publisher's name.
    required: true
    aliases: [publisher]
    type: str
  state:
    description:
      - Whether to ensure that a publisher is present or absent.
    default: present
    choices: [present, absent]
    type: str
  sticky:
    description:
      - Packages installed from a sticky repository can only receive updates from that repository.
    type: bool
  enabled:
    description:
      - Is the repository enabled or disabled?
    type: bool
  origin:
    description:
      - A path or URL to the repository.
      - Multiple values may be provided.
    type: list
    elements: str
  mirror:
    description:
      - A path or URL to the repository mirror.
      - Multiple values may be provided.
    type: list
    elements: str
a\  
- name: Fetch packages for the solaris publisher direct from Oracle
  community.general.pkg5_publisher:
    name: solaris
    sticky: true
    origin: https://pkg.oracle.com/solaris/support/

- name: Configure a publisher for locally-produced packages
  community.general.pkg5_publisher:
    name: site
    origin: 'https://pkg.example.com/site/'
)AnsibleModulec                     t        t        t        ddg      t        dddg      t        d      t        d      t        d	d
      t        d	d
                  } dD ]%  }| j                  |   dgk(  sg | j                  |<   ' | j                  d   dk(  rt        | | j                         y t	        | | j                  d          y )NT	publisher)requiredaliasespresentabsent)defaultchoicesbool)typeliststr)r   elements)namestatestickyenabledoriginmirror)argument_spec)r   r    r   r   )r   dictparamsmodify_publisherunset_publisher)moduleoptions     t/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/pkg5_publisher.pymainr#   M   s    tk];y9h2GHV$f% Ve4Ve4	
F ' '== RD($&FMM&!' }}W*/f 56    c                     |d   }t        |       }||v r*dD ]$  }||   	||   ||   |   k7  st        | |      c S  nt        | |      S | j                          y )Nr   )r   r   r   r   )get_publishersset_publisher	exit_json)r    r   r   existingr!   s        r"   r   r   e   ss    &>Df%Hx? 	9Ff~)&>Xd^F%;;(88	9
 VV,,
r$   c                 |   |d   }g }|d   6|j                  d       |j                  |d   D cg c]  }d|z   	 c}       |d   6|j                  d       |j                  |d   D cg c]  }d|z   	 c}       |d   |d   r|j                  d	       n|d   |j                  d
       |d   |d   r|j                  d       n|d   |j                  d       | j                  ddg|z   |gz   d      \  }}}||g|dd}|dk7  r | j                  di |  | j                  di | y c c}w c c}w )Nr   r   z--remove-origin=*z--add-origin=r   z--remove-mirror=*z--add-mirror=r   z--stickyz--non-stickyr   z--enablez	--disablepkgzset-publisherTcheck_rcrcresultsmsgchangedr    )appendextendrun_command	fail_jsonr(   )	r    r   r   argsur/   outerrresponses	            r"   r'   r'   t   sp   &>DDh#'(&2BCQ_q(CDh#'(&2BCQ_q(CDh#x(8J			%N#i$	):J				&K %%	 4'4&0 & LBS
 5	H 
Qw$8$F x 7 D Ds   D4+D9c                     |t        |       vr| j                          | j                  dd|gd      \  }}}||g|dd}|dk7  r | j                  di |  | j                  di | y )Nr+   zunset-publisherTr,   r.   r   r3   )r&   r(   r6   r7   )r    r   r/   r:   r;   r<   s         r"   r   r      s    v..%%	!9- & LBS
 5	H 
Qw$8$F x r$   c                    | j                  g dd      \  }}}|j                         }|j                  d      j                         j	                  d      }i }|D ]  }t        t        |t        t        |j	                  d                        }|d   }	|	|vr'dD 
ci c]  }
|
||
   
 c}
||	<   g ||	   d<   g ||	   d<   |d	   k||	   |d	      j                  |d
           |S c c}
w )N)r+   r   z-FtsvTr   	r   )r   r   r   r   r   uri)
r6   
splitlinespoplowersplitr   zipmapunstringifyr4   )r    r/   r:   r;   lineskeys
publisherslinevaluesr   ks              r"   r&   r&      s   %%&CTJLBSNNE99Q<%%d+DJ 
Cc$KD1A BCDk"z!6KL6!9LJt)+JtX&)+JtX&&>%tVF^,33F5MB
C   Ms   C'c                 4    | dk(  s| dk(  ry | dk(  ry| dk(  ry| S )N-r   trueTfalseFr3   )vals    r"   rG   rG      s+    
czSBY		
r$   __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESansible.module_utils.basicr   r#   r   r'   r   r&   rG   __name__r3   r$   r"   <module>rZ      sZ    A @/` 570!!H!&, zF r$   