cancel
Showing results for 
Search instead for 
Did you mean: 
jadolyo
Flight Engineer
Flight Engineer
  • 4,561 Views

Error in Guided Exercise: Creating Roles - Chapter 7 section 4

Hello,

I was doing the guided exercise on my local machine and I am having an error I didn't figure out why it's showing, Can anyone help?

 

ERROR! the role 'myvhost' was not found in /home/jadolyo/roles/myvhost/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/jadolyo/roles/myvhost

The error appears to be in '/home/jadolyo/roles/myvhost/use-vhost-role.yml': line 10, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

roles:
- myvhost
^ here

 

my use-vhost-role.yml

 

  1 ---
  2 - name: Use myvhost role playbook
  3   hosts: webservers
  4   pre_tasks:
  5   ¦ - name: pres_tasks message
  6   ¦ ¦ ansible.builtin.debug:
  7   ¦ ¦ ¦ msg: 'Ensure web server configuration.'
  8
  9   roles:
 10   ¦ - myvhost
 11
 12   post_tasks:
 13   ¦ - name: HTML content is installed
 14   ¦ ¦ ansible.builtin.copy:
 15   ¦ ¦ ¦ src: files/html/
 16   ¦ ¦ ¦ dest: "var/www/vhost/{{ ansible_hostname }}"
 17
 18   ¦ - name: post_tasks message
 19   ¦ ¦ ansible.builtin.debug:
 20   ¦ ¦ ¦ msg: 'Web server is configured.'

 

 

roles_error.png

16 Replies
Chetan_Tiwary_
Community Manager
Community Manager
  • 2,675 Views

Hello @jadolyo !

Thanks for reaching out!

I did try the exercise and could not get the issue :

Chetan_Tiwary__0-1694950512316.png

Chetan_Tiwary__1-1694950531283.png

Could you please recheck. Run the lab finish command and retry the lab again from the beginning. Check the folder from where you are running the playbook and where the project directory is.

0 Kudos
TPeters
Flight Engineer
Flight Engineer
  • 2,667 Views

My guess is that it works for Chetan because he is running this from the role-create subdir which contains the roles/myvhost/ subdir, which is accessible for the execution environment that ansible-navigator is using.

But jadolyo has it under ~/roles/myvhost/ and runs his test playbook from the myvhost subdir itself: so ansible-navigator cannot find the role in his execution environment. Mind that the /home/jadolyo/roles/myvhost/roles/ dir at the beginning of the path does not exist, and /home/jadolyo/roles/myvhost/ at the end of the path does exist on the control node but maybe ansible-navigator is looking for that in its execution environment which obviously does not have /home/jadolyo/ .

 

jadolyo
Flight Engineer
Flight Engineer
  • 2,639 Views

Hi @TPeters 

 

Thank you for your notice and explanation, I think I wasn't paying attention yesterday and I didn't sleep well and I was studying for 10 hours that day, I moved use-vhost-role.yml, ansible.cfg and inventory files out of the roles directory and I ran the command bom everything was working fine, I am having an other issue with permissions I will try to figure it out.

Untitled1.png

jadolyo
Flight Engineer
Flight Engineer
  • 2,644 Views

Hi @Chetan_Tiwary_ 

 

Nothing wrong with your lab environment, I was trying to redo the guided exercise with the same steps on my own local VMs, Which I am simulating your lab environment, I will not do a guided exercise I can do it in 10 minutes, and your system discounts 1 hour of my lab hours so sometimes I use my local VMs for that purpose, I only run your labs if I I will do many guided exercises in that one hour.

 

So I just was wondering why it was throwing that error on my local VMs.

0 Kudos
jadolyo
Flight Engineer
Flight Engineer
  • 2,639 Views

Okay after fixing two other issues, which I had to add become: true in the main playbook and I had to fix src: roles/myvhost/files/ the right destination so everything is working as expected.

 

Untitled2.png

khokha
Flight Engineer
Flight Engineer
  • 2,636 Views

Hi @jadolyo 

May i ask you how did you set up this environment on your local vm ?

i tried using AAP but requires huge resources.

Thanks in advance

jadolyo
Flight Engineer
Flight Engineer
  • 2,632 Views

Hi @khokha 

 

Well, I am using an old Dell Inspiron 5520 laptop 3rd generation i5 increased my RAMs from 4GB to 8GB, Installed Oracle VM Manager, Installed RHEL 9 with minimum requirements I don't use GUI, and I use MobaXterm to log in using SSH on each VM, I am using the resources I have right now I can't upgrade or buy a server or a workstation to practice on till I get a good job, You too you can use what you have to learn.

 

I use Ricardo de Costa's class environment from his git lab to make Vim look like what you see.

git clone https://gitlab.com/rgdacosta/classroom_env

 

and finally, as you see in the second picture, What my desktop setup looks like.

 

What is AAP!?

 

Best wishes.

 

Untitled3.png1694975856632-min.jpg

 

khokha
Flight Engineer
Flight Engineer
  • 2,616 Views

@jadolyo 

thanks for your reply, i'm using vm vmware i installed Ansible Automation Platform (AAP) and tried to configure it but as i mentioned it requires huge resources my device has 8GB RAM and i've RHEL9 installed, i'm wondering how did you configure ansible navigator?

can i download oracle VM Manager for free?

You're using mobaxterm installer or portable edition?

Me too i can't upgrade my device right now

Thanks in advance

jadolyo
Flight Engineer
Flight Engineer
  • 2,614 Views

@khokha 

To save your machine resources it's enough to install a minimum server installation of 1GB of RAM or less is enough for each VM, I could run 5 VMs at the same time with my Windows 11 OS, and nothing is affected, Yes it takes time in the execution but I try to practice with 2 nodes most of the time or one node I just practice to understand the concept.

I configured it one month and a half ago but I saved the steps that I did because it took me some time to figure it out, You can follow the below steps.

 

sudo subscription-manager repos --enable=rhel-9-for-x86_64-appstream-rpms

sudo subscription-manager repos --enable ansible-automation-platform-2.2-for-rhel-9-x86_64-rpms

sudo dnf install -y ansible-core
sudo dnf install -y ansible-navigator

podman pull registry.redhat.io/ansible-automation-platform-22/ee-supported-rhel8:latest

 

you need to edit ansible-navigator.yml so not every time you want to execute ansible-navigator it will try to pull the image.

ansible-navigator:
execution-environment:
image: ee-supported-rhel8:latest
pull:
policy: missing
playbook-artifact:
enable: false

 

Yes Oracle VM VirtualBox Manager is a free product, Google it, But you can keep using VMware Workstation it's the same concept anyway. (I installed one VM then I cloned from it what I needed if a machine has some real issues I just delete it and clone a new fresh one don't waste time )

I am using v6.1 working fine with me.

https://www.oracle.com/eg/virtualization/technologies/vm/downloads/virtualbox-downloads.html

I was using MobaXterm portable and then installed it there is no difference, I use it just as a terminal for SSH, considering it as the workstation.

Regards,

Join the discussion
You must log in to join this conversation.