Adding Vagrant test env
Signed-off-by: Alexis Pentori <alexis@status.im>
This commit is contained in:
parent
be8917fe20
commit
739eaaa712
|
@ -7,3 +7,5 @@
|
|||
|
||||
ansible/files/*
|
||||
__pycache__
|
||||
|
||||
.vagrant
|
||||
|
|
23
Makefile
23
Makefile
|
@ -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
|
||||
|
|
26
README.md
26
README.md
|
@ -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.
|
||||
|
|
|
@ -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
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
ansible_ssh_private_key_file: .vagrant/machines/default/virtualbox/private_key
|
||||
ansible_user: vagrant
|
||||
|
|
@ -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
|
Loading…
Reference in New Issue