Skip to content

Commit

Permalink
Merge pull request #8 from utilitywarehouse/auto-dl-agent
Browse files Browse the repository at this point in the history
Automatically download the ssh-key-agent if not present
  • Loading branch information
yvigara authored Nov 5, 2020
2 parents 21266db + a89c28d commit 1038cbb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ data "ignition_systemd_unit" "ssh-key-agent" {
}
)
}

data "ignition_systemd_unit" "ssh-key-agent-download" {
name = "ssh-key-agent-download.service"
enabled = var.enabled
content = templatefile("${path.module}/resources/ssh-key-agent-download.service",
{
source = "https://github.com/utilitywarehouse/ssh-key-agent/releases/download/${var.agent_version}/ssh-key-agent_${var.agent_version}_linux_amd64"
}
)
}
4 changes: 4 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ output "unit" {
value = data.ignition_systemd_unit.ssh-key-agent.rendered
}

output "download-unit" {
value = data.ignition_systemd_unit.ssh-key-agent-download.rendered
}

output "file" {
value = data.ignition_file.ssh-key-agent.rendered
}
15 changes: 15 additions & 0 deletions terraform/resources/ssh-key-agent-download.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=ssh-key-agent-download
Wants=network-online.target
After=network-online.target
Before=ssh-key-agent.service

[Service]
Type=oneshot
Restart=on-failure
ExecStart=-/usr/bin/wget -N -q -O "/opt/bin/ssh-key-agent" "${source}"
ExecStart=-/usr/bin/chmod 755 /opt/bin/ssh-key-agent
ExecStartPost=/bin/systemctl disable ssh-key-agent-download.service

[Install]
WantedBy=multi-user.target

0 comments on commit 1038cbb

Please sign in to comment.