-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add 'become' Support to Command
resources for Privilege Escalation Without Passwordless Sudo
#571
Comments
Thanks for the suggestion @froazin! As a workaround, you should be able to set the password in an environment variable use that to escalate. Something like: import pulumi_command as command
remote_command = command.remote.Command(
"updatePackages",
create="echo \"$PASS\" sudo -S apt-get update",
connection=command.remote.ConnectionArgs(
host="hostname.local",
user="your_user_name",
password="your_password",
),
environment: {
PASS: "your_sudo_password"
},
) Of course the usual cautions should apply about using pulumi secrets to set that variable so it will be encrypted in all pulumi state & outputs. |
Ah that checks out @mjeffryes - thanks for the tip; that should do the trick! I have just been using local command and calling the I've been thinking about potentially using a dynamic resource provider with |
I probably don't have enough context to advise which would be the best solution for you, but I'll through one other option into the mix: There's a open source provider for ansible: ansible/terraform-provider-ansible which you can use via our support for Any Terraform Provider It looks like it would still involve parsing stdout/stderr from the ansible playbooks though. |
Hello!
Issue details
Currently, when using Pulumi's
remote.Command
andlocal.Command
resources to execute commands that require elevated privileges (e.g., apt-get update), the user must be configured to allow passwordless privilege escalation. This setup can pose security concerns and adds complexity to the deployment process.Affected area/feature
pulumi_command.remote.Command
Proposed Solution
Introduce a become parameter to the remote.Command resource, similar to Ansible's become directive. This parameter would enable users to specify privilege escalation within the Pulumi configuration, eliminating the need for passwordless sudo configuration on the remote host.
Example Usage (Python 🐍)
The text was updated successfully, but these errors were encountered: