execute-command

Example:

# Create a directory via a command.
- execute-command:
    command: mkdir -p /tmp/parent/folder

Description

Execute a single command. The command won't be processed through the shell, so it won't reckognize environment variables like $HOME, and can't be used to do shell operation like "<", ">", etc.

Use the frecklet::execute-shell frecklet if that is what you need.

Behind the scenes, this uses the 'command' Ansible module, so check its documentation for more details.

Resources

Variables

Name Type Default Description

command

string --

The command to execute. Required

become_user

string --

The user to execute this command as.

chdir

string --

The working directory.

ignore_error

boolean False

Whether to ignore any potential errors.

no_log

boolean False

Whether to hide the log of this command (because for example the command contains sensitive information).

Examples

Example 1

Create a directory via a command.

Code
- execute-command:
    command: mkdir -p /tmp/parent/folder
Description

Note, usually you'd use the frecklet::folder-exists frecklet for this.

Example 2

Create a relative directory via a command.

Code
- execute-command:
    command: mkdir -p parent/folder
    chdir: /tmp
Description

Note, usually you'd use the frecklet::folder-exists frecklet for this.

Command-line

frecklecute execute-command --help

Usage: frecklecute execute-command [OPTIONS]

  Execute a single command. The command won't be processed through the
  shell, so it won't reckognize environment variables like ``$HOME``, and
  can't be used to do shell operation like "<", ">", etc.

  Use the frecklet::execute-shell frecklet if that is what you need.

  Behind the scenes, this uses the ['command' Ansible module](https://docs.a
  nsible.com/ansible/latest/modules/command_module.html), so check its
  documentation for more details.

Options:
  --command COMMAND               The command to execute.  [required]
  --become-user BECOME_USER       The user to execute this command as.
  --chdir CHDIR                   The working directory.
  --ignore-error / --no-ignore-error
                                  Whether to ignore any potential errors.
  --no-log / --no-no-log          Whether to hide the log of this command
                                  (because for example the command contains
                                  sensitive information).
  --help                          Show this message and exit.