diff --git a/app/Http/Integrations/Requests/Hetzner/Servers/CreateServerRequest.php b/app/Http/Integrations/Requests/Hetzner/Servers/CreateServerRequest.php index cdc1f83..00d03b5 100644 --- a/app/Http/Integrations/Requests/Hetzner/Servers/CreateServerRequest.php +++ b/app/Http/Integrations/Requests/Hetzner/Servers/CreateServerRequest.php @@ -27,6 +27,7 @@ class CreateServerRequest extends Request implements HasBody 'name' => $this->name, 'server_type' => $this->serverType, 'location' => $this->location, + 'user_data' => file_get_contents(resource_path('scripts/hetzner-cloudinit.yml')), ]; } diff --git a/app/Jobs/Servers/WaitForServerToConnect.php b/app/Jobs/Servers/WaitForServerToConnect.php index a4d4cf5..d6df088 100644 --- a/app/Jobs/Servers/WaitForServerToConnect.php +++ b/app/Jobs/Servers/WaitForServerToConnect.php @@ -34,16 +34,6 @@ class WaitForServerToConnect implements ShouldQueue, ShouldBeEncrypted ->execute('echo "Connected"'); if (! $process->isSuccessful()) { - if (str_contains($process->getErrorOutput(), 'Password change required')) { - $newRootPassword = Str::random(24); - Ssh::create('root', $this->server->ipv4 ?? $this->server->ipv6) - ->usePassword($this->rootPassword) - ->execute('echo "root:'.$newRootPassword.'" | chpasswd'); - - $this->rootPassword = $newRootPassword; - $this->release(15); - return; - } logger('root pw: ' . $this->rootPassword); logger('server not reachable'); logger('exit code' . $process->getExitCode()); diff --git a/resources/scripts/hetzner-cloudinit.yml b/resources/scripts/hetzner-cloudinit.yml new file mode 100644 index 0000000..f624814 --- /dev/null +++ b/resources/scripts/hetzner-cloudinit.yml @@ -0,0 +1,3 @@ +#cloud-config +chpasswd: + expire: false \ No newline at end of file