diff --git a/.gitmodules b/.gitmodules index 1226ba308c0c5af4005da3adc87cadd9d481ac75..688e2be1897f22de596e5bc000e949236a6fe30e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,7 @@ [submodule "www/static/pi-billion"] path = www/static/pi-billion url = https://git.laquadrature.net/lqdn-interne/pi-billion.git +[submodule "ansible/don-lqdn"] + path = ansible/don-lqdn + url = https://git.laquadrature.net/lqdn-interne/piops-roles/don-lqdn + branch = main diff --git a/Makefile b/Makefile index b6e2ce912578cb38f2b1c40ac4d8ba5e8e517ad9..4deb0b5fc3c9ea406c8b54de31e12c8d517d0e98 100644 --- a/Makefile +++ b/Makefile @@ -67,12 +67,12 @@ coverage: ## Launch functional tests with coverage. @./vendor/bin/codecept run functional --coverage-html server-start: server-stop ## Launch a local server - @php -S 127.0.0.1:8000 -t ./www/ >> ./log/server.log & - @echo "\033[32mServer running. (http://127.0.0.1:8000)\033[0m" + @php -S 0.0.0.0:8000 -t ./www/ >> ./log/server.log & + @echo "\033[32mServer running. (http://0.0.0.0:8000)\033[0m" server-stop: ## Stop local server if running - -@ps -aux | grep "[p]hp -S 127.0.0.1:8000" | grep -v grep | awk '{print $$2}' | xargs -r -n 1 kill - @echo "\033[32mServer stopped. (http://127.0.0.1:8000)\033[0m" + -@ps -aux | grep "[p]hp -S 0.0.0.0:8000" | grep -v grep | awk '{print $$2}' | xargs -r -n 1 kill + @echo "\033[32mServer stopped. (http://0.0.0.0:8000)\033[0m" cs-fix: ## Fix CS @vendor/bin/php-cs-fixer fix diff --git a/README.md b/README.md index f911807dbdd0a01de51b6899432021d2b0315105..ca2ec91dc1d9ed477411ca3eab468d62acd954c0 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,22 @@ This is a php application based on Fat-Free-Framework and a MySQL database that It's used as our primary donation platform, and uses our bank's payment system (cheaper) to get one-time or recurring payments recorded into the donation platform. +## Environnement de test + +Afin de faciliter la réalisation de tests, vous pouvez utiliser Vagrant et Ansible à travers le rôle `don-lqdn`. + +Pour la mise en place ; + +- Mise en place de la machine virtuelle ; téléchargement d'une machine virtuelle Debian. + - `$ vagrant up` +- Installation du site de don ; Installation du rôle don-lqdn dans la machine virtuelle + - `$ vagrant provision` +- Vous pouvez maintenant voir le site de don sur `http://localhost:8000/`. + +Les modifications faites dans ce dossier sont reportés directement dans la machine virtuelle, dans son dossier `/vagrant`. + +Vous pouvez modifier ceci en éditant le fichier `Vagrantfile` et les fichiers dans le dossier `ansible/`. + ## Installation (quick) In order to install this project, run `make doctor` to check that everything is fine. @@ -45,9 +61,9 @@ and for developers you may also need : This software uses: * **PHP7.3** -* **phinx** to inject database schema and initial data / accounts into MySQL see https://phinx.org/ +* **phinx** to inject database schema and initial data / accounts into MySQL see https://phinx.org/ * **php-cs-fixer** to check php code for errors and fix coding standard issues, see https://github.com/FriendsOfPHP/PHP-CS-Fixer -* **doctrine/dbal** as ORM see https://github.com/doctrine/dbal +* **doctrine/dbal** as ORM see https://github.com/doctrine/dbal * **f3 framework** as main view / controller framework. see https://fatfreeframework.com/ Look at `app/` folder for most Controllers, and `app/routes.ini` for the application routes (the URLs) @@ -56,7 +72,7 @@ Look at `app/` folder for most Controllers, and `app/routes.ini` for the applica * `app/env` must contains the proper values : database connection, bank visa payment codes, and ENV=production at the bottom. * point your Nginx or Apache with PHP5.6 to the `www/` folder, and either allow Rewrite Rules (a2enmod rewrite) or point every URL not being a file to index.php (see below for an nginx sample) -* use AND FORCE https usage, it's 2018, people ;) +* use AND FORCE https usage, it's 2018, people ;) Nginx configuration sample: @@ -71,5 +87,3 @@ location / { try_files $uri /index.php$is_args$args; } ``` - - diff --git a/Vagrantfile b/Vagrantfile index 6a8dae937c562a07fcf51e22e4b93115b38ab892..671d3157089c691f2c20203bcb3cc3a09c7d54ce 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -14,6 +14,8 @@ Vagrant.configure("2") do |config| # boxes at https://vagrantcloud.com/search. config.vm.box = "debian/bullseye64" + config.vm.define "don-debian64" + # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated`. This is not recommended. @@ -23,16 +25,17 @@ Vagrant.configure("2") do |config| # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # NOTE: This will enable public access to the opened port - config.vm.network "forwarded_port", guest: 8000, host: 8383 + # config.vm.network "forwarded_port", guest: 80, host: 3141 + # config.vm.network "forwarded_port", guest: 8000, host: 3141 # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine and only allow access # via 127.0.0.1 to disable public access - # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" + config.vm.network "forwarded_port", guest: 8000, host: 8282, host_ip: "127.0.0.1" # Create a private network, which allows host-only access to the machine # using a specific IP. - config.vm.network "private_network", ip: "192.168.56.1" + # config.vm.network "private_network", ip: "192.168.56.42" # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on @@ -43,28 +46,15 @@ Vagrant.configure("2") do |config| # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = true - # - # # Customize the amount of memory on the VM: - # vb.memory = "1024" - # end - # - # View the documentation for the provider you are using for more - # information on available options. + # Si vous voulez avoir la possibilité de faire des modifications directement + # dans le dossier local, et voir les modifications sans avoir besoin de faire + # `vagrant provision`, vous pouvez décommenter la ligne ci-dessous avant de + # faire `vagrant up && vagrant provision`. + + # config.vm.synced_folder "./", "/home/don/don" - # Enable provisioning with a shell script. Additional provisioners such as - # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the - # documentation for more information about their specific syntax and use. - # config.vm.provision "shell", inline: <<-SHELL - # apt-get update - # apt-get install -y apache2 - # SHELL + config.vm.provision "ansible" do |ansible| + ansible.playbook = "ansible/playbook.yml" + end end diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9592696ffe54c809d6c8526a06e4860e8f836885 --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,56 @@ +# Fichier de configuration pour Ansible dans l'infrastructure de LQDN. + +# Pour voir toutes les options, lancez `ansible-config list` ou la +# documentation: https://docs.ansible.com/ansible/latest/reference_appendices/config.html. + +[defaults] + +inventory = inventory.yml +log_path = ansible-run-lqdn.log +interpreter_python = auto_silent +roles_path = roles/ + +# Rajoute cette ligne aux fichiers de configuration géré par Ansible. +ansible_managed = "⚠ Ce fichier est géré par Ansible, ne pas modifier à la main ! - Responsables : Équipe Technique de La Quadrature Du Net" + + +# Configuration de l'affichage des playbooks +stdout_callback = yaml + +# Ansible va nous prévenir si des commandes peuvent être remplacé +# par des modules ansible. +command_warnings = True + +# Meuuuh 🐮 +nocows = 0 + + +[inventory] + +# R.A.S + +[privilege_escalation] +become = False +become_method = sudo + +[colors] +highlight = white +verbose = blue +warn = bright purple +error = red +debug = dark gray +deprecate = purple +skip = cyan +unreachable = red +ok = green +changed = yellow +diff_add = green +diff_remove = red +diff_lines = cyan + + +[diff] +# Montre les différences, comme en utilisant -D/--diff +always = True +# Combien de lignes de contexte +context = 2 diff --git a/ansible/configuration.test.yml b/ansible/configuration.test.yml new file mode 100644 index 0000000000000000000000000000000000000000..6c5bf1e71a7a3ad5d4508e83fdbe4236f9383e98 --- /dev/null +++ b/ansible/configuration.test.yml @@ -0,0 +1,6 @@ +# Ce fichier contient les variables de configuration de l'environment de test +# du site de don. + +# Si certaines variables ne sont pas mentionnées ici, c'est qu'elles ont +# été assignées leurs valeurs par défaut, présentes dans le rôle don-lqdn sous +# defaults/main.yml ou vars/main.yml diff --git a/ansible/don-lqdn b/ansible/don-lqdn new file mode 160000 index 0000000000000000000000000000000000000000..c046ebd9797833fb546af4462812ac3466f5439c --- /dev/null +++ b/ansible/don-lqdn @@ -0,0 +1 @@ +Subproject commit c046ebd9797833fb546af4462812ac3466f5439c diff --git a/ansible/playbook.yml b/ansible/playbook.yml new file mode 100644 index 0000000000000000000000000000000000000000..ebf8b57c310152c382856b0fd1c4f7a1f0404b74 --- /dev/null +++ b/ansible/playbook.yml @@ -0,0 +1,15 @@ +# Example de playbook permettant d'installer le site de don. + +# Ce playbook peut à la fois être utilisé pour l'installation en production du +# site de don, mais aussi mettre en place le site de don dans un environment de +# test grâce à Vagrant. + +- name: Installation du site de don dans l'environment de test + hosts: don-debian64 + become: yes + # become_user: root + remote_user: root + vars_files: + - configuration.test.yml + roles: + - don-lqdn