Skip to content

Commit 21266db

Browse files
Merge pull request #7 from utilitywarehouse/remove-docker
2 parents de2d7e4 + 2917994 commit 21266db

File tree

10 files changed

+114
-32
lines changed

10 files changed

+114
-32
lines changed

.goreleaser.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
builds:
2+
- id: main
3+
env:
4+
- CGO_ENABLED=0
5+
goos:
6+
- linux
7+
goarch:
8+
- amd64
9+
archives:
10+
- id: main
11+
builds:
12+
- main
13+
format: binary
14+
files:
15+
- none*
16+
release:
17+
github:
18+
owner: utilitywarehouse
19+
name: ssh-key-agent

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
language: go
2+
3+
go:
4+
- 1.15.x
5+
6+
script:
7+
- curl -sfL https://git.io/goreleaser | sh -s -- check # check goreleaser config for deprecations
8+
9+
# calls goreleaser
10+
deploy:
11+
- provider: script
12+
skip_cleanup: true
13+
script: curl -sL https://git.io/goreleaser | bash
14+
on:
15+
tags: true

README.md

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# ssh-key-agent
22

3-
[![Docker Repository on Quay](https://quay.io/repository/utilitywarehouse/ssh-key-agent/status "Docker Repository on Quay")](https://quay.io/repository/utilitywarehouse/ssh-key-agent)
4-
53
Companion service for https://github.com/utilitywarehouse/ssh-key-manager runs
64
on the host and populates `authorized_keys` file based on the groups provided.
75

@@ -18,16 +16,7 @@ Required environment variables:
1816

1917
#### systemd service file
2018

21-
Requires docker install
22-
23-
Whatever file you are mounting into container needs to exist prior, otherwise
24-
docker will create it as directory:
25-
26-
> If you use -v or --volume to bind-mount a file or directory that does not yet
27-
> exist on the Docker host, -v will create the endpoint for you. It is always
28-
> created as a directory.
29-
30-
example Systemd service: [./terraform/resources/ssh-key-agent.service](./terraform/resources/ssh-key-agent.service)
19+
Example Systemd service: [./terraform/resources/ssh-key-agent.service](./terraform/resources/ssh-key-agent.service)
3120

3221
### terraform module
3322

@@ -36,6 +25,41 @@ Repository includes a terraform module, for use instructions have a look at
3625

3726
### releasing
3827

39-
Before creating a tag / release in Github, please update the Docker image
40-
reference in
41-
[./terraform/variables.tf](./terraform/variables.tf)
28+
Before creating a tag/release in Github, please update the verion in [./terraform/variables.tf](./terraform/variables.tf)
29+
30+
### Docker instructions
31+
32+
If you prefer to run ssh-key-agent with docker, here's an example service:
33+
34+
```
35+
[Unit]
36+
Description=ssh-key-agent
37+
After=docker.service
38+
Requires=docker.service
39+
[Service]
40+
Restart=on-failure
41+
ExecStartPre=-/usr/bin/mkdir -p /home/core/.ssh
42+
ExecStartPre=-/usr/bin/touch /home/core/.ssh/authorized_keys
43+
ExecStartPre=-/usr/bin/chown -R "core":"core" /home/core/.ssh
44+
ExecStartPre=-/usr/bin/chmod 700 /home/core/.ssh
45+
ExecStartPre=-/usr/bin/chmod 644 /home/core/.ssh/authorized_keys
46+
ExecStart=/bin/sh -c 'docker run --name=%p_$(uuidgen) --rm \
47+
-v /home/core/.ssh/authorized_keys:/authorized_keys \
48+
-e SKA_KEY_URI=${uri} \
49+
-e SKA_GROUPS=${groups} \
50+
-e SKA_AKF_LOC=/authorized_keys \
51+
-e SKA_INTERVAL=60 \
52+
quay.io/utilitywarehouse/ssh-key-agent:${version}'
53+
ExecStop=/bin/sh -c 'docker stop -t 3 "$(docker ps -q --filter=name=%p_)"'
54+
[Install]
55+
WantedBy=multi-user.target
56+
```
57+
58+
[![Docker Repository on Quay](https://quay.io/repository/utilitywarehouse/ssh-key-agent/status "Docker Repository on Quay")](https://quay.io/repository/utilitywarehouse/ssh-key-agent)
59+
60+
Whatever file you are mounting into container needs to exist prior, otherwise
61+
docker will create it as directory:
62+
63+
> If you use -v or --volume to bind-mount a file or directory that does not yet
64+
> exist on the Docker host, -v will create the endpoint for you. It is always
65+
> created as a directory.

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/utilitywarehouse/ssh-key-agent
2+
3+
go 1.15
4+
5+
require golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
2+
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE=
3+
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
4+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
5+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
6+
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
7+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

terraform/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ The input variables are documented in their description and it's best to refer
66
to [variables.tf](variables.tf).
77

88
## Outputs
9-
- `id` - the id of the ignition systemd unit file
10-
- `template_rendered` - the systemd unit template, rendered with the provided variables
9+
- `unit` - the ignition systemd unit file
10+
- `file` - the ignition file to setup the ssh-key-agent binary
1111

1212
## Usage
1313
```hcl
1414
module "ssh_key_agent" {
15-
source = "github.com/utilitywarehouse/tf_ssh_key_agent"
15+
source = "github.com/utilitywarehouse/ssh-key-agent//terraform"
1616
1717
groups = [
1818

terraform/main.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
data "ignition_file" "ssh-key-agent" {
2+
mode = 493
3+
filesystem = "root"
4+
path = "/opt/bin/ssh-key-agent"
5+
6+
source {
7+
source = "https://github.com/utilitywarehouse/ssh-key-agent/releases/download/${var.agent_version}/ssh-key-agent_${var.agent_version}_linux_amd64"
8+
}
9+
}
10+
111
data "ignition_systemd_unit" "ssh-key-agent" {
212
name = "ssh-key-agent.service"
313
enabled = var.enabled
414
content = templatefile("${path.module}/resources/ssh-key-agent.service",
515
{
616
uri = var.uri
717
groups = "${join(",", var.groups)}"
8-
version = var.docker_image_version
18+
version = var.agent_version
919
}
1020
)
1121
}

terraform/outputs.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
output "id" {
1+
output "unit" {
22
value = data.ignition_systemd_unit.ssh-key-agent.rendered
33
}
4+
5+
output "file" {
6+
value = data.ignition_file.ssh-key-agent.rendered
7+
}
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
[Unit]
22
Description=ssh-key-agent
3-
After=docker.service
4-
Requires=docker.service
3+
After=network-online.target
4+
Wants=network-online.target
55
[Service]
66
Restart=on-failure
77
ExecStartPre=-/usr/bin/mkdir -p /home/core/.ssh
88
ExecStartPre=-/usr/bin/touch /home/core/.ssh/authorized_keys
99
ExecStartPre=-/usr/bin/chown -R "core":"core" /home/core/.ssh
1010
ExecStartPre=-/usr/bin/chmod 700 /home/core/.ssh
1111
ExecStartPre=-/usr/bin/chmod 644 /home/core/.ssh/authorized_keys
12-
ExecStart=/bin/sh -c 'docker run --name=%p_$(uuidgen) --rm \
13-
-v /home/core/.ssh/authorized_keys:/authorized_keys \
14-
-e SKA_KEY_URI=${uri} \
15-
-e SKA_GROUPS=${groups} \
16-
-e SKA_AKF_LOC=/authorized_keys \
17-
-e SKA_INTERVAL=60 \
18-
quay.io/utilitywarehouse/ssh-key-agent:${version}'
19-
ExecStop=/bin/sh -c 'docker stop -t 3 "$(docker ps -q --filter=name=%p_)"'
12+
Environment="SKA_KEY_URI=${uri}"
13+
Environment="SKA_GROUPS=${groups}"
14+
Environment="SKA_AKF_LOC=/home/core/.ssh/authorized_keys"
15+
Environment="SKA_INTERVAL=60"
16+
ExecStart=/opt/bin/ssh-key-agent
2017
[Install]
2118
WantedBy=multi-user.target

terraform/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ variable "groups" {
88
description = "A list of allowed google groups"
99
}
1010

11-
variable "docker_image_version" {
11+
variable "agent_version" {
1212
type = string
13-
default = "1.0.6"
13+
default = "1.0.7"
1414
description = "The ssh-key-agent version"
1515
}
1616

0 commit comments

Comments
 (0)