cloudinit fix for password expiry
This commit is contained in:
@@ -27,6 +27,7 @@ class CreateServerRequest extends Request implements HasBody
|
|||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'server_type' => $this->serverType,
|
'server_type' => $this->serverType,
|
||||||
'location' => $this->location,
|
'location' => $this->location,
|
||||||
|
'user_data' => file_get_contents(resource_path('scripts/hetzner-cloudinit.yml')),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,16 +34,6 @@ class WaitForServerToConnect implements ShouldQueue, ShouldBeEncrypted
|
|||||||
->execute('echo "Connected"');
|
->execute('echo "Connected"');
|
||||||
|
|
||||||
if (! $process->isSuccessful()) {
|
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('root pw: ' . $this->rootPassword);
|
||||||
logger('server not reachable');
|
logger('server not reachable');
|
||||||
logger('exit code' . $process->getExitCode());
|
logger('exit code' . $process->getExitCode());
|
||||||
|
|||||||
3
resources/scripts/hetzner-cloudinit.yml
Normal file
3
resources/scripts/hetzner-cloudinit.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#cloud-config
|
||||||
|
chpasswd:
|
||||||
|
expire: false
|
||||||
Reference in New Issue
Block a user