Skip to content

Commit

Permalink
Update docs and add check for deprecated var.
Browse files Browse the repository at this point in the history
  • Loading branch information
Donald Morton committed Jul 24, 2020
1 parent 52bb6c4 commit bbf3931
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,6 @@ dmypy.json

# Cython debug symbols
cython_debug/

# Vagrant
.vagrant/
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,59 @@ have to install all dependencies even when they are disabled to prevent errors.
Tests
-----

If you'd like to test the role out using our test suite, you'll need a few things installed:
If you'd like to run the Molecule tests, you'll need a few things installed:

- [Vagrant](https://www.vagrantup.com/docs/installation)
- [libvirt](https://github.com/vagrant-libvirt/vagrant-libvirt)
- [Molecule](https://molecule.readthedocs.io/en/latest/installation.html)
- [testinfra](https://testinfra.readthedocs.io/en/latest/)

Note that this is ONLY required if you want to run the test harness. You don't need any of this to run the playbook. This is a special setup that allows you to test the Ansible playbook against disposable VMs.

#### Install Notes

Setting up Molecule requires installing a number tools for the VM enviroment. The following are notes from a successful install on Ubuntu 20.04.

Install Virtualenv, Molecule, and testharness

sudo apt-get update
sudo apt-get install -y python3-pip libssl-dev python3-virtualenv
source venv/bin/activate
python3 -m pip install "molecule[lint]"
pip3 install testinfra

Install Vagrant and libvirt

sudo apt-get install -y bridge-utils dnsmasq-base ebtables libvirt-bin libvirt-dev qemu-kvm qemu-utils ruby-dev
sudo wget -nv https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb
sudo dpkg -i vagrant_2.2.9_x86_64.deb
vagrant --version
sudo apt-get install ruby-libvirt qemu libvirt-daemon-system libvirt-clients ebtables
sudo apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
vagrant plugin install vagrant-libvirt
vagrant plugin list
pip3 install python-vagrant molecule-vagrant

Test that Vagrant works

vagrant init generic/ubuntu1804
vagrant up --provider=libvirt
vagrant ssh
vagrant halt

Test that Molecule works

git clone https://github.com/Graylog2/graylog-ansible-role.git
cd graylog-ansible-role
molecule create
molecule converge
molecule login
systemctl status graylog-server
exit
molecule destroy

#### Commands

To spin up a test VM:

export MOLECULE_DISTRO='generic/ubuntu1804'
Expand Down
5 changes: 5 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
when: item not in vars
with_items: "{{ required_vars }}"

- name: "Check deprecated variables"
fail:
msg: "Varible 'graylog_server_version' has been deprecated. Use 'graylog_full_version' instead."
when: graylog_server_version is defined

- name: "Load OS-family specific vars"
include_vars: "{{ ansible_os_family }}.yml"

Expand Down

0 comments on commit bbf3931

Please sign in to comment.