Last active
August 26, 2018 06:34
-
-
Save ryochin/5eb1b6a23f21cdc35c85fec21c6d8950 to your computer and use it in GitHub Desktop.
chef-solo initialization script for CentOS7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# for CentOS7 | |
case $# in | |
1) | |
REMOTE_HOST=$1 | |
;; | |
*) | |
echo "usage: $0 <remote host>" | |
exit 1 | |
;; | |
esac | |
# add chef user | |
ssh $REMOTE_HOST 'sudo /usr/sbin/useradd -d /home/chef -g wheel -m -s /bin/bash -u 140 chef' | |
ssh $REMOTE_HOST 'echo "chef ALL=(ALL) NOPASSWD: ALL" | sudo EDITOR="tee -a" visudo' | |
# add my pubkey | |
ssh $REMOTE_HOST 'sudo install -d -o chef -m 0700 ~chef/.ssh' | |
scp ~/.ssh/id_rsa.pub $REMOTE_HOST:/tmp | |
ssh $REMOTE_HOST 'sudo cp /tmp/id_rsa.pub ~chef/.ssh/authorized_keys' | |
# yum update | |
ssh $REMOTE_HOST 'sudo yum update -y nss curl libcurl ca-certificates' | |
ssh $REMOTE_HOST 'sudo update-ca-trust force-enable' | |
# install chef | |
ssh $REMOTE_HOST '(which chef-solo > /dev/null 2>&1) || sudo curl -L https://www.opscode.com/chef/install.sh | sudo bash -s -- -v 12.10.24' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment