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

Testing scripts do not work #369

Open
gudrutis opened this issue Dec 23, 2020 · 6 comments
Open

Testing scripts do not work #369

gudrutis opened this issue Dec 23, 2020 · 6 comments
Labels

Comments

@gudrutis
Copy link

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 gave ERROR! the playbook: /etc/ansible/playbooks/playbook_under_test/nas.yml could not be found. Not sure if that was supposed to happen.

zmatonis@zmatonis-ThinkPad-X1-Carbon-7th:~/projects/ansible-nas/tests$ ./test.sh 
Starting Docker container: geerlingguy/docker-ubuntu1804-ansible.
latest: Pulling from geerlingguy/docker-ubuntu1804-ansible
Digest: sha256:7d54382176cbb0e1984dd70fd11966248bbd6014aa098c86899851c6c26dd93d
Status: Image is up to date for geerlingguy/docker-ubuntu1804-ansible:latest
docker.io/geerlingguy/docker-ubuntu1804-ansible:latest
bb5a8cb53b0cda715dd700b70af2a775b294b1fffffa89f9c3879f2c11419f48


Checking Ansible version.
ansible-playbook 2.10.4
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.6.9 (default, Oct  8 2020, 12:12:24) [GCC 8.4.0]

Checking Ansible playbook syntax.
ERROR! the playbook: /etc/ansible/playbooks/playbook_under_test/nas.yml could not be found

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

                     ._____.   .__
_____    ____   _____|__\_ |__ |  |   ____             ____ _____    ______
\__  \  /    \ /  ___/  || __ \|  | _/ __ \   ______  /    \\__  \  /  ___/
 / __ \|   |  \\___ \|  || \_\ \  |_\  ___/  /_____/ |   |  \/ __ \_\___ \
(____  /___|  /____  >__||___  /____/\___  >         |___|  (____  /____  >
     \/     \/     \/        \/          \/               \/     \/     \/
   a n s i b l e - n a s      https://github.com/davestephens/ansible-nas

 Checking Vagrant installation
 Copy all.yml to test.yml
 Starting Vagrant and running playbook
 Vagrant up completed, you can connect to the VM at http://172.30.1.5:10080. When you've finished testing, run 'vagrant destroy' to kill the VM.

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:

sudo apt install vagrant
sudo apt install VirtualBox
git clone https://github.com/davestephens/ansible-nas.git
cd ansible-nas/tests
./test-vagrant.sh

Additional context
New user, just looking for a fast way to spin up a demo instance.

@gudrutis gudrutis added the bug label Dec 23, 2020
@ivnmaksimovic
Copy link

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/

@PurpleNinja225
Copy link
Contributor

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.

@wmudge
Copy link
Contributor

wmudge commented Sep 2, 2021

@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.

@HitLuca
Copy link
Contributor

HitLuca commented Oct 2, 2021

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.

@k4lim
Copy link

k4lim commented Oct 17, 2021

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

@viktor-c
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants