Skip to content

🚚 Useful Ansible playbooks for easily deploy your website or webapp to absolutely fresh remote virtual server and automation many processes. Only 3 minutes from the playbook run to complete setup server and start it.

License

Notifications You must be signed in to change notification settings

koddr/useful-playbooks

Repository files navigation

🚚 Useful playbooks for easily deploy

logo

Useful Ansible playbooks for easily deploy your website or webapp to absolutely fresh virtual server (VDS/VPS or Droplet) launched on GNU/Linux. Only 3 minutes from the playbook run to complete setup server and start it. There you go! It just works.

⚑️ Quick start

  1. Download ZIP archive or git clone this repository.
  2. Go to the downloaded or cloned folder.
  3. Select a playbook (see Available playbooks section).
  4. Run <playbook_name> with (or without) arguments and extra vars:
ansible-playbook <playbook_name>-playbook.yml [args] [extra vars...]
  1. Enjoy! 😎

πŸ“š Available playbooks

  • πŸ“– new_server for auto configure a fresh remote virtual server
  • πŸ“– install_brotli for install Brotli module to Nginx
  • πŸ“– create_ssl for create a new website with SSL certificate from Let's Encrypt
  • πŸ“– github_backup for a backup automation of your GitHub accounts (repositories, gists, organizations)

πŸ’‘ Required information about Ansible

πŸ€” What is Ansible?

Follow Wikipedia page:

ansible logo

Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows. It includes its own declarative language to describe system configuration.

Ansible was written by Michael DeHaan and acquired by Red Hat in 2015. Ansible is agentless, temporarily connecting remotely via SSH or Windows Remote Management (allowing remote PowerShell execution) to do its tasks.

πŸ‘€ Why it's so good to use for me?

Ansible is a radically simple IT automation system. It handles configuration management, application deployment, cloud provisioning, ad-hoc task execution, network automation, and multi-node orchestration. Ansible makes complex changes like zero-downtime rolling updates with load balancers easy.

  • Have a dead simple setup process and a minimal learning curve.
  • Manage machines very quickly and in parallel.
  • Avoid custom-agents and additional open ports, be agentless by leveraging the existing SSH daemon.
  • Describe infrastructure in a language that is both machine and human friendly.
  • Focus on security and easy auditability/review/rewriting of content.
  • Manage new remote machines instantly, without bootstrapping any software.
  • Allow module development in any dynamic language, not just Python.
  • Be usable as non-root.
  • Be the easiest IT automation system to use, ever.

:octocat: GitHub: https://github.com/ansible/ansible

🎯 How to work with Ansible and playbooks?
  1. Be sure, that Python (version 3.5 or later) is installed.
  2. Install Ansible for your OS by this instructions.
  3. Setting up inventory by this guide.
βœ… Helpful hints, tools and plugins for working with Ansible

VS Code addons:

  • vscode-ansible for code completion, syntax highlighting and linting of Ansible playbooks files
  • vscode-nginx for syntax highlighting of Nginx configs

VS Code config hints:

For better readability, please add two association to your .vscode/settings.json:

  1. For Ansible playbooks
  2. For jinja2 templates (which uses for Nginx configs)
{
  // ...
  "files.associations": {
    // ...
    "*-domain.j*2": "NGINX", // for all jinja2 files ended with `domain` word
    "*playbook.y*ml": "ansible" // for YAML files ended with `playbook` word
  }
  // ...
}

Beautify Ansible outputs:

Since Ansible v2.5.x, you can enable beautify output by callback_plugins and auto convert this one line output:

TASK [Get SSL for domain] *******************************
fatal: [***]: FAILED! => {"changed": true, "cmd": ["certbot", "--nginx", "certonly", "--agree-tos", "-m", "[email protected]", "-d", "example.com", "-d", "www.example.com", "--dry-run"], "delta": "***", "end": "***", "msg": "non-zero return code", "rc": 1, "start": "***", "stderr": "..." ...

To awesome structured, like this:

TASK [Get SSL for domain] *******************************
fatal: [***]: FAILED! => changed=true
  cmd:
  - certbot
  - --nginx
  - certonly
  - --agree-tos
  - -m
  - [email protected]
  - -d
  - example.com
  - -d
  - www.example.com
  - --dry-run
  delta: '***'
  end: '***'
  msg: non-zero return code
  rc: 1
  start: '***'
  stderr: ...
  ...

To use it, please, edit the [defaults] section in your Ansible config file (/etc/ansible/ansible.cfg):

[defaults]
stdout_callback = yaml       # Use the YAML callback plugin
bin_ansible_callbacks = True # Use the stdout_callback when running ad-hoc commands

πŸ“Ί Media

A list of articles and video lessons, where useful-playbooks is used:

Make pull request with links to your articles and videos! We will post them right here.

⭐️ Project assistance

If you want to say thank you or/and support active development useful-playbooks:

  1. Add a :octocat: GitHub Star to the project.
  2. Twit about project on your Twitter.
  3. Donate some money to project author via PayPal: @paypal.me/koddr.
  4. Join DigitalOcean at our referral link (your profit is $100 and we get $25).
  5. Buy awesome domain name with 5% discount at REG.COM.

Thanks for your support! 😘 Together, we make this project better every day.

⚠️ License

MIT Β© Vic ShΓ³stak & True web artisans.