Git Product home page Git Product logo

ansible-digitalocean-bootstrap's Introduction

This is an Ansible playbook to bootstrap a brand new DigitalOcean virtual server.

Tested With Ubuntu LTS 12.04 32bit

Please be aware this playbook is not idempotent at least the part which in charge of droplet creation. So if you run it twice you will get two droplets.

Setup

Just run sudo pip install -r requirements.txt and following packages will be installed

ansible
dopy python module
passlib python module

Ansible 1.6 or higher is required for this playbook, ufw and debconf modules are not available in earlier versions.

Initial configuration

You should know you Client ID and API key from you Digital Ocean account

All configurable variables are in vars.yml file. Mandatory parameters are below

  • DigitalOcean Client ID
  • DigitalOcean API key
  • ssh public key file

Run!

ansible-playbook -i localhost newdroplet.yml

Be aware playbook will change root password you received by email. SSH login for the root user will be disabled as well so use admin user account and sudo instead. All new passwords will be saved into ./credentials/$hostname/$username files.

Playbook is actually doing steps

Droplet

  • deploy ssh keys
  • create droplet

Users and groups

  • configure remote access
    • change default root password - always a good idea, default root password received by email in clear text
    • create admin user profile - it would be a main profile for all operations

Security settings

  • configure sudo -- allow sudo for certain groups of users (administrators)
  • configure ssh
    • create new server ssh keys -- Despite the fact that this is not an issue anymore it seems like good practice for me. The default keys have been created out of my control.
    • restrict sshd settings
      • Restrict ssh login for certain group of users (AllowGroup)
      • Disable root login via ssh (RootLogin no)
      • Password guessing protection (MaxAuthTries, LoginGraceTime, MaxSessions, MaxStartups)
  • enable ufw (firewall)

Software

  • install updates -- it goes without saying
  • configure mail forwarding for admin user -- to keep in touch with my servers
  • fail2ban -- prevent password guessing
  • ntpd is not about security however it's a vps so this thing is essential

Next steps to enhance security (not implemented)

  • Restrict ssh access by IP/network -- this is really good idea for production environment
  • Change default ssh port or enable port knocking -- mitigate massive port scan attempts
  • disable ipv6
  • There are some options /etc/sysctl.conf (coredums and etc)
  • enable mount options for /tmp (noexec, nodev)

ansible-digitalocean-bootstrap's People

Contributors

hostmaster avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.