Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic linux tools for deploy_hook #1014

Open
ThomDietrich opened this issue May 24, 2023 · 6 comments
Open

Basic linux tools for deploy_hook #1014

ThomDietrich opened this issue May 24, 2023 · 6 comments

Comments

@ThomDietrich
Copy link

Hey there,
I need to use the deploy_hook functionality to copy generated certificates to a place and name which another application expects. To that end I've defined something similar to this:

certificates:
  - domains:
       - ui.kntinternet.de
     deploy_hook: cp /etc/letsencrypt/live/mydomain.de/privkey.pem /etc/letsencrypt/privkey.pem

Upon execution I receive the error:

  dnsrobocert-1  | Hook 'deploy-hook' reported error code 1
  dnsrobocert-1  | Hook 'deploy-hook' ran with error output:
  dnsrobocert-1  |  /bin/sh: 1:  cp: not found

Could you please provide basic commands like cp with the container? Thanks!

@adferrand
Copy link
Owner

I will check if/why the PATH environment is not set correctly, but in the mean time, could you try with the full path of cp, so /bin/cp ?

@ThomDietrich
Copy link
Author

unifi7-dnsrobocert-1  | Hook 'deploy-hook' reported error code 1
unifi7-dnsrobocert-1  | Hook 'deploy-hook' ran with error output:
unifi7-dnsrobocert-1  |  /bin/sh: 1:  /bin/cp: not found
unifi7-dnsrobocert-1  |  /bin/sh: 1:  /bin/cp: not found
unifi7-dnsrobocert-1  |  Error while executing the `deploy` hook:
unifi7-dnsrobocert-1  |  Command '/bin/cp /etc/letsencrypt/live/xxx.de/privkey.pem /etc/letsencrypt/privkey.pem; \ /bin/cp /etc/letsencrypt/live/xxx.de/cert.pem /etc/letsencrypt/cert.pem; \ /bin/cp /etc/letsencrypt/live/xxx.de/chain.pem /etc/letsencrypt/chain.pem' returned non-zero exit status 127.
unifi7-dnsrobocert-1  |  Traceback (most recent call last):
unifi7-dnsrobocert-1  |    File "/usr/local/lib/python3.9/site-packages/dnsrobocert/core/hooks.py", line 40, in main
unifi7-dnsrobocert-1  |      globals()[parsed_args.type](dnsrobocert_config, parsed_args.lineage)
unifi7-dnsrobocert-1  |    File "/usr/local/lib/python3.9/site-packages/dnsrobocert/core/hooks.py", line 137, in deploy
unifi7-dnsrobocert-1  |      _deploy_hook(certificate)
unifi7-dnsrobocert-1  |    File "/usr/local/lib/python3.9/site-packages/dnsrobocert/core/hooks.py", line 239, in _deploy_hook
unifi7-dnsrobocert-1  |      subprocess.check_call(deploy_hook, shell=True, env=env)
unifi7-dnsrobocert-1  |    File "/usr/local/lib/python3.9/subprocess.py", line 373, in check_call
unifi7-dnsrobocert-1  |      raise CalledProcessError(retcode, cmd)
unifi7-dnsrobocert-1  |  subprocess.CalledProcessError: Command '/bin/cp /etc/letsencrypt/live/xxx.de/privkey.pem /etc/letsencrypt/privkey.pem; \ /bin/cp /etc/letsencrypt/live/xxx.de/cert.pem /etc/letsencrypt/cert.pem; \ /bin/cp /etc/letsencrypt/live/xxx.de/chain.pem /etc/letsencrypt/chain.pem' returned non-zero exit status 127.
unifi7-dnsrobocert-1  | 

@ThomDietrich
Copy link
Author

Side note,
I would welcome a feature to define where to store cert/key/chain. Feels like a direct use case that can be easier solved via a configuration option rather than the hoops of a deploy-hook. What do you think?

@ThomDietrich
Copy link
Author

Hey @adferrand did you think about the suggested environment variables? Thanks!

@ThomDietrich
Copy link
Author

ThomDietrich commented Nov 21, 2023

Resolved! Sorry this was user error 🙈 I've used a more complicated yaml than posted above and had a typo in my deploy hook. Fyi this works:

    deploy_hook: >-
       /bin/cp /etc/letsencrypt/live/mydomain.de/privkey.pem /etc/letsencrypt/privkey.pem;
       /bin/cp /etc/letsencrypt/live/mydomain.de/cert.pem /etc/letsencrypt/cert.pem;
       /bin/cp /etc/letsencrypt/live/mydomain.de/chain.pem /etc/letsencrypt/chain.pem

@ThomDietrich
Copy link
Author

Would still be interested to discuss environment variables so I don't have to define this messy hook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants