chmod-1.7.0
2 minute read
KOSI Plugin chmod Version 1.7.0
Summary
The chmod plugin allows you to modify access permissions for a specified file or directory. By defining a path, state, and mode, you can change file permissions using the Linux chmod command.
- The state value can be either file or directory. If directory is specified, the plugin applies permissions recursively.
- The mode value represents the permission settings in the standard numerical format used in Linux.
- If necessary, you can run chmod with sudo, requiring a password set by the root user.
Keys
Key | Description | |
---|---|---|
path | Mandatory | Absolute path of the file or directory whose permissions you want to change. |
state | Mandatory | Set to file or directory depending on whether the path is a file or directory. |
mode | Mandatory | Permission mode using the Linux numeric syntax (supports three-digit and four-digit octal representation). |
sudo | optional | Set to true to use sudo for the chmod command. |
sudoPassword | optional | Password for executing sudo commands. A root user must assign this password to a non-root user beforehand. |
Note: If you’re not yet familiar with Linux permissions, check out this short introduction from RedHat.
Example 1 - Changing file permissions
languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-example-packagev3";
description = "kosi-example-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input = "template.yaml";
}
containers =
{
example = ["docker.io", "nginx", "latest"];
}
install
{
cmd(command = "echo Changing file permissions using the chmod-plugin");
chmod
(
path = "/user/myuser/myUserApp.sh";
state = "file";
mode = "777"
);
}
Example 2 - Changing directory permissions with sudo
languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-example-packagev3";
description = "kosi-example-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input = "template.yaml";
}
containers =
{
example = ["docker.io", "nginx", "latest"];
}
install
{
cmd(command = "echo Changing directory permissions using the chmod-plugin");
chmod
(
path = "/root";
state = "directory";
mode = "777";
sudo = "true";
sudoPassword = "myPassword";
);
bash(command = "ls -la /root");
}
Example 3 - Restricting permissions to read-only
languageversion = "1.0.0";
apiversion = "kubernative/kubeops/sina/user/v4";
name = "kosi-example-packagev3";
description = "kosi-example-package";
version = "0.1.0";
docs = "docs.tgz";
logo = "logo.png";
files =
{
input = "template.yaml";
}
containers =
{
example = ["docker.io", "nginx", "latest"];
}
install
{
cmd(command = "echo Restricting file permissions using chmod-plugin");
chmod
(
path = "/user/myuser/myUserApp.sh";
state = "file";
mode = "444";
);
}