Recipes to set up the infrastructure for the CGUs app and deploy it.
Recettes pour mettre en place l'infrastructure et déployer l'application CGUs
- Install Ansible
To test the changes without impacting the production server, a Vagrantfile is provided to test the changes locally in a virtual machine. VirtualBox and Vagrant are therefore required.
- Install VirtualBox
- Install Vagrant
To avoid making changes on the production server by mistake, by default all commands will only affect the Vagrant development virtual machine (VM). Note that the VM needs to be started before with vagrant up
.
To execute commands on the production server you should specify it by adding the option --inventory ops/inventories/production.yml
to the following commands:
- To setup a full (phoenix) server:
ansible-playbook ops/site.yml
- To setup infrastructure only:
ansible-playbook ops/infra.yml
- To setup
CGUs
app only:
ansible-playbook ops/app.yml
Some useful options can be used to:
- see what changed with
--diff
- simulate execution with
--check
- see what will be changed with
--check --diff
Some tags are available to refine what will happen, use them with --tags
:
setup
: to only setup system dependencies required by the app (cloning repo, installing app dependencies, all config files, and so on…)start
: to start the appstop
: to stop the apprestart
: to restart the appupdate
: to update the app (pull code, install dependencies and restart app)
For example, you can update CGUs
by running:
ansible-playbook ops/app.yml --tags update
If you have the following error:
Failed to connect to the host via ssh: ssh: connect to host 127.0.0.1 port 2222: Connection refused
You may have a collision on the default port 2222
used by vagrant to forward ssh commands.
Run the following command to know which ports are forwarded for the virtual machine:
vagrant port
It should display something like that:
The forwarded ports for the machine are listed below. Please note that
these values may differ from values configured in the Vagrantfile if the
provider supports automatic port collision detection and resolution.
22 (guest) => 2200 (host)
Modify ansible ssh options to the ops/inventories/dev.yml
file with the proper ansible_ssh_port
:
all:
children:
dev:
hosts:
'127.0.0.1':
[…]
ansible_ssh_port: 2200
[…]