Chmod-2.2.0

Required license: KOSI Enterprise

KOSI Plugin chmod Version 2.2.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.If required, the command can also be executed with sudo.

  • The state value can be either file or directory. If directory is specified, the plugin applies permissions recursively.
  • The mode value defines the permission settings using the standard numeric format used in Linux.
  • If required, you can run chmod with sudo. This requires a password that must be assigned to the non-root user in advance by the root user.

Keys

Key Description
path Mandatory Absolute path of the file or directory whose permissions you want to change.
state Mandatory Specifies whether the path refers to a file or a directory. If directory is used, permissions are applied recursively.
mode Mandatory Permission mode using the Linux numeric syntax (supports three-digit and four-digit octal representation) such as 755 or 644
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";
    );
}