Replies: 1 comment 1 reply
-
Using from pyinfra import host, state
from pyinfra.api import StringCommand, operation
from pyinfra.operations import files, server
from pyinfra.operations.util.files import chmod
@operation(is_idempotent=False)
def run_script(
src,
dest=None,
user=None,
group=None,
mode=None,
cache_time=None,
force=False,
sha256sum=None,
sha1sum=None,
md5sum=None,
headers=None,
insecure=False,
):
"""
Download a shell script to `dest` or temporary location and run.
"""
dest = dest or state.get_temp_filename()
yield from files.download(
src=src,
dest=dest,
user=user,
group=group,
mode=mode,
cache_time=cache_time,
force=force,
sha256sum=sha256sum,
sha1sum=sha1sum,
md5sum=md5sum,
headers=headers,
insecure=insecure,
)
temp_file = state.get_temp_filename()
yield from files.put(
src=dest,
dest=temp_file,
assume_exists=True,
)
yield chmod(temp_file, "+x")
yield StringCommand(temp_file)
# yield from server.script(
# src=dest,
# ) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What's the recommended way to run remote scripts via pyinfra? e.g.
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
I tried:
but the
dest
file is expected to already exist at the start (even before the download is performed):thanks!
Beta Was this translation helpful? Give feedback.
All reactions