package
0.0.0-20240905033552-c50090bf3da5
Repository: https://github.com/tinkerbell/actions.git
Documentation: pkg.go.dev

# README

quay.io/tinkerbell/actions/cexec:latest

The cexec Action performs execution either within a chroot environment or within the base filesystem. The primary use-case is being able to provision files/an Operating System to disk and then being able to execute something that perhaps resides within that filesystem.

Examples

actions:
- name: "Install Grub"
  image: quay.io/tinkerbell/actions/cexec:latest
  timeout: 90
  environment:
      BLOCK_DEVICE: /dev/sda3
      FS_TYPE: ext4
      CHROOT: y
      CMD_LINE: "grub-install --root-directory=/boot /dev/sda"

In order to execute multiple commands (separated by a semi-colon) we will need to leverage a shell. We do this by passing sh -c as a DEFAULT_INTERPRETER. This interpreter will then parse your commands.

actions:
- name: "Update packages"
  image: quay.io/tinkerbell/actions/cexec:latest
  timeout: 90
  environment:
      BLOCK_DEVICE: /dev/sda3
      FS_TYPE: ext4
      CHROOT: y
      DEFAULT_INTERPRETER: "/bin/sh -c"
      CMD_LINE: "apt-get -y update; apt-get -y upgrade"
      UPDATE_RESOLV_CONF: true
      DEBIAN_FRONTEND: noninteractive

Environment variables and CLI flags

All options can be set either via environment variables or CLI flags. CLI flags take precedence over environment variables, which take precedence over default values.

Env variableFlagTypeDefault ValueRequiredDescription
BLOCK_DEVICE--block-devicestring""yesThe block device to mount.
FS_TYPE--fs-typestring""yesThe filesystem type of the block device.
CHROOT--chrootstring""noIf set to y (or a non empty string), the Action will execute the given command within a chroot environment. This option is DEPRECATED. Future versions will always chroot.
CMD_LINE--cmd-linestring""yesThe command to execute.
DEFAULT_INTERPRETER--default-interpreterstring""noThe default interpreter to use when executing commands. This is useful when you need to execute multiple commands.
UPDATE_RESOLV_CONF--update-resolv-confbooleanfalsenoIf set to true, the cexec Action will update the /etc/resolv.conf file within the chroot environment with the /etc/resolv.conf from the host.
JSON_OUTPUT--json-outputbooleantruenoIf set to true, the cexec Action will log output in JSON format. The defaults to true. If set to false, the cexec Action will log output in plain text format.

Any environment variables you set on the Action will be available to the command you execute. For example, if you set DEBIAN_FRONTEND: noninteractive as an environment variable, it will be available to the command you execute.

Exit codes

The following exit codes or statuses are returned by the cexec Action:

CodeDescription
0The cexec Action was executed successfully.
10The was a failure parsing cli flags and/or env variables.
20Required cli flags and/or env variables were not specified.
30The cexec Action failed to execute successfully.