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.
- Download ZIP archive or
git clone
this repository. - Go to the downloaded or cloned folder.
- Select a playbook (see
Available playbooks
section). - Run
<playbook_name>
with (or without) arguments and extra vars:
ansible-playbook <playbook_name>-playbook.yml [args] [extra vars...]
- Enjoy! π
- π
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)
π€ What is Ansible?
Follow Wikipedia page:
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.
π― How to work with Ansible and playbooks?
β 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
:
- For
Ansible
playbooks - For
jinja2
templates (which uses forNginx
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
A list of articles and video lessons, where useful-playbooks
is used:
- βοΈ How to install Brotli module for Nginx on Ubuntu 20.04+ @ 27 Jun 2020
- β¨ A practical guide to GitHub Actions: build & deploy a static 11ty website to remote virtual server after push @ 01 Jun 2020
- βοΈ Let's automate a backup process of your GitHub accounts, organizations & repositories @ 21 July 2020
Make pull request with links to your articles and videos! We will post them right here.
If you want to say thank you or/and support active development useful-playbooks
:
- Add a GitHub Star to the project.
- Twit about project on your Twitter.
- Donate some money to project author via PayPal: @paypal.me/koddr.
- Join DigitalOcean at our referral link (your profit is $100 and we get $25).
- Buy awesome domain name with 5% discount at REG.COM.
Thanks for your support! π Together, we make this project better every day.
MIT Β© Vic ShΓ³stak & True web artisans.