
    Vh                     j    d dl mZmZmZ eZdZdZdZd dl	m
Z
  G d de      Zd Zed	k(  r e        y
y
)    )absolute_importdivisionprint_functionag  
module: opendj_backendprop
short_description: Will update the backend configuration of OpenDJ using the dsconfig set-backend-prop command
description:
  - This module will update settings for OpenDJ with the command set-backend-prop.
  - It will check first using de get-backend-prop if configuration needs to be applied.
author:
  - Werner Dijkerman (@dj-wasabi)
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  opendj_bindir:
    description:
      - The path to the bin directory of OpenDJ.
    required: false
    default: /opt/opendj/bin
    type: path
  hostname:
    description:
      - The hostname of the OpenDJ server.
    required: true
    type: str
  port:
    description:
      - The Admin port on which the OpenDJ instance is available.
    required: true
    type: str
  username:
    description:
      - The username to connect to.
    required: false
    default: cn=Directory Manager
    type: str
  password:
    description:
      - The password for the C(cn=Directory Manager) user.
      - Either password or passwordfile is needed.
    required: false
    type: str
  passwordfile:
    description:
      - Location to the password file which holds the password for the C(cn=Directory Manager) user.
      - Either password or passwordfile is needed.
    required: false
    type: path
  backend:
    description:
      - The name of the backend on which the property needs to be updated.
    required: true
    type: str
  name:
    description:
      - The configuration setting to update.
    required: true
    type: str
  value:
    description:
      - The value for the configuration item.
    required: true
    type: str
  state:
    description:
      - If configuration needs to be added/updated.
    required: false
    default: "present"
    type: str
z
- name: Add or update OpenDJ backend properties
  opendj_backendprop:
    hostname: localhost
    port: 4444
    username: "cn=Directory Manager"
    password: password
    backend: userRoot
    name: index-entry-limit
    value: 5000

)AnsibleModulec                   &    e Zd Zd Zd Zd ZddZy)BackendPropc                     || _         y )N)_module)selfmodules     x/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/opendj_backendprop.py__init__zBackendProp.__init__h   s	        c                     |dz   dd|dt        |      d|d|ddd	g|z   }| j                  j                  |      \  }}	}
|d
k(  r|	S | j                  j                  dt        |
      z          y )N	/dsconfigzget-backend-prop-h--port--bindDN--backend-name-n-Xz-sr   Error message: msgstrr   run_command	fail_json)r   opendj_bindirhostnameportusernamepassword_methodbackend_name
my_commandrcstdoutstderrs              r   get_propertyzBackendProp.get_propertyk   s    K'(c$il$
 
 "\\55jAFF7MLL""'83v;'F"Gr   c	                     |dz   dd|dt        |      d|d|d|dz   |z   d	d
g|z   }	| j                  j                  |	      \  }
}}|
dk(  ry| j                  j                  d|z          y )Nr   zset-backend-propr   r   r   r   z--set:r   r   r   Tr   r   r   )r   r    r!   r"   r#   r$   r%   namevaluer&   r'   r(   r)   s                r   set_propertyzBackendProp.set_property{   s    K'(c$ilTCZ%'$	
 	
 "\\55jAFF7LL""'86'A"Br   Nc                 |    |j                  d      D ](  }|s|j                         }|d   |k(  s|d   |k(  s( y y)Nr   r      TF)split)r   datar-   r.   config_line
split_lines         r   validate_datazBackendProp.validate_data   sK    ::d+ 	$K(..0
a=D(!!}-#	$ r   )NNN)__name__
__module____qualname__r   r*   r/   r6    r   r   r	   r	   f   s    H C"r   r	   c                     t        t        t        dd      t        d      t        d      t        dd      t        dd	      t        dd
      t        d      t        d      t        d      t        d      
      dddggddgg      } | j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }	| j                  d   }
| j                  d   d|g}n| j                  d   d|g}t        |       }|j	                  |||||      }|r|j                  |||	      s]| j                  r| j                  d       |j                  ||||||||	      r| j                  d       y | j                  d       y | j                  d       y | j                  d       y )Nz/opt/opendj/binpath)defaulttypeT)requiredzcn=Directory ManagerF)r=   r?   )r?   no_log)r?   r>   present)r=   )
r    r!   r"   r#   passwordpasswordfilebackendr-   r.   staterB   rC   )argument_specsupports_check_modemutually_exclusiverequired_one_ofr    r!   r"   r#   rD   r-   r.   rE   z-wz-j)r    r!   r"   r#   r$   r%   )r3   r-   r.   )changed)r    r!   r"   r#   r$   r%   r-   r.   )	r   dictparamsr	   r*   r6   
check_mode	exit_jsonr/   )r   r    r!   r"   r#   rB   rC   r%   r-   r.   rE   r$   opendjvalidates                 r   mainrQ      s   '8vF4(t$"85I56u6:$'t$%y)
 !'89$n56F$ MM/2M}}Z(H== D}}Z(H}}Z(H==0L==+L== DMM'"EMM'"E}}Z ,*	~	&	2. F"",4(,,43B0< # >H ##E#J     ."",4(,,43B0<(,). # 0    .   /U+'r   __main__N)
__future__r   r   r   r>   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   objectr	   rQ   r7   r:   r   r   <module>rZ      sV    A @GR

 5-& -`=(@ zF r   