arensb.truenas.initscript module – Manage init/shutdown scripts.

Note

This module is part of the arensb.truenas collection (version 1.11.4).

To install it, use: ansible-galaxy collection install arensb.truenas.

To use it in a playbook, specify: arensb.truenas.initscript.

New in arensb.truenas 1.10.0

Synopsis

  • Set up and manage init and shutdown scripts and commands.

Parameters

Parameter

Comments

cmd

aliases: command

string

Command to execute.

Mutually exclusive with path and script.

name

string / required

Name of the script. Acts as an identifier.

path

string

Path to a script to execute.

Mutually exclusive with cmd and script.

script

string

Text of the script to execute.

When it is time to execute the script, the text will be saved to a temporary file, which will then be executed with sh.

Mutually exclusive with cmd and path.

state

string

Whether the script should exist or not.

Choices:

  • "absent"

  • "present" ← (default)

timeout

integer

Time in seconds that the system should wait for the script to terminate.

when

string

When to execute the script:

preinit: at boot time, before most services have started, but filesystems and network are available.

postinit: late in the boot process, after most services have started, but before TrueNAS services.

shutdown: during shutdown.

Choices:

  • "preinit"

  • "postinit"

  • "shutdown"

Examples

- name: Run a command late once everything has started
  initscript:
    name: Start Foo
    cmd: "service foo start"
    when: postinit

- name: Run a script at shutdown
  initscript:
    name: Cleaning up
    script: |
      #!/bin/sh
      echo "Cleaning up before shutdown."
      service foo stop
      rm /var/some-lock-file
    when: shutdown

- name: Delete an init script
  initscript:
    name: Remove old cruft
    name: Start Foo
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

script

integer

A data structure describing a newly-created init script.

Only returned when a script is created.

Returned: success