path-has-mode
Example:
# Set the mode of an existing file. - path-has-mode: path: /tmp/freckles.sh mode: '0775'
Description
Make sure a file/folder has a certain owner/group.
This will recursively apply the mode change in case the path is a directory. If the path does not exist, nothing will be done.
Root/sudo permissions will be used to do the chmod.
Variables
Name | Type | Default | Description |
---|---|---|---|
|
string | -- | The mode to apply. Required |
|
string | -- | the path Required |
|
boolean | False | Whether to apply the changes recursively (if folder). |
Examples
Example 1
Set the mode of an existing file.
Code
- path-has-mode: path: /tmp/freckles.sh mode: '0775'
Code
doc: short_help: Make sure a file/folder has a certain mode. help: | Make sure a file/folder has a certain owner/group. This will recursively apply the mode change in case the path is a directory. If the path does not exist, nothing will be done. Root/sudo permissions will be used to do the chmod. examples: - title: Set the mode of an existing file. vars: path: /tmp/freckles.sh mode: '0775' dest: | If the file ``/tmp/freckles.sh`` exists, this sets the mode to be '0775' (executable). If the file doesn't exist, nothing will be done. args: path: doc: short_help: the path type: string required: true mode: doc: short_help: The mode to apply. type: string required: true recursive: doc: short_help: Whether to apply the changes recursively (if folder). required: false default: false type: boolean meta: tags: - filesystem - file - chmod frecklets: - frecklet: name: path-has-mode.at.yml type: ansible-tasklist desc: short: "ensure path '{{:: path ::}}' has mode: {{:: mode ::}}" properties: elevated: true internet: false idempotent: true resources: ansible-tasklist: - path-has-mode.at.yml vars: __path__: '{{:: path ::}}' __mode__: '{{:: mode ::}}' __recurse__: '{{:: recursive ::}}'
frecklecute path-has-mode --help Usage: frecklecute path-has-mode [OPTIONS] Make sure a file/folder has a certain owner/group. This will recursively apply the mode change in case the path is a directory. If the path does not exist, nothing will be done. Root/sudo permissions will be used to do the chmod. Options: --mode MODE The mode to apply. [required] --path PATH the path [required] --recursive / --no-recursive Whether to apply the changes recursively (if folder). --help Show this message and exit.
# -*- coding: utf-8 -*- # # module path: pycklets.path_has_mode.PathHasMode # from dataclasses import dataclass from pyckles import AutoPycklet from typing import * # noqa @dataclass class PathHasMode(AutoPycklet): """Make sure a file/folder has a certain owner/group. This will recursively apply the mode change in case the path is a directory. If the path does not exist, nothing will be done. Root/sudo permissions will be used to do the chmod. Args: mode: The mode to apply. path: the path recursive: Whether to apply the changes recursively (if folder). """ FRECKLET_ID = "path-has-mode" mode: str = None path: str = None recursive: bool = None def __post_init__(self): super(PathHasMode, self).__init__(var_names=["mode", "path", "recursive"]) frecklet_class = PathHasMode
# -*- coding: utf-8 -*- # # module path: pycklets.path_has_mode.PathHasMode # from pyckles import AutoPycklet class PathHasMode(AutoPycklet): """Make sure a file/folder has a certain owner/group. This will recursively apply the mode change in case the path is a directory. If the path does not exist, nothing will be done. Root/sudo permissions will be used to do the chmod. Args: mode: The mode to apply. path: the path recursive: Whether to apply the changes recursively (if folder). """ FRECKLET_ID = "path-has-mode" def __init__(self, mode=None, path=None, recursive=None): super(PathHasMode, self).__init__(var_names=["mode", "path", "recursive"]) self._mode = mode self._path = path self._recursive = recursive @property def mode(self): return self._mode @mode.setter def mode(self, mode): self._mode = mode @property def path(self): return self._path @path.setter def path(self, path): self._path = path @property def recursive(self): return self._recursive @recursive.setter def recursive(self, recursive): self._recursive = recursive frecklet_class = PathHasMode