Skip to content

Commit 62b695e

Browse files
author
meshkodiak[bot]
authored
Merge pull request #107 from meshcloud/feature/configure_known_hosts_in_terraform_runner
feat: configurable known hosts for ssh
2 parents b5a0a3f + 4e6056f commit 62b695e

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- no changes
1010

1111
### Terraform Runner
12-
- no changes
12+
- Configure known hosts via environment variable
1313

1414
## v1.7.3
1515

terraform-runner/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ RUN mkdir ~/unipipe
2323
COPY run-unipipe-terraform.sh /root/unipipe/run-unipipe-terraform.sh
2424
RUN chmod 0755 ~/unipipe/run-unipipe-terraform.sh
2525

26+
# We add known_hosts entries for GitHub because they can be queried safely and we use them for development
27+
# For other git servers, set the KNOWN_HOSTS environment variable of the container
2628
RUN mkdir ~/.ssh
2729
RUN curl --silent https://api.github.com/meta \
2830
| jq --raw-output '"github.com "+.ssh_keys[]' >> ~/.ssh/known_hosts
@@ -31,4 +33,4 @@ COPY entry.sh /root/unipipe/entry.sh
3133
RUN chmod 0755 /root/unipipe/entry.sh
3234

3335
CMD ["/usr/sbin/crond", "-f", "-l", "8"]
34-
ENTRYPOINT ["/root/unipipe/entry.sh"]
36+
ENTRYPOINT ["/root/unipipe/entry.sh"]

terraform-runner/README.MD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,14 @@ as you can see in the following:
3333
docker pull ghcr.io/meshcloud/unipipe-terraform-runner:latest
3434
docker run -t -i -e GIT_SSH_KEY="$(<my-ssh-key-file)" --env-file env.list ghcr.io/meshcloud/unipipe-terraform-runner:latest
3535
```
36+
37+
By default terraform-runner trusts GitHub's public SSH keys.
38+
If you work with a remote repo that is not hosted on GitHub, you need to set the KNOWN_HOSTS environment variable.
39+
40+
```
41+
docker run -it \
42+
-e GIT_SSH_KEY="$(<my-ssh-key-file)" \
43+
-e KNOWN_HOSTS="$(<my-known-hosts-file)" \
44+
--env-file env.list \
45+
ghcr.io/meshcloud/unipipe-terraform-runner:latest
46+
```

terraform-runner/run-unipipe-terraform.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ set -o errtrace
55
set -o pipefail
66
set -o nounset
77

8+
if [[ -n $KNOWN_HOSTS ]]; then
9+
echo "$KNOWN_HOSTS" > ~/.ssh/known_hosts
10+
fi
11+
812
REPO_NAME=instances-repo
913
REPO_DIR=~/unipipe/$REPO_NAME
1014
if [[ ! -d "$REPO_DIR" ]]; then
@@ -21,4 +25,4 @@ cd $REPO_DIR
2125

2226
/usr/local/bin/unipipe git pull $REPO_DIR
2327
/usr/local/bin/unipipe terraform $REPO_DIR
24-
/usr/local/bin/unipipe git push $REPO_DIR -m "processed instances via unipipe terraform"
28+
/usr/local/bin/unipipe git push $REPO_DIR -m "processed instances via unipipe terraform"

0 commit comments

Comments
 (0)