This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start wiring up schedule at configure
- Loading branch information
Showing
6 changed files
with
59 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,41 @@ | ||
import docker | ||
from privateer2.keys import keys_data | ||
from privateer2.util import string_to_volume | ||
from privateer2.yacron import generate_yacron_yaml | ||
|
||
|
||
def configure(cfg, name): | ||
cl = docker.from_env() | ||
data = keys_data(cfg, name) | ||
keys = keys_data(cfg, name) | ||
schedule = generate_yacron_yaml(cfg, name) | ||
vol = cfg.machine_config(name).key_volume | ||
cl.volumes.create(vol) | ||
print(f"Copying keypair for '{name}' to volume '{vol}'") | ||
string_to_volume( | ||
data["public"], vol, "id_rsa.pub", uid=0, gid=0, mode=0o644 | ||
keys["public"], vol, "id_rsa.pub", uid=0, gid=0, mode=0o644 | ||
) | ||
string_to_volume(data["private"], vol, "id_rsa", uid=0, gid=0, mode=0o600) | ||
if data["authorized_keys"]: | ||
string_to_volume(keys["private"], vol, "id_rsa", uid=0, gid=0, mode=0o600) | ||
if keys["authorized_keys"]: | ||
print("Authorising public keys") | ||
string_to_volume( | ||
data["authorized_keys"], | ||
keys["authorized_keys"], | ||
vol, | ||
"authorized_keys", | ||
uid=0, | ||
gid=0, | ||
mode=0o600, | ||
) | ||
if data["known_hosts"]: | ||
if keys["known_hosts"]: | ||
print("Recognising servers") | ||
string_to_volume( | ||
data["known_hosts"], vol, "known_hosts", uid=0, gid=0, mode=0o600 | ||
keys["known_hosts"], vol, "known_hosts", uid=0, gid=0, mode=0o600 | ||
) | ||
if data["config"]: | ||
if keys["config"]: | ||
print("Adding ssh config") | ||
string_to_volume( | ||
data["config"], vol, "config", uid=0, gid=0, mode=0o600 | ||
keys["config"], vol, "config", uid=0, gid=0, mode=0o600 | ||
) | ||
if schedule: | ||
print("Adding yacron schedule") | ||
string_to_volume(schedule, vol, "yacron.yml", uid=0, gid=0) | ||
string_to_volume(name, vol, "name", uid=0, gid=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters