Get started
To use the “automation-cli” tool, you need to master :
- SSH key authentication.
- bash language.
Limitations
To avoid wasting your time, please read the contents of this chapter carefully.
This program uses internal methods (bash) to install the packages required to execute an operation (notion of dependency).
These methods are only applicable to the operating systems DEBIAN© and derivatives (DEBIAN forever). If you’re using another distribution, the internal methods will have to be adapted, and you’ll have to submit a “PR” (git Push Request).
By design, this program does not work and will never work under “Windows© ”.
Introduction
This program is an open source automation tool, which allows you to manage and deploy configurations on servers in a simple and efficient way on small infrastructures. It has been designed for :
-
Task automation: repetitive tasks, software installation (e.g. preparation of Linux Debian workstations and servers).
-
Orchestration: coordinate processes on multiple servers simultaneously.
-
Configuration management: ensure configuration consistency across all managed servers.
“automation-cli” prepares and sends a ’bash’ script, via an SSH (agentless) connection, which can be encapsulated in a VPN Wireguard (user space) on one or more nodes that execute it (detailed operation). “automation-cli” handles any errors encountered.
“automation-cli” was written as part of the “MytinyDC” project. Like many “sysadmins”, I had numerous shells written in the “bash” language. The effort required to convert all these tasks to Ansible was too great. So I went back to the Ansible blueprint and defined my “shells” as “tasks”. The first version resulted in an engine written entirely in bash, which became too complicated to maintain. The project eventually evolved towards a JavaScript architecture (NodeJs).
Installation
“automation-cli” has no installation system. Simply download the appropriate binary for your platform:
Binaire | checksum sha256 |
---|---|
Linux Debian amd64 (X86_64) | sha256sum |
Linux Debian arm64 | sha256sum |
Download the binary and the “sha253sum” control file. Once the files have been downloaded to your station (“a control node”) :
- Perform a binary integrity check :
sha256sum -c ./automation-cli-[platform].txt
- Rename the binary :
mv automation-cli[platform] automation-cli
- Make the file executable :
chmod +x ./automation-cli
To benefit from the full flexibility of this tool, move the file to one of the directories included in the value of your “PATH” environment variable : echo $PATH
.
Ex: sudo mv ./automation-cli /usr/local/bin
Nodes (hosts)
In an automation process, it’s important to identify the actors involved. In the “automation-cli” context, the actors are nodes (hosts, servers).
Control node
Host on which “automation-cli” is installed, and which performs operations stored in an OPSDirectory
Managed node
Host managed by automation-cli. The managed node executes scripts sent by the “control node” via SSH communication.
All operations are performed by the “root” user; “sudo” is supported.
Hello world
Operation on the control node
This first operation is used to test the correct operation of the tool :
automation-cli run -h localhost -c 'echo "hello world"'
- Confirmation of execution, type Y in uppercase (can be bypassed by adding the “-y ” parameter)
- Operating result
An operation on several servers
“automation-cli” uses SSH to connect to a managed node. Consequently, the control node’s public key must be added to the managed node.
Generating and using an SSH key
If your account doesn’t have an SSH key, generate one with ssh-keygen
. “automation-cli” supports password protection for this key.
Add the public key generated on one of your servers (root account: /root/.ssh/authorized_keys).
Run
This allows you to test operation via an SSH connection. We’re going to run the “hello world” operation simultaneously on the “localhost” server and on the server that has your SSH public key. Surround the value of parameter “-h” with quotation marks (”) or apostrophes (’).
automation-cli run -h "localhost [Server IP Address]" -c 'echo "hello world"'
The operation was carried out on both servers simultaneously.
Several operations on one server
The operation will consist of the execution of two simple operations. To do this, we’ll need a component called “operationBook”.
This is a YAML file describing the operations to be executed.
Our two operations :
- Display “Hello World:
echo "Hello World"
- List the contents of the local disk root :
ls /
Create the YAML file (./test.yaml) as follows:
comment: "My first operationBook"operations: - command: 'echo "Hello world"' - command: "ls /"
Save, then run :
automation-cli run -h "localhost" -ob "./test.yaml" -y
Multiple operations on multiple servers
When used on multiple servers, each operation in the “operationBook” is executed in the specified order on each server.
The program waits until all servers have completed each operation step before moving on to the next.
If the operation is unsuccessful for one of the servers, that server is removed from the execution list, and the other servers continue to execute the next steps.
Using the previous “operationBook”, on two servers simultaneously :
automation-cli run -h "localhost [Server IP Address]" -ob "./test.yaml" -y
Types of operation
The operations described above are simple operations. With the “command” type, actions will be limited very quickly.
That’s why this tool features 3 types of operation :
-
“command” (-c)
As seen previously, it allows a simple command to be executed on a server (supports chaining with “;” or “&&”).
-
“operation” (-op)
An “operation” consists of a manifest used to describe an operation. An “operation” can be defined by the “command” or “scripts” attribute.
-
“operationBook” (-ob)
The “operationBook” is a yaml file that describes the sequence of operations through several types of operations :
- “command”
- “operation”
- “operationBook”
A very simple example of an “operationBook” is shown above. An “operationBook” can execute one or more other “operationBooks ”.
Initializing an operations repository
Secrets
Wireguard VPN
If you wish to use “automation-cli” via a VPN Wireguard connection, please refer to this chapter