Skip to content

Instantly share code, notes, and snippets.

@cmaitchison
Created August 17, 2012 09:45
Show Gist options
  • Save cmaitchison/3377486 to your computer and use it in GitHub Desktop.
Save cmaitchison/3377486 to your computer and use it in GitHub Desktop.

Revisions

  1. cmaitchison revised this gist Aug 17, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion chef_solo_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ chown -R $ADMIN_USER:$ADMIN_GROUP $SSH_DIR

    #disable password access
    sed -E -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
    /etc/init.d/ssh restart
    /etc/init.d/sshd restart

    yum update -y

  2. cmaitchison revised this gist Aug 17, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion chef_solo_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ chown -R $ADMIN_USER:$ADMIN_GROUP $SSH_DIR

    #disable password access
    sed -E -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
    etc/init.d/ssh restart
    /etc/init.d/ssh restart

    yum update -y

  3. cmaitchison revised this gist Aug 17, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions chef_solo_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -23,13 +23,12 @@ chmod 600 $SSH_DIR/authorized_keys
    chown -R $ADMIN_USER:$ADMIN_GROUP $SSH_DIR

    #disable password access
    sed -E -i 's/.*PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
    sed -E -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
    etc/init.d/ssh restart

    yum update -y

    yum install -y gcc automake autoconf libtool make

    yum install -y ruby
    yum install -y ruby-devel ruby-docs ruby-ri ruby-rdoc
    yum install -y rubygems
    @@ -39,9 +38,10 @@ gem install chef ruby-shadow --no-ri --no-rdoc
    mkdir -p /var/chef
    chown $ADMIN_USER:$ADMIN_GROUP /var/chef/

    #init git repo
    #init git
    yum install -y git-core

    #init capistrano deploy directories
    mkdir -p /var/www/shared/
    mkdir -p /var/www/releases/
    chown $ADMIN_USER:$ADMIN_GROUP -R /var/www
  4. cmaitchison created this gist Aug 17, 2012.
    49 changes: 49 additions & 0 deletions chef_solo_bootstrap.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    #!/bin/bash -xe

    #THIS SCRIPT MUST BE RUN AS ROOT

    ADMIN_USER=admin
    ADMIN_GROUP=admin

    #add admin group
    (cat /etc/group | grep -E '\b$ADMIN_GROUP\b') || sudo groupadd $ADMIN_GROUP

    #add admin user
    (cat /etc/passwd | grep -E "\b$ADMIN_USER\b:x") || useradd -m -s /bin/bash $ADMIN_USER -g $ADMIN_GROUP

    #sudoless access for admin user
    (cat /etc/sudoers | grep -E "^$ADMIN_USER\b.*NOPASSWD") || echo "$ADMIN_USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

    #configure SSH
    SSH_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuwaDITgrsmxVvSJ+HEir4iW2eBb8XqB3wIxCWJwmhiB2S6MkdX1CFcj8boHL2RIYgKN0yiTCVlOdQFjhyRpnd8NbS0RW7753SE1hzkgOg+2e1B15lf1PCSD5OPWAtpb1eYlLcs6hns+yFhYCFeQrKLBL2/si8D8OcQcTR7BjjFQEWdhjl4cYiT68cr57yFT+c/f32ZTynEWukC2YIGMjJ1nACUOYF8CSp6RUrD2kY3C1Pb1Q5V3jwi0lhay4aF5AWp28hPVtYASBe2BrYXp8uErhnmWxgXNV19P0NSHE7TBXd9nXz/njI2SDP/p2N/vHquz/Ybxs4F+kGGXknUFitQ== [email protected]"
    SSH_DIR=/home/$ADMIN_USER/.ssh
    mkdir -p -m 700 $SSH_DIR
    echo $SSH_KEY > $SSH_DIR/authorized_keys
    chmod 600 $SSH_DIR/authorized_keys
    chown -R $ADMIN_USER:$ADMIN_GROUP $SSH_DIR

    #disable password access
    sed -E -i 's/.*PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
    etc/init.d/ssh restart

    yum update -y

    yum install -y gcc automake autoconf libtool make

    yum install -y ruby
    yum install -y ruby-devel ruby-docs ruby-ri ruby-rdoc
    yum install -y rubygems

    #install chef
    gem install chef ruby-shadow --no-ri --no-rdoc
    mkdir -p /var/chef
    chown $ADMIN_USER:$ADMIN_GROUP /var/chef/

    #init git repo
    yum install -y git-core

    mkdir -p /var/www/shared/
    mkdir -p /var/www/releases/
    chown $ADMIN_USER:$ADMIN_GROUP -R /var/www

    reboot now