Add support for running routines via command line

This commit is contained in:
garrettmills
2020-08-13 20:28:23 -05:00
parent afb35ebad8
commit f5b84b530c
33 changed files with 396 additions and 5 deletions

View File

@@ -1,17 +1,20 @@
const State = require('../State')
class CommandState extends State {
#ran_once = false
static get services() {
return [...super.services, 'output']
}
async apply() {
const cmd = `${this._config.cmd}`
await this._host.run(cmd)
const result = await this._host.run(cmd)
this.#ran_once = true
}
async check() {
return false
return this.#ran_once
}
async reverse() {
@@ -30,6 +33,10 @@ class CommandState extends State {
check_message() {
return `The command check was not successful.`
}
display() {
return `Run the command: ${this._config.cmd}`
}
}
module.exports = exports = CommandState

View File

@@ -20,6 +20,10 @@ class IsAliveState extends State {
check_message() {
return this.failure_message()
}
display() {
return `Ensure that the host is alive...`
}
}
module.exports = exports = IsAliveState

View File

@@ -27,6 +27,10 @@ class PackageAbsentState extends State {
check_message() {
return this.failure_message()
}
display() {
return `Ensure that the package ${this._config.package} is not installed...`
}
}
module.exports = exports = PackageAbsentState

View File

@@ -31,6 +31,10 @@ class PackageCacheClearedState extends State {
check_message() {
return `The package cache on host "${this._host.name}" has not been cleared.`
}
display() {
return `Ensure that the package cache is cleared...`
}
}
module.exports = exports = PackageCacheClearedState

View File

@@ -27,6 +27,10 @@ class PackageState extends State {
check_message() {
return this.failure_message()
}
display() {
return `Ensure that the package ${this._config.package} is installed...`
}
}
module.exports = exports = PackageState

View File

@@ -31,6 +31,10 @@ class ServiceDaemonReloadState extends State {
check_message() {
return `The service daemon on host "${this._host.name}" has not been reloaded.`
}
display() {
return `Reload the service daemon...`
}
}
module.exports = exports = ServiceDaemonReloadState

View File

@@ -32,6 +32,10 @@ class ServiceRestartState extends State {
check_message() {
return `The service "${this._config.service}" on host "${this._host.name}" has not been restarted.`
}
display() {
return `Restart the ${this._config.service} service...`
}
}
module.exports = exports = ServiceRestartState

View File

@@ -33,6 +33,10 @@ class ServiceState extends State {
check_message() {
return this.failure_message()
}
display() {
return `Ensure that the ${this._config.service} service is running...`
}
}
module.exports = exports = ServiceState

View File

@@ -32,6 +32,10 @@ class ServiceStoppedState extends State {
check_message() {
return `The service "${this._config.service}" on host "${this._host.name}" has not been stopped.`
}
display() {
return `Ensure that the ${this._config.service} service is not running...`
}
}
module.exports = exports = ServiceStoppedState

View File

@@ -32,6 +32,10 @@ class UpdateState extends State {
check_message() {
return `There are package updates pending on the host "${this._host.name}."`
}
display() {
return `Ensure that all packages are up to date...`
}
}
module.exports = exports = UpdateState