Skip to content

Ansible playbook for initial ubuntu 16.04 server setup

Notifications You must be signed in to change notification settings

melihovv/initial-server-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Initial Ubuntu 16.04 Server Setup

What this playbook does

  • installs python2 and aptitude
  • upgrades all software
  • creates user with sudo rights
  • configures sshd: disables root login and password authentication, also allows to login only user created on prev step
  • installs
    • git
    • ntp
    • vim
    • tmux
    • htop
    • curl
  • configures automatic security updates (do not reloads server, only installs updates)
  • setups timezone
  • configures iptables and fail2ban
  • create swap file

inventory file

Create inventory file. Its content is something like this

[web]
46.101.210.137

Install deps

ansible-galaxy install -r requirements.yml

Initial setup

By default on ubuntu 16.04 there is no python 2 and aptitude. To fix it run:

ansible-playbook initial-setup.yml

Beside it this playbook also creates user and configures ssh server.

Environment variables

Copy vars/main.yml.example to vars/main.yml and change variable values for your needs.

To generate password use

sudo apt-get install -y whois
mkpasswd --method=SHA-512

Run

ansible-playbook main.yml

To run only specific roles

ansible-playbook main.yml --roles=user