From cd1b4042ae7235b3d7a6361a4f8b45ef2f8ea147 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 5 Sep 2018 17:36:01 -0400 Subject: [PATCH] Move SSH keys and other config hard-coded config out of the build worker template In addition to removing our public keys from git, this will also allow additional customization Fixes https://jira.coreos.com/browse/QUAY-1035 --- buildman/manager/executor.py | 25 ++++++++++++++----------- buildman/templates/cloudconfig.yaml | 18 +++++++----------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/buildman/manager/executor.py b/buildman/manager/executor.py index 4bcff9697..3cafe0ae9 100644 --- a/buildman/manager/executor.py +++ b/buildman/manager/executor.py @@ -109,17 +109,20 @@ class BuilderExecutor(object): quay_password = self.executor_config['QUAY_PASSWORD'] return TEMPLATE.render( - realm=realm, - token=token, - build_uuid=build_uuid, - quay_username=quay_username, - quay_password=quay_password, - manager_hostname=manager_hostname, - websocket_scheme=self.websocket_scheme, - coreos_channel=coreos_channel, - worker_tag=self.executor_config['WORKER_TAG'], - logentries_token=self.executor_config.get('LOGENTRIES_TOKEN', None), - volume_size=self.executor_config.get('VOLUME_SIZE', '42G'), + realm=realm, + token=token, + build_uuid=build_uuid, + quay_username=quay_username, + quay_password=quay_password, + manager_hostname=manager_hostname, + websocket_scheme=self.websocket_scheme, + coreos_channel=coreos_channel, + worker_image=self.executor_config.get('WORKER_IMAGE', 'quay.io/coreos/registry-build-worker'), + worker_tag=self.executor_config['WORKER_TAG'], + logentries_token=self.executor_config.get('LOGENTRIES_TOKEN', None), + volume_size=self.executor_config.get('VOLUME_SIZE', '42G'), + max_lifetime_s=self.executor_config.get('MAX_LIFETIME_S', 10800), + ssh_authorized_keys=self.executor_config.get('SSH_AUTHORIZED_KEYS', []), ) diff --git a/buildman/templates/cloudconfig.yaml b/buildman/templates/cloudconfig.yaml index 9136c11aa..07b6e960d 100644 --- a/buildman/templates/cloudconfig.yaml +++ b/buildman/templates/cloudconfig.yaml @@ -7,16 +7,12 @@ users: - sudo - docker +{% if ss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bI7Cfvcnf9hZd+n20Bp250GbcH0HD4/9d2DMIU6c6rAjmglPfVmyphcRruWdyCZz+ps9cfpVCQSSGSnbGS7T3M4VIXrCtjNZ7Fv7YIJ8EXWlhkNEfOYuy/lhfvyMLrp5abg5HkXSgOA3kfyitLnBN/lJODSUguDPmpo7tyjplEFQ70LYxJczw== EvB Key +{% for ssh_key in ssh_authorized_keys -%} +- {{ ssh_key }} +{%- endfor %} +{%- endif %} write_files: - path: /root/disable-aws-metadata.sh @@ -63,7 +59,7 @@ coreos: [Install] WantedBy=sockets.target {{ dockersystemd('quay-builder', - 'quay.io/coreos/registry-build-worker', + worker_image, quay_username, quay_password, worker_tag, @@ -103,4 +99,4 @@ coreos: Description=Machine Lifetime Service [Service] Type=oneshot - ExecStart=/bin/sh -xc "/bin/sleep 10800; /usr/bin/systemctl --no-block poweroff" + ExecStart=/bin/sh -xc "/bin/sleep {{ max_lifetime_s }}; /usr/bin/systemctl --no-block poweroff"