New repo link: https://github.com/i9or/blog -> infra
folder.
Some fancy scripts and yamls for my blog infrastructure... gosh just use docker already, Jesus.
ansible
v2.12+
Key generation:
ssh-keygen -t ed25519 -C "user@example.com" -f ./keys/production_key
ssh-keygen -t ed25519 -C "user@example.com" -f ./keys/staging_key
Key naming:
production_key
— SSH key for productiondeploy
userstaging_key
— SSH key for stagingdeploy
user
Note: ./keys/
folder should be added to .gitignore
!
Some steps are still manual, host that needs to be provisioned have to have deploy
user.
To provision staging environment:
ansible-playbook staging-provision.yml
Another manual step is to run pm2 startup
command and follow its instruction.
The same goes for production environment, but production-provision.yml
playbook needs to be used.
Sometimes PM2 doesn't start services with new environment variables. Command below forces PM2 to update environment variables to the latest version:
ansible staging -a "pm2 restart all -a"