Adding Vagrant test env

Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
Alexis Pentori 2023-06-27 09:40:41 +02:00
parent be8917fe20
commit 739eaaa712
No known key found for this signature in database
GPG Key ID: 65250D2801E47A10
6 changed files with 76 additions and 0 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@
ansible/files/*
__pycache__
.vagrant

View File

@ -46,3 +46,26 @@ init-terraform:
cleanup:
rm -r $(TF_PLUGINS_DIR)/$(ARCHIVE)
init-test-env:
vagrant up
# Warning : this add a test key into the admin
ssh-keygen -y -f .vagrant/machines/default/virtualbox/private_key >> $(HOME)/.ansible/roles/infra-role-bootstrap-linux/files/keys/admin.pub
ansible-playbook ansible/bootstrap.yml \
--inventory ansible/inventory/test \
--extra-vars '@ansible/group_vars/test.yml' \
--tags role::bootstrap:packages,role::bootstrap:docker,role::bootstrap:firewall,role::bootstrap:users,role::bootstrap:logging
test-run-upgrade:
ansible-playbook ansible/upgrade.yml \
--inventory ansible/inventory/test \
--extra-vars '@ansible/group_vars/test.yml'
clean-test-env:
vagrant destroy
rm -r .vagrant
test: init-test-env test-run-upgrade clean-test-env

View File

@ -21,3 +21,29 @@
# Repo Usage
For how to use this repo read the [Infra Repo Usage](https://github.com/status-im/infra-docs/blob/master/docs/general/infra_repo_usage.md) doc.
# Test
## Prerequisites
To run the test environement, you need to have installed
* [vagrant](https://www.vagrantup.com/)
* [VirtualBox](https://www.virtualbox.org/)
> **Note**: It's opssible to use another virtualization hypervisor, in that case, you need to modify the Vagrantfile accordingly.
## Launch
The command ``make test`` will launch the following actions:
* `init-test-env` : Create the VM, add the user ssh public key into the `admin.pub` file of `infra-role-bootstrap-linux`, run the linux bootstraping of the VM (tags for `packages`, `role`, `docker`, `firewall`, `user`, `logging`)
* `test-run-upgrade`: Example of plabook to run
* `clean-text-env`: Delete the VM, and remove the `.vagrant` directory.
## Adapt to project
* Modify the `ansible/inventory/test` to add host group matching the playbook you want to run.
* Add function in the Makefile for each playbook you want to run.
> **Warning**: The test VM doesn't not install consul on the host, some part of the playbook might failed. Use tags to specify witch role to execute.

19
Vagrantfile vendored Normal file
View File

@ -0,0 +1,19 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
# Resource configuration
config.vm.provider "virtualbox" do |v|
v.memory=4096
v.cpus= 2
end
# Networking
# config.vm.define "vm" do |vm|
# vm.vm.hostname="test-node"
# end
end

View File

@ -0,0 +1,4 @@
---
ansible_ssh_private_key_file: .vagrant/machines/default/virtualbox/private_key
ansible_user: vagrant

2
ansible/inventory/test Normal file
View File

@ -0,0 +1,2 @@
[all]
test hostname=localhost ansible_host=127.0.0.1 ansible_port=2222 env=test stage=test data_center=test region=test dns_entry=test.statusim.net