/ansible-react-node

ansible playbook to automate configuration of aws ec2 instance hosting a reactjs web application

Primary LanguageJinja

ansible-react-node

summary

This Ansible playbook is designed to set up a a react-js web application. The playbook performs the following tasks:

Installs Node, PM2, nginx, curl, open ports for communications and test backend service once started
Includes secret variables from a separate file
Starts the backend Node.js application using PM2, specifying the entry point (./server/app.js) and setting the environment variables NODE_ENV, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY.
Starts the React frontend application using nginx

Ensure there is a vars directory in the project directory and contains the vault secret for the AWS credentials, and a password file for the ansible vault secret file that is generated by: ansible-vault create ${SECRET_NAME.YAML}. Also a vars_file.yml that contains all the variables to be injected into the ninja2 template of the ansible playbook.

To run the playbook:

ansible-playbook -i ${INVENTORY_FILE.ini} webapp_config_playbook.yml --vault-password-file=vars/${VAULT_PASSWORD_FILE}.txt