A simple collection of roles and standard playbooks for deploying a common deployment / front application stack. These are mostly for PHP / Node + Caddy infrastructures, with MariaDB and Mongo database engines.
NB : the default inventory file location is
/etc/ansible/hostson Linux, and/usr/local/etc/ansible/hostson macOS You should include the ansible user to use when loging in, as so:
[frontend_server]
my.frontend.server.com ansible_user=ubuntu
my.other.frontend.server.com ansible_user=ubuntu
NB : We use the following groups
[frontend_node],[frontend_php]in the playbooks.
- 
- Ensures that the server has at least some basics tools like 
sudoandpython-aptfor Ansible to run correctly. - Updates and upgrades 
apt 
 - Ensures that the server has at least some basics tools like 
 - 
- Ensures a /var/backups/rolling folder is present
 - Creates a DB + files backup script
 - Creates a cron task for daily backups and uploads the backup somewhere safe (on a S3 compatible endpoint)
 
 
NB: You need to copy the
roles/backup/files/credentials.distfile toroles/backup/files/credentialsand put your provider credentials there. You might want to change theregiontoo inroles/backup/files/configif needed.
- 
Ensures that
caddy, is installed correctly and runs as a service. - 
Ensures that
mongo-orgis the lastest and that the service is runnning correctly. - 
Ensures that
node,npmare installed correctly. - 
Ensures that
maria_dbis the lastest and that the service is runnning correctly. Adds a consistent/root/.my.cnffile for logging in. - 
Installs postfix along with mlmmj using the configured MX domain. For more info on Mlmmj see this blog post
 - 
Ensures that
nginxis the lastest and that the service is runnning correctly. Also uploads a secured configuration fornginx. - 
Installs
php7.4FPM and command line interface with a few standard modules, a sensible configuration file for cli and FPM, and thecomposerpackage manager. - 
Ensures that
yarnis installed correctly. 
The playbooks are rather straightforward.
Before deploying a new server, you must make sure that your user has sudo rights, and that your SSH key is authorized for a password-less login
This done, when deploying a new nodeJS server for instance (on macOS):
ansible-playbook --inventory=/usr/local/etc/ansible/hosts playbooks/frontend_node.yml
This role is kind of "standalone". To use it, just play the mlmmj playbook alone, to install node and mlmmj in one go:
ansible-playbook --inventory=/usr/local/etc/ansible/hosts  playbooks/mlmmj.yml
If you want to execute a single shell command :
# Gets the speed of each cpu 
ansible all -m shell -a "cat /proc/cpuinfo | grep MHz"
These roles and playbooks are released under the MIT licence. Enjoy !!