path-is-absent
Example:
# Delete a file (if it exists), using root privileges. - path-is-absent: path: /usr/bin/freckles.sh become: true
Description
Ensure a file or folder is absent. If the path is a folder, it will be deleted recursively.
Variables
Name | Type | Default | Description |
---|---|---|---|
|
string | -- | The path. Required |
|
boolean | False | Whether to use elevated privileges when deleting a file/tree. |
Examples
Example 1
Delete a file (if it exists), using root privileges.
Code
- path-is-absent: path: /usr/bin/freckles.sh become: true
Example 2
Delete a file (if it exists).
Code
- path-is-absent: path: /tmp/freckles.sh
Code
doc: short_help: Ensure a file or folder is absent. help: |- Ensure a file or folder is absent. If the path is a folder, it will be deleted recursively. examples: - title: Delete a file (if it exists), using root privileges. vars: path: /usr/bin/freckles.sh become: true - title: Delete a file (if it exists). vars: path: /tmp/freckles.sh args: path: doc: short_help: The path. type: string required: true empty: false cli: param_type: argument become: doc: short_help: Whether to use elevated privileges when deleting a file/tree. type: boolean required: false default: false frecklets: - task: become: '{{:: become ::}}' frecklet: name: file type: ansible-module desc: short: 'delete file (if exists): {{:: path ::}}' long: | Delete file or folder '{{:: path ::}}' if it exists (recursively, if folder). references: "'file' Ansible module": https://docs.ansible.com/ansible/latest/modules/file_module.html properties: idempotent: true internet: false elevated: '{{:: become ::}}' vars: path: '{{:: path ::}}' state: absent
frecklecute path-is-absent --help Usage: frecklecute path-is-absent [OPTIONS] PATH Ensure a file or folder is absent. If the path is a folder, it will be deleted recursively. Options: --become / --no-become Whether to use elevated privileges when deleting a file/tree. --help Show this message and exit.
# -*- coding: utf-8 -*- # # module path: pycklets.path_is_absent.PathIsAbsent # from dataclasses import dataclass from pyckles import AutoPycklet from typing import * # noqa @dataclass class PathIsAbsent(AutoPycklet): """Ensure a file or folder is absent. If the path is a folder, it will be deleted recursively. Args: become: Whether to use elevated privileges when deleting a file/tree. path: The path. """ FRECKLET_ID = "path-is-absent" become: bool = None path: str = None def __post_init__(self): super(PathIsAbsent, self).__init__(var_names=["become", "path"]) frecklet_class = PathIsAbsent
# -*- coding: utf-8 -*- # # module path: pycklets.path_is_absent.PathIsAbsent # from pyckles import AutoPycklet class PathIsAbsent(AutoPycklet): """Ensure a file or folder is absent. If the path is a folder, it will be deleted recursively. Args: become: Whether to use elevated privileges when deleting a file/tree. path: The path. """ FRECKLET_ID = "path-is-absent" def __init__(self, become=None, path=None): super(PathIsAbsent, self).__init__(var_names=["become", "path"]) self._become = become self._path = path @property def become(self): return self._become @become.setter def become(self, become): self._become = become @property def path(self): return self._path @path.setter def path(self, path): self._path = path frecklet_class = PathIsAbsent