Search code examples
ruby-on-railschef-infrachef-recipechef-soloknife

Chef - Switch user and run package installations


I have a server that can only SSH using a non-admin username. I also have the root username and password for this server. I want to install some packages by bootstrapping this node. Is there a way to bootstrap this server and run the installations switching to root?

I ran the command,

knife bootstrap [NODE_IP] --ssh-user [NON-ROOT-USERNAME] --ssh-password [NON-ROOT-PASSWORD] --sudo --use-sudo-password --node-name [NODE_NAME] --run-list 'recipe[bootstrap_test]'

Solution

  • You would need user with sudo access to install packages which is different from running installations using root. Give the non-admin user sudo access in sudoers file. you can configure sudo access using command visudo. Also see this thread