Main library features
Consistent Usage
All the functions share the same API, accepting configuration in a flexible manner validated by a schema. Once you learn the core usage, you only learn the configuration of the actions you wish to execute.
Everything is a file
No agent to install, no database to depend on. Your project is just another Node.js package easily versionned in Git and any SCM, easily integrated with your CI and CD DevOps tools.
Idempotence
Call a function multiple times and expect the same result. You’ll be informed of any modification and can retrieve detailed information.
Documentation
Learn fast. Source code is self-documented with the most common uses enriched by many examples. Don’t forget to look at the tests as well.
Flexibility
Deliberately sacrificing speed for a maximum of strength, ease of use, and flexibility. The simple API built on a plugin architecture allows us to constantly add new functionalities without affecting the API.
Composition
Built from small and reusable actions imbricated into a complex system. It follows the Unix philosophy of building small single-building blocks with a clear API.
SSH native support
All the functions run transparently over SSH with a possibility to execute as the root user via sudo. Look at the tests, they are all executed both locally and remotely.
Reporting
Advanced reports can be obtained by providing a log function, listening to stdout and stderr streams, generating diffs and backups.
Reliability
Feel confident. Modules are used in production for years and the code is enforced by an extensive test coverage.
Support
The package is open sourced with one of the least restrictive licenses. Get involved and contribute to open source development by sending pull requests and requesting commercial support from Adaltas.
Redis installation example
// Including Nikita
const nikita = require('nikita')
// User configuration
const config = {
// url: 'http://download.redis.io/redis-stable.tar.gz',
// conf: {
// bind: '127.0.0.1',
// port: 6379,
// ...
// }
}
// Nikita instantiation
nikita
// Activate CLI reporting
.log.cli()
// Define and execute a custom Redis action
.call({$header: 'Redis'}, config, function({config}){
// Default configuration
if(!config.url){ config.url = 'http://download.redis.io/redis-stable.tar.gz' }
if(!config.conf){ config.conf = {} }
if(!config.conf['bind']){ config.conf['bind'] = '127.0.0.1' }
if(!config.conf['protected-mode']){ config.conf['protected-mode'] = 'yes' }
if(!config.conf['port']){ config.conf['port'] = 6379 }
// Do the job
this
.file.download({
$header: 'Download',
source: config.url,
target: 'cache/redis-stable.tar.gz'
})
.execute({
$header: 'Compilation',
$unless_exists: 'redis-stable/src/redis-server',
command: `
tar xzf cache/redis-stable.tar.gz
cd redis-stable
make
`
})
.file.properties({
$header: 'Configuration',
target: 'conf/redis.conf',
separator: ' ',
content: config.conf
})
.execute({
$header: 'Startup',
code_skipped: 3,
command: `
./src/redis-cli ping && exit 3
nohup ./redis-stable/src/redis-server conf/redis.conf &
`
})
})