Ansishell is a command (i.g. job, task, etc) runner either locally or remotely based on a declarative format (e.g yaml) defined to be run.
We know this approach as: Configuration as a Code or CaaC in which we control the operation through human readable configuration.
Here is an example of declarative format
kind: playbook
name: any name you liked
steps:
- task: run lsblk
commands:
- lsblk
- df
- task: show list of files
commands:
- ls -l
- pwd
groups:
- uat
local:
- /home/shm/
- /tmp
remote:
- host-1
- host-2
- host-3So with Ansishell we can run those commands either locally or remotely
# dry run
# SSHing into three hosts
# - host-1
# - host-2
# - host-3
# and run any taks we have for groups:
# - uat
./ansishell.sh -dr remote -g uat -f playbook.yml
# run
./ansishell.sh remote -g uat -f playbook.yml
# local
# goes over paths we defined
# - /home/shm/
# - /tmp
./ansishell.sh -dr local -g uat -f playbook.ymlAnsishell inspired from:
For parsing yaml, yq is used, so it should be installed any where you run ansishell.
You can download it directly from release page.
- Add feature
- read host variables for docker containers
- update:
- output formatting
- sample for exec and docker
- Bug fixes:
- exporting variables for containers
- update samples for shell in a container
- Bug fixes:
- change path directory in
.local[]accordingly - get and set
.environmentfor each task - handle single quote in body of a script
- change path directory in
- Add feature:
- combining sub-commands
- Making the
.localoptional - Add
--installfor app subcommand - Rename ansishell.sh to ansishell
- Add more script_debug for better debugging
- Add
set -Cfor the runner, to avoid file overwrite - Enable
--dry-runfor docker - Exit with non-zero if selected group name could not be found
- Rename "setting" sub-command to "app"
- 2b4c115 Add ENV feature to exec runner
- 12aba97 Use loop inside fn
- 4f6cd28 Add volume and environment object for docker
Defining type to docker in yaml tries to run commands in a image is specified in each - task
kind: playbook
type: docker
...
...
steps:
- task: try to xyz
image: alpine:latestThis feature supports:
- mounting volumes -- docker-compose style
- environment
- f76a8eb Add support for run cmd in docker
d68a1e5Rename cli.sh to ansishell.sh95a4901Change exec: color to blue with print_infob210bffAdd example for both local and remote commands9b24401Update setting subcommand
bb9fa7aUpdate help menu for both local and remote subcommands60e71a4Rename serv: to host: for remote subcommand
1c3f690Reuse__ansishell_task_runner()function in local subcommandcdf5040Rename__remote()to__ansishell_task_runner()
The first implementation was using a __remote function which was private inside remote() function.
Since both local and remote commands had execution part in common, so this function (__remote) was
renamed to used for both subcommands.
ed95ae6Add --file option for remote command
Prior to this point, the CLI was using last argument for a playbook file.
This was not easy to manage, so a -f | --file option added to get a file name for playbook.
f304febImprove help() formant and output guide for users3697acaAdd dry run option --dry-rundbf369dFix bug: showing just first commandsbe2ae86Rename name to task for each step
dbf369dFix bug: showing just first commands
cc7ecc9Update output style for remote sub-command
884d3f4Update bash strict mode and add title at the top
0d19fefInitial Commit
License
Copyright 20XX Shakiba Moshiri