Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vagrant test env #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@

ansible/files/*
__pycache__

.vagrant
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 19 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions ansible/group_vars/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
ansible_ssh_private_key_file: .vagrant/machines/default/virtualbox/private_key
ansible_user: vagrant

2 changes: 2 additions & 0 deletions ansible/inventory/test
Original file line number Diff line number Diff line change
@@ -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