More information about “automation-cli
About switches
Caution: incorrect use of “-op”, “-sshpass”, etc. command switches can lead to “parser commander” edge effects.
Assigning a value to a switch is written as -[switch][space]“[value]”, NOT “=”.
Example with [-sshpass “SSH key password”], do not enter [-sshpass=“SSH key password”], otherwise “commander” will only keep “-s”, which corresponds to silent mode for the run command.
Debugging
To obtain debugging information, first run :
export MYTINYDCDEBUG=1
Then run the PLC of your choice.
Debugging information is located in the directory: “~/automation-cli.logs/automation-debug.log”. The full path is displayed in the last line of the run report.
To stop debugging :
unset MYTINYDCDEBUG
WARNING: The information contained in the debugging log file may reveal secrets…
Host inactivity
When an operation is executed by “automation-cli”, host activity is monitored every five seconds. “automation-cli” stops automatically when no activity has been detected. The default period is two hours. You can change this value using the -actto
switch and specify a value in minutes.
An activity is an event on the std
or stderr
outputs.
To test this feature :
automation-cli run -h "localhost" -actto 1 -c "sleep 120" -y
Bash
Protect variables at runtime, for example.
Display the contents of a variable passed to the runtime environment: TESTTESTTEST=xxxx
# \$ see explanationsautomation-cli run -h "localhost" -c "echo \$TESTTESTTEST" -y -e TESTTESTTEST="xxxx"# ORautomation-cli run -h "localhost" -c 'echo "$TESTTESTTEST"' -y -e TESTTESTTEST="xxxx"
\$TESTTESTTEST because you’re executing a bash command. bash performs content substitution before execution because the content is enclosed in quotation marks, for more details see bash operation
Scheduled tasks (cron)
Depending on the configuration of some systems, it is advisable to prefix the “automation-cli” command with its actual location “/usr/local/bin/automation-cli” in a “cron” file. To avoid sending unnecessary e-mails, add the “-s” parameter (silent mode), which suppresses all display of the “automation-cli” environment. In your scripts, don’t use the standard output, keep only the “stderr” output for errors.
Operations backup
The best method is to convert the operations directory into a Git repository. This part is not covered much in this documentation. For more information on Git, click here.
WARNING: If you save your operations in a Git repository, you will require [encrypt your inventories].(/en/secrets).