All Projects → melihovv → initial-webserver-setup

melihovv / initial-webserver-setup

Licence: other
Ansible playbook for initial ubuntu 16.04 webserver setup and Laravel zero time deployment

Programming Languages

Jinja
831 projects

Projects that are alternatives of or similar to initial-webserver-setup

Graylog Ansible Role
Ansible role which installs and configures Graylog
Stars: ✭ 173 (+246%)
Mutual labels:  ansible-playbook, playbook
action-ansible-playbook
⚙️ A GitHub Action for running Ansible playbooks
Stars: ✭ 133 (+166%)
Mutual labels:  ansible-playbook, playbook
swiss-army
Ansible-driven configuration management for maintaining a preferred environment (base system and app dotfiles / configurations)
Stars: ✭ 44 (-12%)
Mutual labels:  ansible-playbook, ansible-roles
RHEL7-CIS
Ansible RHEL 7 - CIS Benchmark Hardening Script
Stars: ✭ 28 (-44%)
Mutual labels:  ansible-playbook, ansible-roles
Upcloud Ansible
Dynamic inventory and modules for managing servers via UpCloud's API
Stars: ✭ 50 (+0%)
Mutual labels:  ansible-playbook, playbook
lykops
lykops是一套web可视化的运维自动化项目,基于python3+django开发的。可视化、简化执行ansible任务,并提供详细的任务执行报告。
Stars: ✭ 129 (+158%)
Mutual labels:  ansible-playbook, ansible-roles
ansible-taskrunner
Ansible Taskrunner - ansible-playbook wrapper with YAML-abstracted python click cli options!
Stars: ✭ 14 (-72%)
Mutual labels:  ansible-playbook, playbook
Terraform Null Ansible
Terraform Module to run ansible playbooks
Stars: ✭ 114 (+128%)
Mutual labels:  ansible-playbook, playbook
Ansible Playbook Grapher
A command line tool to create a graph representing your Ansible playbook tasks and roles
Stars: ✭ 234 (+368%)
Mutual labels:  ansible-playbook, playbook
ansible
Ansible playbook automation for pfelk
Stars: ✭ 23 (-54%)
Mutual labels:  ansible-playbook
nanvault
A standalone CLI tool to encrypt and decrypt files in the Ansible Vault format
Stars: ✭ 33 (-34%)
Mutual labels:  ansible-vault
ans-pve-win-templ
Ansible playbook to create Proxmox Windows VM templates
Stars: ✭ 49 (-2%)
Mutual labels:  ansible-playbook
WebServer
Powershell WebServer is a Powershell module that starts a webserver (without the need for IIS)
Stars: ✭ 27 (-46%)
Mutual labels:  webserver
WebServer
C++高性能网络服务器
Stars: ✭ 53 (+6%)
Mutual labels:  webserver
usegalaxy-playbook
Ansible Playbook for usegalaxy.org
Stars: ✭ 30 (-40%)
Mutual labels:  playbook
arch-ansible
An Ansible playbook to install Arch Linux
Stars: ✭ 33 (-34%)
Mutual labels:  ansible-playbook
catalyst9k-network-automation
Sample python scripts for automation workflows for feature sets present in Catalyst Switching using openly available YANG data models
Stars: ✭ 40 (-20%)
Mutual labels:  ansible-playbook
fcgi-function
A cross-platform module to writing C/C++ service for nginx.
Stars: ✭ 33 (-34%)
Mutual labels:  webserver
keycloak-kubernetes
Keycloak deployment into Kubernetes cluster
Stars: ✭ 25 (-50%)
Mutual labels:  ansible-playbook
offensive-infrastructure
Offensive Infrastructure with Modern Technologies
Stars: ✭ 88 (+76%)
Mutual labels:  ansible-roles

Initial Ubuntu 16.04 Web Server Setup

Ansible playbook to setup web server and playbook to deploy laravel project with zero time.

What initial-setup.yml playbook does

  • install python2 and aptitude
  • upgrade all software
  • create user with sudo rights
  • configure sshd: disables root login and password authentication, also allows to login only user created on previous step

What setup.yml playbook does

  • install
    • git
    • ntp
    • vim
    • tmux
    • htop
    • curl
    • unzip
  • configure automatic security updates (do not reloads server, only installs updates)
  • setup timezone
  • configure iptables and fail2ban
  • create swap file
  • setup ssl certificate with letsencrypt
  • install node.js, npm and yarn
  • install nginx
  • install php and composer
  • install mysql
  • creates following folders structure for zero time deployment:
    • /path/to/domain
      • current -> /link/to/latest/release
      • persistent
        • storage
      • releases
        • 2017-08-10-10-00-00
        • 2017-08-11-10-00-00
        • 2017-08-12-10-00-00

What deploy.yml playbook does

  • clone repository
  • set correct permissions
  • link /path/to/release/storage to /path/to/domain/persistent/storage
  • install composer dependencies
  • link /path/to/release/.env to /path/to/domain/persistent/.env
  • install npm dependencies and generate assets
  • optimize laravel application
  • backup database
  • run new migrations
  • link /path/to/domain/current to /path/to/domain/releases/new-release
  • delete all, but 10 latest releases

If build fails

  • rollback migrations
  • remove new release folder
  • link /path/to/domain/current to /path/to/domain/releases/last-success-release

Install

Inventory file

Create inventory file in project root. You should specify ip address of your server in this file.

[web]
46.101.210.137

Install dependencies

ansible-galaxy install -r requirements.yml

Environment variables

Copy vars/main.yml.example to vars/main.yml and change variable values for your needs. For security reasons you may want to encrypt this file using ansible-vault:

ansible-vault encrypt vars/main.yml

And then edit this file with

ansible-vault edit vars/main.yml

To see all available variables take a look at roles/*/defaults/main.yml. Also visit external roles github page for additional documentation.

To generate password for your user use

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

Nginx and php-fpm configs

  • Site config for nginx place in roles/nginx/templates/yoursite.j2
  • Php-fpm pool config place in roles/php/templates/yoursite.conf.j2
  • Default configs are available in this gist

Initial setup

By default on ubuntu 16.04 there is no python 2 and aptitude. Without those programs ansible cannot work. To fix it run:

ansible-playbook initial-setup.yml

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

Provision server

This playbook setup nginx, php-fpm, mysql, nodejs, etc.

ansible-playbook setup.yml

To run only specific roles

ansible-playbook setup.yml --tags=user,nginx

To exclude specific roles

ansible-playbook setup.yml --skip-tags=user,nginx

Deploy

ansible-playbook deploy.yml

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].