Documentation

    PLEASE NOTE: This document applies to latest version and not to the latest stable release v2.18

    Documentation for other releases can be found by using the version selector in the top right of any doc page.

    Bultins

    By default, every execution of rash exposes two variables to the Context: {{ rash }} and {{ env }}.

    rash

    {{ rash }} variables are builtin values retrieved from execution context.

    - assert:
        that:
          - 'rash.args | length == 0'
          - 'rash.dir == "/"'
          - 'rash.path == "/builtins_example.rh"'
          - 'rash.user.uid == 1000'
          - 'rash.user.gid == 1000'
          - 'rash.check_mode == false'
    

    src/vars/builtin.rs:

    #[derive(Serialize, Deserialize)]
    pub struct Builtins {
        /// Args passed from command line execution.
        args: Vec<String>,
        /// Script directory absolute path.
        dir: String,
        /// Script absolute path.
        path: String,
        user: UserInfo,
        /// Whether rash is running in check mode.
        check_mode: bool,
    }
    
    #[derive(Serialize, Deserialize)]
    struct UserInfo {
        uid: u32,
        gid: u32,
    }
    

    check_mode

    The rash.check_mode variable is a boolean that indicates whether rash is running in check mode (dry-run mode). This is useful for conditionally executing tasks or validating behavior when --check flag is passed.

    Example:

    - name: Skip in check mode
      debug:
        msg: "Running in check mode, skipping actual changes"
      when: rash.check_mode
    

    env

    You can access any environment var as {{ env.MY_ENV_VAR }}.

    Also, you can use command line arguments to pass environment variables:

    rash -e MY_ENV_VAR=foo example.rh