
    Vh+                    |    d dl mZ dZdZdZd dlmZ d dlmZm	Z	 d dl
mZ d dlmZ d d	lmZ d
 Zedk(  r e        yy)    )annotationsa  
---
module: tempfile
version_added: "2.3"
short_description: Creates temporary files and directories
description:
  - The M(ansible.builtin.tempfile) module creates temporary files and directories. C(mktemp) command
    takes different parameters on various systems, this module helps to avoid troubles related to that.
    Files/directories created by module are accessible only by creator. In case you need to make them
    world-accessible you need to use M(ansible.builtin.file) module.
  - For Windows targets, use the M(ansible.windows.win_tempfile) module instead.
options:
  state:
    description:
      - Whether to create file or directory.
    type: str
    choices: [ directory, file ]
    default: file
  path:
    description:
      - Location where temporary file or directory should be created.
      - If path is not specified, the default system temporary directory will be used.
    type: path
  prefix:
    description:
      - Prefix of file/directory name created by module.
    type: str
    default: ansible.
  suffix:
    description:
      - Suffix of file/directory name created by module.
    type: str
    default: ""
extends_documentation_fragment: action_common_attributes
attributes:
    check_mode:
        support: none
    diff_mode:
        support: none
    platform:
        platforms: posix
seealso:
- module: ansible.builtin.file
- module: ansible.windows.win_tempfile
author:
  - Krzysztof Magosa (@krzysztof-magosa)
a+  
- name: Create temporary build directory
  ansible.builtin.tempfile:
    state: directory
    suffix: build

- name: Create temporary file
  ansible.builtin.tempfile:
    state: file
    suffix: temp
  register: tempfile_1

- name: Create a temporary file with a specific prefix
  ansible.builtin.tempfile:
     state: file
     suffix: txt
     prefix: myfile_

- name: Use the registered var and the file module to remove the temporary file
  ansible.builtin.file:
    path: "{{ tempfile_1.path }}"
    state: absent
  when: tempfile_1.path is defined
zy
path:
  description: Path to created file or directory.
  returned: success
  type: str
  sample: "/tmp/ansible.bMlvdk"
)close)mkstempmkdtemp)
format_exc)AnsibleModule)	to_nativec                 D   t        t        t        ddddg      t        d      t        dd      t        dd	      
            } 	 | j                  d   dk(  rDt        | j                  d   | j                  d   | j                  d         \  }}t	        |       n5t        | j                  d   | j                  d   | j                  d         }| j                  d|       y # t        $ r.}| j                  t        |      t                      Y d }~y d }~ww xY w)Nstrfile	directory)typedefaultchoicespath)r   zansible.)r   r    )stater   prefixsuffix)argument_specr   r   r   )r   r   dirT)changedr   )msg	exception)r   dictparamsr   r   r   	exit_json	Exception	fail_jsonr	   r   )modulehandler   es       H/home/dcms/DCMS/lib/python3.12/site-packages/ansible/modules/tempfile.pymainr$   c   s   E6FK;PQ6"UJ7UB/	
FC==!V+"}}X.}}X.MM&)LFD
 &M}}X.}}X.MM&)D 	D1 CYq\Z\BBCs   	BC( (	D1$DD__main__N)
__future__r   DOCUMENTATIONEXAMPLESRETURNosr   tempfiler   r   	tracebackr   ansible.module_utils.basicr   +ansible.module_utils.common.text.convertersr	   r$   __name__     r#   <module>r2      sK    #.`2
  %   4 AC< zF r1   