recipe-runner/system-module

System module with methods for executing commands and handling files

dev-master / 1.0.x-dev 2019-08-14 14:49 UTC

This package is auto-updated.

Last update: 2024-12-15 02:18:35 UTC


README

Build Status

Requires

Installation

Create a recipe and add the module to the packages section:

name: "Your recipe"
extra:
  rr:
    packages:
      "recipe-runner/system-module": "1.0.x-dev"

Usage

Method: run

Executes a command.

steps:
    - actions:
        - run: "echo hi user"

A command could be split into command and parameters. This way, parameters will be escaped automatically.

steps:
    - actions:
        run:
            command:
                "echo"      # Command
                "hi user"   # parameter 1

You can also set a timeout and the current working directory

steps:
    - actions:
        - run:
            command: "echo hi user"
            timeout: 60
            cwd: "/temp"

Method: copy_file

Makes a copy of a single file.

steps:
    - actions:
        - copy_file:
            from: "/dir1/file.txt"
            to: "/tmp/file.txt"

Method: download_file

Download a file from network.

steps:
    - actions:
        - download_file: 
            url: "https://phar.phpunit.de/phpunit-8.phar"
            filename: "phpunit.phar"

Method: make_dir

Makes a directory recursively. On POSIX filesystems, directories are created with a default mode value 0777.

steps:
    - actions:
        - make_dir: "/dir1"

or you can set the directory mode with the parameter mode

steps:
    - actions:
        - make_dir:
            dir: "/dir1"
            mode: 0777

Method: mirror_dir

Copies all the contents of the source directory into the target one.

steps:
    - actions:
        - mirror_dir:
            from: "/dir1"
            to: "/tmp"

Method: read_file

Reads the content of a file or URL address.

steps:
    - actions:
        - read_file: "/tmp/hi.txt"
          register: "file_content"

File content available at content:

registered["file_content"]["content"]

## or

registered.get('file_content.content')

Method: remove

Deletes files, directories and symlinks.

steps:
    - actions:
        - remove: "/tmp/hi.txt"

or

steps:
    - actions:
        - remove: 
            - "/tmp/hi.txt"
            - "/dir1"
            - "/home/user/symlink1.sh"

Method: write_file

Saves the given contents into a file.

steps:
    - actions:
        - write_file:
            filename: "/tmp/hi.txt"
            content: "hi user"

For module developers

The preferred installation method is Composer:

composer require recipe-runner/system-module

Unit tests

You can run the unit tests with the following command:

$ cd system-module
$ composer test

License

This library is open-sourced software licensed under the MIT license.