jsiebens / hashi-up

bootstrap HashiCorp Consul, Nomad, or Vault over SSH < 1 minute
MIT License
676 stars 54 forks source link

--ssh-target-sudo-pass flag does not seem to work #37

Closed agritheory closed 2 years ago

agritheory commented 2 years ago

I am passing the --ssh-target-sudo-pass flag and commands are failing. Command and output below. While this is the same error message as #12, I don't think it's the same root issue.

hashi-up consul install \
  --ssh-target-addr $SERVER_1_IP \
  --ssh-target-user atuser \
  --ssh-target-key ~/.ssh/nomad
  --ssh-target-sudo-pass {{redacted}}
  --server \
  --client-addr 0.0.0.0 \
  --bootstrap-expect 3 \
  --retry-join $SERVER_1_IP --retry-join $SERVER_2_IP --retry-join $SERVER_3_IP

Output:

[INFO] Uploading generated Consul configuration ...
[INFO] Installing Consul ...
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required
error received during installation: Process exited with status 1
 : command not found
 : command not found

Output with the -v flag:

panic: Invalid Semantic Version

goroutine 1 [running]:
github.com/Masterminds/semver.MustParse(...)
        /home/runner/go/pkg/mod/github.com/!masterminds/semver@v1.5.0/version.go:100
github.com/jsiebens/hashi-up/pkg/config.GetArmSuffix({0x927e5b?, 0xc00029c2a0?}, {0x7ffc233dc1fa, 0x2})
        /home/runner/work/hashi-up/hashi-up/pkg/config/version.go:79 +0xc8
github.com/jsiebens/hashi-up/cmd.InstallConsulCommand.func1.1({0xa05b00?, 0xc000140000})
        /home/runner/work/hashi-up/hashi-up/cmd/consul_install.go:157 +0xae8
github.com/jsiebens/hashi-up/pkg/operator.executeRemote({0x7ffc233dc20f, 0xe}, {0x7ffc233dc233, 0x6}, {0xa05590?, 0xc00007f580}, 0xc000193ca0)
        /home/runner/work/hashi-up/hashi-up/pkg/operator/operator.go:152 +0x309
github.com/jsiebens/hashi-up/pkg/operator.ExecuteRemote({0x7ffc233dc20f, 0xe}, {0x7ffc233dc233, 0x6}, {0x7ffc233dc24e?, 0x16?}, {0x0?, 0x0?}, 0x100?)
        /home/runner/work/hashi-up/hashi-up/pkg/operator/operator.go:93 +0x910
github.com/jsiebens/hashi-up/cmd.(*Target).execute(0xc000088360, 0xc000193ca0)
        /home/runner/work/hashi-up/hashi-up/cmd/target.go:42 +0xb1
github.com/jsiebens/hashi-up/cmd.InstallConsulCommand.func1(0xc0001eaf00?, {0x92773f?, 0xa?, 0xa?})
        /home/runner/work/hashi-up/hashi-up/cmd/consul_install.go:186 +0x2f1
github.com/muesli/coral.(*Command).execute(0xc0001eaf00, {0xc00020d400, 0xa, 0xa})
        /home/runner/go/pkg/mod/github.com/muesli/coral@v1.0.0/command.go:856 +0x67c
github.com/muesli/coral.(*Command).ExecuteC(0xc000005b80)
        /home/runner/go/pkg/mod/github.com/muesli/coral@v1.0.0/command.go:974 +0x3bd
github.com/muesli/coral.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/muesli/coral@v1.0.0/command.go:902
github.com/jsiebens/hashi-up/cmd.Execute()
        /home/runner/work/hashi-up/hashi-up/cmd/command.go:31 +0x3f4
main.main()
        /home/runner/work/hashi-up/hashi-up/main.go:12 +0x1d

I also tried running this without the flag and having provided sudo/no password permissions to the user in question

jsiebens commented 2 years ago

Hi @agritheory

Maybe a little bit silly, but it seems that the multi-line command in your example is missing some backslashes \ at the end of a line:

  --ssh-target-key ~/.ssh/nomad
  --ssh-target-sudo-pass {{redacted}}

Without such a slash, bash will not take the following lines as arguments...

Can you try your command with those slashes?

agritheory commented 2 years ago

@jsiebens Thanks for taking a look at this, that was exactly the problem.