Open gudrutis opened 3 years ago
When you run the test script it will create tests/test.yml
where all apps, including Heimdall are disabled, so running vagrant up
will not have any of the apps running. But now you can edit tests/test.yml
and set heimdall_enabled: true
(and more apps) in tests/test.yml
. Then run vagrant provision
and Heimdall will be reachable on http://172.30.1.5:10080/
steps to my success.
sudo apt install vagrant
sudo apt install VirtualBox
git clone https://github.com/davestephens/ansible-nas.git
cd ansible-nas
./tests/test.sh # This generates tests/test.yml. This is what you will be changing to update the test environment.
./tests/test-vagrant.sh -vvv # For some reason the vm never starts unless I add -vvv but its okay cause I like watching it anyways.
nano tests/test.yml
vagrant provision
I'm sure with the transitioning applications to roles that some of the testing scripts will need to be reworked.
@PurpleNinja225 - thanks for the help, your instructions were informative.
A couple of items I uncovered in getting testing to work.
First, the Vagrant box ubuntu/bionic64
as referenced in the Vagrantfile only works with VirtualBox. See https://www.vagrantup.com/docs/boxes, bottom of the page:
It is often a point of confusion, but Canonical (the company that makes the Ubuntu operating system) publishes boxes under the "ubuntu" namespace on Vagrant Cloud. These boxes only support VirtualBox and do not provide an ideal experience for most users. If you encounter issues with these boxes, please try the Bento boxes instead.
Second, I ran tests/test.sh
and it failed as well (see below). This means the tests/test.yml
file was not generated. Moreover, I didn't realize that I needed to provide a tests/test.yml
. Oops.
Third, I was unable to get the tests/test.sh
Docker-based test to work due to the lack of an up-to-date package cache, i.e. apt update
, on the base image. This caused the first required role to fail; bertvv.samba
was not able to install samba-common
.
Lastly, and this is particular to my development environment, I have been developing remotely (on my home lab), and using the private_network
option in Vagrant meant I couldn't reach the exposed UIs directly, so I ended up adding an "overlay" Vagrantfile in ~/.vagrant.d/Vagrantfile
with an appropriate config.vm.network "forwarded_port"
configuration for the app under test. Not sure if there is a better way.
I am struggling too with the testing scripts, I will post updates on my findings:
@wmudge to fix the samba issue, I added this line in the nas.yml
file
- name: update apt packages
apt:
update_cache: true
right under the first
- import_tasks: tasks/users.yml
tags: users
The inventory
file in tests/inventories/integration_testing
seems to be wrong, as the hostname defined in it is ansible-nas
instead of ansible-nas-test
. Renaming the hostnames in there manages to start a proper vagrant provision
task on a running ansible-nas-test
(or properly runs the test-vagrant.sh
script`
test.sh
requires a nas.yml
playbook by default, but the docstring on top mentions a test.yml
playbook. Make sure to specify your actual playbook filename by using an env var (playbook=your_playbook_name.yml ./tests/test.sh
). test-vagrant.sh
requires a nas.yml
playbook, as specified in the Vagrantfile
. At this point you may as well just create a nas.yml
playbook and use it for both tests
The first proper vagrant provision (for which I only enabled heimdall) failed, but running it another time managed to get it running.
I also have problems running the test scripts.
Running test.sh
gives me the following error:
latest: Pulling from geerlingguy/docker-ubuntu2004-ansible Digest: sha256:e5e35a791bd56c3fe14969400b6380df2a6c6e4b11a3852f9608f38afab1f974 Status: Image is up to date for geerlingguy/docker-ubuntu2004-ansible:latest docker.io/geerlingguy/docker-ubuntu2004-ansible:latest 3e3da8884af64517fffbdf58b7ee12289baa514ab79f395dc447d95a4a1e5bef
Checking Ansible version. Error response from daemon: Container 3e3da8884af64517fffbdf58b7ee12289baa514ab79f395dc447d95a4a1e5bef is not running
When running the test-vagrant.sh
I have to add -vvv
to see the following error:
There was an error while executing
VBoxManage
, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.Command: ["startvm", "69565524-823a-4db9-ba75-6d2645938876", "--type", "headless"]
Stderr: VBoxManage.exe: error: RawFile#0 failed to create the raw output file /mnt/c/Users/xxx/Desktop/ansible-nas/tests/ubuntu-bionic-18.04-cloudimg-console.log (VERR_PATH_NOT_FOUND) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole
To fix this i added the following to my Vagrantfile
config.vm.provider "virtualbox" do |vb|
vb.customize [ "modifyvm", :id, "--uart1", "off" ]
vb.customize [ "modifyvm", :id, "--uart2", "off" ]
vb.customize [ "modifyvm", :id, "--uart3", "off" ]
vb.customize [ "modifyvm", :id, "--uart4", "off" ]
end
steps to my success.
sudo apt install vagrant sudo apt install VirtualBox git clone https://github.com/davestephens/ansible-nas.git cd ansible-nas ./tests/test.sh # This generates tests/test.yml. This is what you will be changing to update the test environment. ./tests/test-vagrant.sh -vvv # For some reason the vm never starts unless I add -vvv but its okay cause I like watching it anyways. nano tests/test.yml vagrant provision
I'm sure with the transitioning applications to roles that some of the testing scripts will need to be reworked.
Your steps should be documented on the 'website' because the old link to david stephens .uk page is now redirected but not found... The website does not clearly state how to test. It's a nice process to get it slowly going and learning by trial and error, but still would be nice to have it clearly documented
Describe the bug I was following this tutorial ( https://davidstephens.uk/ansible-nas/testing/ ) to check out the Ansible-NAS. I was expecting to access Heimdall on http://172.30.1.5:10080 after running or
test-vagrant.sh
. That did not happen.Also, as an added bonus, running
test.sh
gaveERROR! the playbook: /etc/ansible/playbooks/playbook_under_test/nas.yml could not be found
. Not sure if that was supposed to happen.Expected behavior To be able to reach Heimdall on http://172.30.1.5:10080 after running or
test-vagrant.sh
Actual behavior after running the script, I get this output
However, when I check VirtualBox dashboard, I see that the actual VM is not actually running or even created. I have to separately run
vagrant up
to actually spin the VM. Still, after this, the address is still not reachable.Steps to reproduce On ubuntu 20.04 machine they should execute:
Additional context New user, just looking for a fast way to spin up a demo instance.