alajmo / sake Goto Github PK
View Code? Open in Web Editor NEW:robot: sake is a task runner for local and remote hosts
Home Page: https://sakecli.com
License: MIT License
:robot: sake is a task runner for local and remote hosts
Home Page: https://sakecli.com
License: MIT License
This is an issue to improve the server object. I've gathered the following use-cases:
user@ip:port
Some initial mockup of the new design:
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
I want to use sake for managing parallel installations of software on my web hosting server; to so so, I would like to have different servers (with different usernames), but the same host as all of the accounts are sitting on the same server. Is this something you think would be meaningful?
What are the key differences between Ansible and Sake? I can use Ansible to run tasks on different computers.
Hello
I've been playing with sake which is really good but I encountered a case where I have few servers on the same IP but with several SSH ports.
And sake throws an error
$ sake check
Found configuration errors:
error: found duplicate host `X.X.X.X` for the following servers
which is inconvenient because SSH supports it
Is your feature request related to a problem? Please describe.
I wasn't sure if this was the same problem as #5 so I'm opening a new issue just in case. I'm using a mac and whenever I try to run even a basic command like sake run ping --all
using an identity key file I get one of two errors:
/Users/timothybryant/.ssh/id_ed25519_personal
so I created a new key file with a passphrase and now I get:
/Users/timothybryant/.ssh/id_rsa_password_protected
I also tried using the -i
command line argument instead but got the same results.
Describe the solution you'd like
I'm trying to run remote commands on VM's I have and I had hoped sake would be able to do that by ssh'ing to the hosts using the key files I have stored.
Additional context
Most of what I've done thus far (e.g. tasks, specs, etc) has come from the repo examples. Here is an example config for one of my VM's though:
servers:
localhost:
desc: localhost
host: localhost
local: true
#work_dir: /tmp
tags: [local]
vm303:
host: 192.168.1.74
user: jsmith
port: 22
identity_file: ~/.ssh/id_ed25519_personal
local: false
tags: [cluster]
Currently sake does not exit with non-zero code (or, simply, fail) when the command we're executing exited with non-zero code.
It'd be nice if it would fail on non-zero code.
I think the feature should be optional to remain backward compatible with existing users. So, to have sake fail on non-zero exit code, the user should incite another CLI options like --fail
.
The sake command that I use to produce this issue was sake run <command> --servers <server> --known-host-file <file>
Let me know if I was wrong about the exit behavior or any needed reproductions.
Currently only SSH port numbers up to 255 are supported. But many servers are configured by disabling connections on the default SSH port (22) and using a non well known port (such as 2200) instead.
This is because port is currently defined as a uint8
. A change in data type to uint16
should fix this and allow for the full range of port numbers to be used.
This is the error message received when using a large port number:
Config file:
servers:
server:
host: 192.168.1.7
port: 2222
tasks:
ping:
desc: Pong
cmd: echo "pong"
OS
Shell
Installed with go install github.com/alajmo/sake@latest
Version: dev
Commit: none
Date: n/a
sake.yml
:
servers:
localhost:
host: 0.0.0.0
local: true
remote:
host: 0.0.0.0
local: true
work_dir: does_not_exist
tasks:
ping:
desc: Pong
target: {servers: [remote]}
tasks:
- cmd: echo "pong"
local: true
What's wrong:
$ sake run ping
TASK*********
$ sake run --any-errors-fatal ping
TASK*********
error: chdir /tmp/t/does_not_exist: no such file or directory
sake run ping
, though it did nothing. I expected sake
to print any errors and logs happened during execution of task.work_dir
is used for remote
server and task is required to run locally (local: true
). But sake
tries to go into work_dir
locally before executing task, which is wrong behavior.OS
Shell
MaxAuthTries
on sshdssh: handshake failed: ssh: disconnect, reason 2: Too many authentication failures
From the code here, all provided identities are collected and tried for each server with pubkey support.
Lines 163 to 166 in 47cdac6
This should not be the case, each server should only try with (own) provided and global identity.
Also this approach is not very efficient as N servers with same pubkey will generate N identical identities. If a server using pubkey2 is declared below 100 servers using pubkey1, it will need to try 100 wrong identities before it can make connection, if even can pass the MaxAuthTries
.
I have a simple question about one of the code decisions in this project. I see you've chosen to not use the golang viper library for handling configuration and have a custom implementation with yaml library. I was wondering if there was a specific reason for this decision? Viper is compatible with cobra, written by the same author, so it would've been a good option?
Hi,
it just so happened that one of my server is only accessible through two bastions, so I think it'd be great to implement a solution for this in sake.
I've search for a phrase "bastion" in the repository and found this:
https://github.com/alajmo/sake/blob/main/core/run/unix.go#L31
If I'm not missing something then it seems like an pretty easy straightforward thing to do: put all bastions as a list in YAML file then echo each item of the list in this format: -J user@bastionA:port, user@bastionB:port
.
What do you think about it?
Atm it see there is a way to do it via config, but that isn't portable if multiple users are sharing the same sake file but different ssh user.
When you access multiple hosts with the same hostname but different ports (e.g. running multiple virtualized servers on one host) you can't distinguish one from each other in the output.
config-example:
servers:
VM1:
host: root@server:22001
VM2:
host: user@server:22002
VM3:
host: root@server:22003
Running a task like an os-prober will create:
host | OS
--------------------+----------------------------------------------
server | Debian 11
server | Debian 10
server | Debian 11
The information about the different servernames, ports etc. is missing
The output should (optionally) contain information about the server-name (VM1, VM2, VM3 in the example above) and / or port and username.
./.
OS
Shell
I have some VMs running under libvirt, which are normally accessible via their host name, but sake can't resolve them. Resolution does work in other tools (ping
, pyinfra
, ansible
, ssh
, etc) so I don't think it's a general configuration error.
servers:
localhost:
host: 0.0.0.0
local: true
vm:
host: host1vm
tasks:
ping:
desc: Pong
cmd: echo "pong"
λ sake run ping --all
Unreachable Hosts
server | host | user | port | error
--------+---------+------+------+---------------------------------------------------------------
vm | host1vm | soup | 22 | dial tcp: lookup host1vm on 127.0.0.53:53: server misbehaving
λ ping host1vm
PING host1vm (192.168.122.244) 56(84) bytes of data.
64 bytes from 192.168.122.244 (192.168.122.244): icmp_seq=1 ttl=64 time=0.141 ms
^C64 bytes from 192.168.122.244: icmp_seq=2 ttl=64 time=0.132 ms
You can use https://github.com/rktjmp/virt-up to bring up named hosts, but it does require some setup.
OS
Shell
I have 1password
as http agent and I've also tried with identity_file setting. Connecting to ssh doesnt work, and give me the following error:
ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
I run: sake run ping
Version: 0.15.0
Authentication:
Key Type:
Key Format:
sake.yaml
:
servers:
myserver:
host: server
tasks:
ping:
desc: Pong
cmd: echo "pong"
~/.ssh/config
:
Host server
HostName 123.123.123.123
User root
IdentityFile ~/.ssh/ailab_ed25519
sake run ping --all
Output:
error: open ~/.ssh/ailab_ed25519: no such file or directory
sake ssh myserver
Output:
[email protected]'s password:
It picks up my PC name (ronny) instead of the the server username (root).
$ ssh-keygen -t ed25519 -C "ailab-server"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/ronny/.ssh/id_ed25519): ailab_ed25519
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Passphrase is empty
As in "for Pete's sake," or as in the alcoholic beverage of fermented rice?
sake ssh remote-server
works as expected
sake exec 'ls' -s remote-server
for the same server returns an error: "ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain"
A remote command with plain ssh works:
ssh user@remote-server "ls"
Any hint why the connection fails if I try to execute a cmd via sake?
I've just found the tool and I'm very impressed, but I can't figure out how to use sudo on a remote server.
From what I've read in the documentation is supposed to run not interactively, so I could provide a password with sudo -S
.
Considering that I'm running a script only on one server at a time I'd rather have an interactive session, which seems to be possible using the --tty
parameter, but then I don't SSH into the server automatically anymore.
What's the recommended solution here?
Hi:
Maybe I'm not doing it right, but I don't know how to run a command with single quote in it.
When I run, for example:
sake exec -s server 'uname -r|awk -v FS='-' '{print $1}''
it fails with "Process exited with status 1".
I've tried with doble quote and "\", but I can't find a way for it to work
Is there a way to do it?
Best regards
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.
When entering a ipv6 address i get the following error:
dial tcp: address fd58:9374:59b8:430c:8299:936b:7f1:49c:22: too many colons in address
If I put square brackets around i get:
error: cannot unmarshal !!seq into string
Describe the solution you'd like
A clear and concise description of what you want to happen.
I would like to be able to connect to servers using ipv6
Additional context
Add any other context or screenshots about the feature request here.
I want to stop system on several servers. I have two types of servers insert and storages.
on servers with tag insert i need to run command systemctl stop vm-insert
and on storages systemctl stop vm-storage
i've made such config
tasks:
stop-vm-insert:
cmd: |
echo "systemctl stop vm-insert";
....
target:
tags: [insert]
stop-vm-storage:
cmd: |
echo "systemctl stop vm-storage";
....
target:
tags: [ storage ]
stop-daemons:
tasks:
- task: stop-vm-insert
- task: stop-vm-storage
i'm expecting that commands must be issued only on target servers but instead they are run on both target groups.
Any ideas on how to do so ?
Would love to see Windows support added to this, both for client and for server side.
This is an issue to improve the task object. I've gathered the following use-cases:
hidden: true
attributesilent: true
(and flag)default_timeout_s
chdir
for tasks, work_dir
for serversMatch *
in ssh config for inventory as welldefault
spec/targetsake ssh inv
not workingA separate pull-request will be created to implement the necessary changes.
OS
Shell
I get the following error message when running a command, no matter if I target a single server or all my servers:
error: strconv.ParseInt: parsing "": invalid syntax
sake check
says that my configuration is OK.
This is my definition file:
servers:
production:
host: my.server.de
port: 123
user: user1
local: false
tags:
- remote
stage:
host: my.server.de
port: 123
user: user2
local: false
tags:
- remote
test:
host: my.server.de
port: 123
user: user3
local: false
tags:
- remote
internal:
host: 192.1.2.3
user: user
local: false
tags:
- internal
tasks:
ping:
desc: Ping server
cmd: ping $SAKE_SERVER_HOST
local: true
pwd:
desc: Print working directory
cmd: pwd
And this is what I'm running:
sake run ping --all
Similar to alajmo/mani
project, output from sake
includes a Running
spinner, which is also present when directed to file.
Add an option to disable the Running
spinner (-s, --silent).
I use and enjoy both projects ;)
Hello.
Thanks for the projet, it is great.
But I wondering what are the differences from Ansible which seems to do the same job ?
Why did you create this tool ?
Thanks
Hi there,
I am testing the tool, I like the simplicity very useful. Thank you.
I want to know if there is a way to store output from a task to use in the next task in the same recipe?
Hope you can help me.
Regards,
Julio
OS
Shell
~ sake.yaml ~
servers:
myserver1: ## not working (error: strconv.ParseInt: parsing "55555": value out of range)
host: [email protected]:55555
myserver2: ## working
host: [email protected]
port: 55555
sake check
I was trying to configure a server in sake.yaml, by simply using the hostname as it is written in my ~/.ssh/config
, but realized this does not work.
sake.yaml
:servers:
myserver:
host: myserver
~/.ssh/config
:Host myserver
Hostname 123.123.123.123
User root
Can this be made to work?
OS
Shell
Seems the config reference doc is not updated. I ran into problem configuring header format in newer version.
https://github.com/alajmo/sake/blob/main/docs/config-reference.md?plain=1#L117
~ sake.yaml (old) ~
specs:
default:
output: table
themes:
default:
table:
format:
header: upper
~ sake.yaml (new) ~
specs:
default:
output: table
themes:
default:
table:
header:
format: upper
$ sake check ## runs fine
$ sake list servers ## error
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x657177]
goroutine 1 [running]:
github.com/alajmo/sake/core/print.CreateTable({{0x0, 0x0}, {0x7d28f6, 0x5}, {{0xc0000ada90, 0x7}, {{0x0, 0x0}, {0x7d2761, 0x5}, ...}, ...}, ...}, ...)
/home/runner/work/sake/sake/core/print/table.go:31 +0x197
github.com/alajmo/sake/core/print.table1[...]({_, _, _}, {{0x0, 0x0}, {0x7d28f6, 0x5}, {{0xc0000ada90, 0x7}, {{0x0, ...}, ...}, ...}, ...}, ...)
/home/runner/work/sake/sake/core/print/print_table.go:48 +0x88
github.com/alajmo/sake/core/print.PrintTable[...]({_, _, _}, {{0x0, 0x0}, {0x7d28f6, 0x5}, {{0xc0000ada90, 0x7}, {{0x0, ...}, ...}, ...}, ...}, ...)
/home/runner/work/sake/sake/core/print/print_table.go:33 +0x19e
github.com/alajmo/sake/cmd.listServers(0xae2340, {0xb1bb18?, 0x0?, 0x0?}, 0xc0000d2fa0, 0xc000080780)
/home/runner/work/sake/sake/cmd/list_servers.go:121 +0x5e9
github.com/alajmo/sake/cmd.listServersCmd.func1(0xc00015cc80?, {0xb1bb18?, 0x0?, 0x0?})
/home/runner/work/sake/sake/cmd/list_servers.go:33 +0x88
github.com/spf13/cobra.(*Command).execute(0xc00015cc80, {0xb1bb18, 0x0, 0x0})
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:876 +0x67b
github.com/spf13/cobra.(*Command).ExecuteC(0xadd680)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:990 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
/home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:918
github.com/alajmo/sake/cmd.Execute()
/home/runner/work/sake/sake/cmd/root.go:42 +0x25
main.main()
/home/runner/work/sake/sake/main.go:8 +0x17
Is your feature request related to a problem? Please describe.
Trying to use a private key with .pem extension gives the following error:
error: failed to parse `path/to/key.pem`
ssh: not an encrypted key
Describe the solution you'd like
To be able to define servers that use .pem
private key files
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.