sake
sake copied to clipboard
Improve Servers
This is an issue to improve the server object. I've gathered the following use-cases:
- [x] allow duplicate hosts https://github.com/alajmo/sake/pull/25
- [x] resolve hostnames from ssh_config https://github.com/alajmo/sake/issues/12
- [x] Support Bastion/Jumphost https://github.com/alajmo/sake/pull/32
- [ ] Define multiple hosts without creating individual servers
- [ ] Dynamically fetch hosts (via kubectl, reading from a text file or any other way)
- [ ] Regex filtering of servers
Notes
- How to target inventory? (%, number of servers, regex?)
Some initial mockup of the new design:
- Expand env variables in inventory
- Inventory example:
for i in $(seq 1 100); do echo www.$i.example.com; done
# sake run -s server-1 --number 1 # --number 25%
servers:
# One of the following:
# host: 192.168.1.1
# hosts: www[01:50].example.com # look at https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#adding-ranges-of-hosts
# hosts:
# - 192.168.1.1
# - 192.168.1.2
inventory: kubectl get nodes # or cat hosts.txt # add example for k8s
Hello! I’d like to contribute to this project, but I don’t want to duplicate anything that you’re actively working on. Is there anything on this issue that I can pick up, or should I find another one?
I think the regex filtering of servers
task would be a good start (code paths for similar functionality exist, see tags/servers).
Some notes:
- Set via flag or config, I'm thinking the name
--match
could be used - Target server hosts (so it's not regex for the server names, but for the server hosts)
- Write some unit tests
Would be great to be able to pass arguments to whatever gets inventory. Something like:
# sake run -s server-1 -inventory-args "--expanded-args here"
servers:
# One of the following:
# host: 192.168.1.1
# hosts: www[01:50].example.com # look at https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#adding-ranges-of-hosts
# hosts:
# - 192.168.1.1
# - 192.168.1.2
inventory: some-command
So the inventory command would be:
some-command --expanded-args here
Not sure I follow, do you mean something like this:
servers:
name: server-1
inventory: echo $SOME_ENV
$ sake run ping -s server-1 SOME_ENV="192.168.1.1,192.168.1.2"
which would run task ping
on servers:
- 192.168.1.1
- 192.168.1.2
I think I would pair this with another tool, like a python script, that generates the servers to connect to. But I would like to modify what that python tool generates (maybe select a different region or env) based on some runtime arguments that sake
would pass to the script. Not sure what the interface might look like.
All features are released with v0.12.0 now. @josegonzalez you can now run the following:
servers:
inv:
inventory: ./some-python-script $somearg
env:
somearg: 192.168.1.2
# use default somearg 192.168.1.2
sake run <task> -s inv
# Pass CLI argument
sake run <task> -s inv somearg=192.168.1.99