# Development ## Ubuntu Host Requirements ### Check kvm & virtualbox ```bash sudo kvm-ok sudo apt install -y qemu qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager sudo apt install virtualbox ``` > Or install Virtualbox from https://www.virtualbox.org/wiki/Downloads ### Install vagrant & ansible ```bash sudo apt install ansible wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list sudo apt update && sudo apt install vagrant vagrant plugin install vagrant-hostmanager ansible-galaxy collection install ansible.posix ansible-galaxy collection install community.crypto ansible-galaxy collection install community.general ansible-galaxy collection install community.mysql ``` ## Deploy ```bash vagrant up ``` > In case of "'/var/run/libvirt/libvirt-sock': Permission denied", try to login/logout or restart the machine ## Apply Ansible Once all VMs are up (see 'Deploy'), you can lauch Ansible without Vagrant. Examples: ```bash ansible -v -i '192.168.56.41,' --key-file .vagrant/machines/lb/virtualbox/private_key -u vagrant -b -m setup all ansible-playbook -v -i provisioning/ansible/hosts -u vagrant -b provisioning/ansible/playbook.yml ``` ## Result In your `/etc/hosts` file, add a line to match the dev nextcloud domain (defined in your Vagrantfile), eg "nextcloud.test", to the choosen IP, eg "192.168.56.51". Open a browser with "https://nextcloud.test" ## Validation ### 1 DB - 1 Web - 1 LB Done with: - Apache & mod_php - KeyDB instead of Redis - KeepAlived & HAProxy present but not used OK > TODO: add a switch to choose mod_php or php-FPM for Apache ```Ruby HOSTS = [ { :hostname => "db1", :ip => NETWORK+"11", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_servers" }, { :hostname => "web.test", :ip => NETWORK+"41", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "web_servers", :ipdb => NETWORK+"20", :redis_vip => NETWORK+"40", :priority => 101 }, { :hostname => "lb.test", :ip => NETWORK+"51", :ram => 1024, :cpu => 1, :box => "ubuntu/focal64", :group => "lbal_servers", :state => "MASTER", :priority => 101 }, ] ``` ### 3 DBs galera cluster - 1 Web - 1 LB OK > TODO: install KeepAlived in DB nodes ```Ruby HOSTS = [ { :hostname => "db1", :ip => NETWORK+"11", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_servers" }, { :hostname => "db2", :ip => NETWORK+"12", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_servers" }, { :hostname => "db3", :ip => NETWORK+"13", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_servers" }, { :hostname => "web.test", :ip => NETWORK+"41", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "web_servers", :ipdb => NETWORK+"20", :redis_vip => NETWORK+"40", :priority => 101 }, { :hostname => "lb.test", :ip => NETWORK+"51", :ram => 1024, :cpu => 1, :box => "ubuntu/focal64", :group => "lbal_servers", :state => "MASTER", :priority => 101 }, ] ``` ### 3 DBs galera cluster - 2 ProxySQL - 1 Web - 1 LB OK ```Ruby HOSTS = [ { :hostname => "db1", :ip => NETWORK+"11", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_servers", }, { :hostname => "db2", :ip => NETWORK+"12", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_servers", }, { :hostname => "db3", :ip => NETWORK+"13", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_servers", }, { :hostname => "lbsql1", :ip => NETWORK+"19", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_lbal_servers", :state => "MASTER", :priority => 101, :vip => NETWORK+"20" }, { :hostname => "lbsql2", :ip => NETWORK+"18", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_lbal_servers", :state => "BACKUP", :priority => 100, :vip => NETWORK+"20" }, { :hostname => "web.test", :ip => NETWORK+"41", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "web_servers", :ipdb => NETWORK+"20", :redis_vip => NETWORK+"40", :priority => 101 }, { :hostname => "lb.test", :ip => NETWORK+"51", :ram => 1024, :cpu => 1, :box => "ubuntu/focal64", :group => "lbal_servers", :state => "MASTER", :priority => 101 }, ] ``` ### 1 DB - 2 GL - 2 Web - 2 LB TODO Done with: - Apache & mod_php - KeyDB instead of Redis - KeepAlived & HAProxy present but not used ```Ruby HOSTS = [ { :hostname => "db1", :ip => NETWORK+"11", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "db_servers", }, { :hostname => "gl1", :ip => NETWORK+"31", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "gluster_servers" }, { :hostname => "gl2", :ip => NETWORK+"32", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "gluster_servers" }, { :hostname => "web.test", :ip => NETWORK+"41", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "web_servers", :ipdb => NETWORK+"20", :redis_vip => NETWORK+"40", :priority => 101 }, { :hostname => "web2.test", :ip => NETWORK+"42", :ram => 1024, :cpu => 1, :box => "centos/7", :group => "web_servers", :ipdb => NETWORK+"20", :redis_vip => NETWORK+"40", :priority => 100 }, { :hostname => "lb.test", :ip => NETWORK+"51", :ram => 1024, :cpu => 1, :box => "ubuntu/focal64", :group => "lbal_servers", :state => "MASTER", :priority => 101 }, { :hostname => "lb2.test", :ip => NETWORK+"52", :ram => 512, :cpu => 1, :box => "ubuntu/focal64", :group => "lbal_servers", :state => "BACKUP", :priority => 100 }, ] ``` ### 3 DB galera cluster - 2 ProxySQL - 2 GL - 2 Web - 2 LB TODO ```Ruby HOSTS = [ ] ```