
    VhN                         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mZ d dlmZ d dlmZmZmZmZmZmZmZ d	 Zed
k(  r e        yy)    )absolute_importdivisionprint_functiona  
---
module: mongodb_parameter
short_description: Change an administrative parameter on a MongoDB server
description:
    - Change an administrative parameter on a MongoDB server.
version_added: "1.0.0"

extends_documentation_fragment:
  - community.mongodb.login_options
  - community.mongodb.ssl_options

options:
    replica_set:
        description:
            - Replica set to connect to (automatically connects to primary for writes).
        type: str
    param:
        description:
            - MongoDB administrative parameter to modify.
        type: str
        required: true
    value:
        description:
            - MongoDB administrative parameter value to set.
        type: str
        required: true
    param_type:
        description:
            - Define the type of parameter value.
        default: str
        type: str
        choices: [int, str]

notes:
    - Requires the pymongo Python package on the remote host, version 4+.
    - This can be installed using pip or the OS package manager.
    - See also U(https://www.mongodb.com/docs/languages/python/pymongo-driver/current/get-started/download-and-install/)
requirements: [ "pymongo" ]
author: "Loic Blot (@nerzhul)"
z
- name: Set MongoDB syncdelay to 60 (this is an int)
  community.mongodb.mongodb_parameter:
    param: syncdelay
    value: 60
    param_type: int
z
before:
    description: value before modification
    returned: success
    type: str
after:
    description: value after modification
    returned: success
    type: str
N)AnsibleModulemissing_required_lib)	to_native)r   mongodb_common_argument_spec
mongo_authPYMONGO_IMP_ERRpymongo_foundOperationFailureget_mongodb_clientc            
         t               } | j                  t        d       t        d      t        d      t        dddg             t        | dd	d
gg      }t        s |j                  t        d      t               |j                  d   }|j                  d   }|j                  d   }	 |dk(  rt        |      }	 t        |d      }t        ||d      }j                  }	  |j                   di ||i}dvr|j)                  dd       y |j)                  ||d   k7  |d   |       y # t        $ r |j                  d|d|       Y w xY w# t        $ r(}|j                  dt        |      z         Y d }~d }~ww xY w# t"        $ r;}	|j                  dt        |	      z  t%        j&                                Y d }	~	d }	~	ww xY w)N)defaultT)requiredstrint)r   choices)replica_setparamvalue
param_typeF
login_userlogin_password)argument_specsupports_check_moderequired_togetherpymongo)msg	exceptionr   r   r   zvalue 'z	' is not )r   )directConnectionz Unable to connect to MongoDB: %szunable to change parameter: %swasz1Unable to determine old value, assume it changed.)changedr   )r#   beforeafter)setParameter)r	   updatedictr   r   	fail_jsonr   r   paramsr   
ValueErrorr   r
   	Exceptionr   admincommandr   	traceback
format_exc	exit_json)
r   moduler   r   r   clientexcepdbafter_valuees
             w/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/mongodb/plugins/modules/mongodb_parameter.pymainr9   ^   s   02M&D!D!u~>	   #!(*:;<F 1)<#2 	 	4 MM'"E|,JMM'"EKJET#FTBFFTB 
Bp bjjBE5>B K+^_%;u+="={SXGY$ 	 	&'  KujIJK  T?)EBRRSST  p=	!LXaXlXlXnoopsB   0D3 E )F 3!EE	F#FF	G1GG__main__)
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESRETURNr/   ansible.module_utils.basicr   r   ansible.module_utils._textr   Iansible_collections.community.mongodb.plugins.module_utils.mongodb_commonr	   r
   r   r   r   r   r9   __name__     r8   <module>rG      s]    A @(T	
  J 0  .&b zF rF   