File tree Expand file tree Collapse file tree 7 files changed +105
-20
lines changed Expand file tree Collapse file tree 7 files changed +105
-20
lines changed Original file line number Diff line number Diff line change @@ -27,23 +27,9 @@ docker will create it as directory:
27
27
> exist on the Docker host, -v will create the endpoint for you. It is always
28
28
> created as a directory.
29
29
30
- ```
31
- [Unit]
32
- Description=ssh-key-agent
33
- After=docker.service
34
- Requires=docker.service
35
- [Service]
36
- Restart=on-failure
37
- ExecStartPre=-/bin/mkdir -p /home/user/.ssh/
38
- ExecStartPre=-/usr/bin/touch /home/user/.ssh/authorized_keys
39
- ExecStart=/bin/sh -c 'docker run --name=%p_$(uuidgen) --rm \
40
- -v /home/user/.ssh/authorized_keys:/authorized_keys \
41
- -e SKA_KEY_URI=https://[app/bucket]/authmap \
42
-
43
- -e SKA_AKF_LOC=/authorized_keys \
44
- -e SKA_INTERVAL=60 \
45
- quay.io/utilitywarehouse/ssh-key-agent'
46
- ExecStop=/bin/sh -c 'docker stop -t 3 "$(docker ps -q --filter=name=%p_)"'
47
- [Install]
48
- WantedBy=multi-user.target
49
- ```
30
+ example Systemd service: [ ./terraform/resources/ssh-key-agent.service] ( ./terraform/resources/ssh-key-agent.service )
31
+
32
+ ### terraform module
33
+
34
+ Repository includes a terraform module, for use instructions have a look at
35
+ [ ./terraform/README.md] ( ./terraform/README.md )
Original file line number Diff line number Diff line change
1
+ This terraform module returns an ignition systemd unit for running
2
+ ssh-key-agent as a service on Kinvolk's Flatcar Linux.
3
+
4
+ ## Input Variables
5
+ The input variables are documented in their description and it's best to refer
6
+ to [ variables.tf] ( variables.tf ) .
7
+
8
+ ## Outputs
9
+ - ` id ` - the id of the ignition systemd unit file
10
+ - ` template_rendered ` - the systemd unit template, rendered with the provided variables
11
+
12
+ ## Usage
13
+ ``` hcl
14
+ module "ssh_key_agent" {
15
+ source = "github.com/utilitywarehouse/tf_ssh_key_agent"
16
+
17
+ groups = [
18
+
19
+
20
+ ]
21
+
22
+ ssh_key_agent_version = "1.0.4"
23
+ uri = "https://s3-eu-west-1.amazonaws.com/example-keys-cache/authmap"
24
+ }
25
+ ```
Original file line number Diff line number Diff line change
1
+ data "template_file" "ssh-key-agent" {
2
+ template = " ${ file (" ${ path . module } /resources/ssh-key-agent.service" )} "
3
+
4
+ vars = {
5
+ uri = var.uri
6
+ groups = " ${ join (" ," , var. groups )} "
7
+ version = var.ssh_key_agent_version
8
+ }
9
+ }
10
+
11
+ data "ignition_systemd_unit" "ssh-key-agent" {
12
+ name = " ssh-key-agent.service"
13
+ enabled = var. enabled
14
+ content = data. template_file . ssh-key-agent . rendered
15
+ }
Original file line number Diff line number Diff line change
1
+ output "id" {
2
+ value = data. ignition_systemd_unit . ssh-key-agent . id
3
+ }
4
+
5
+ output "template_rendered" {
6
+ value = data. template_file . ssh-key-agent . rendered
7
+ }
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =ssh-key-agent
3
+ After =docker.service
4
+ Requires =docker.service
5
+ [Service]
6
+ Restart =on-failure
7
+ ExecStartPre =-/usr/bin/mkdir -p /home/core/.ssh
8
+ ExecStartPre =-/usr/bin/touch /home/core/.ssh/authorized_keys
9
+ ExecStartPre =-/usr/bin/chown -R "core" :"core" /home/core/.ssh
10
+ ExecStartPre =-/usr/bin/chmod 700 /home/core/.ssh
11
+ 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_)"'
20
+ [Install]
21
+ WantedBy =multi-user.target
Original file line number Diff line number Diff line change
1
+ variable "uri" {
2
+ type = string
3
+ description = " The S3 URI of the authmap file"
4
+ }
5
+
6
+ variable "groups" {
7
+ type = list
8
+ description = " A list of allowed google groups"
9
+ }
10
+
11
+ variable "ssh_key_agent_version" {
12
+ type = string
13
+ description = " The ssh-key-agent version"
14
+ }
15
+
16
+ variable "enabled" {
17
+ type = string
18
+ default = true
19
+ description = " Whether or not the service shall be enabled"
20
+ }
Original file line number Diff line number Diff line change
1
+ terraform {
2
+ required_providers {
3
+ ignition = {
4
+ source = " terraform-providers/ignition"
5
+ }
6
+ template = {
7
+ source = " hashicorp/template"
8
+ }
9
+ }
10
+ required_version = " >= 0.13"
11
+ }
You can’t perform that action at this time.
0 commit comments