Skip to content

Commit 1038cbb

Browse files
authored
Merge pull request #8 from utilitywarehouse/auto-dl-agent
Automatically download the ssh-key-agent if not present
2 parents 21266db + a89c28d commit 1038cbb

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

terraform/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,13 @@ data "ignition_systemd_unit" "ssh-key-agent" {
1919
}
2020
)
2121
}
22+
23+
data "ignition_systemd_unit" "ssh-key-agent-download" {
24+
name = "ssh-key-agent-download.service"
25+
enabled = var.enabled
26+
content = templatefile("${path.module}/resources/ssh-key-agent-download.service",
27+
{
28+
source = "https://github.com/utilitywarehouse/ssh-key-agent/releases/download/${var.agent_version}/ssh-key-agent_${var.agent_version}_linux_amd64"
29+
}
30+
)
31+
}

terraform/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ output "unit" {
22
value = data.ignition_systemd_unit.ssh-key-agent.rendered
33
}
44

5+
output "download-unit" {
6+
value = data.ignition_systemd_unit.ssh-key-agent-download.rendered
7+
}
8+
59
output "file" {
610
value = data.ignition_file.ssh-key-agent.rendered
711
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Unit]
2+
Description=ssh-key-agent-download
3+
Wants=network-online.target
4+
After=network-online.target
5+
Before=ssh-key-agent.service
6+
7+
[Service]
8+
Type=oneshot
9+
Restart=on-failure
10+
ExecStart=-/usr/bin/wget -N -q -O "/opt/bin/ssh-key-agent" "${source}"
11+
ExecStart=-/usr/bin/chmod 755 /opt/bin/ssh-key-agent
12+
ExecStartPost=/bin/systemctl disable ssh-key-agent-download.service
13+
14+
[Install]
15+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)