jadolyo
Flight Engineer
Flight Engineer
  • 1,683 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

14 Replies
khokha
Flight Engineer
Flight Engineer
  • 621 Views

@jadolyo 

Thanks alooooooooooooooooooooooooooooot.

Rabna ykrmk w ys3dk w ywaf2k.

جزاك الله خيرا كثيرا

May i ask you again if i had trouble in completing the entire environment setup, please?

jadolyo
Flight Engineer
Flight Engineer
  • 620 Views

@khokha 

Oh, You are Arab, You are most welcome.

 

جزانا وإياكم الجنة في الفردوس الأعلى، اللهم آمين

دعوة صادقة في ظهر الغيب بصلاح الحال، وهكون سعيد جدا.


Yes for sure, If you need help anytime, I will be happy to give a hand.

khokha
Flight Engineer
Flight Engineer
  • 614 Views

اميين يا رب نحن و اياكم

هدعيلك كتيييير ان شاء الله

شكراااااا

jadolyo
Flight Engineer
Flight Engineer
  • 567 Views

Hi @khokha 

I saw an email notification you are asking about something but I see you deleted your message, Anyway, I would like to share some tips on my configuration.

1- /etc/hosts file I did some configuration to each VM and to my main controller as below.

192.168.1.50 controller controller.lab.example.com
192.168.1.51 node1 node1.lab.example.com
192.168.1.52 node2 node2.lab.example.com
192.168.1.53 node3 node3.lab.example.com

 

So every time I SSH I just write ssh controller or ssh node1 you can modify MobaXterm hosts file as well so you can easily ssh without writing the IP address.

 

2- Created a user let's say "Ansible" on my controller and each VM too and for sure copied the public key from the controller to each VM, You should know this from RHCSA, Right!

 

3- the ansible.cfg and inventory you can create your own it depends on your naming I am using nodeX you might use serverX my inventory as an example looks like as below

ansible.cfg

inventory = inventory

* Note: I created a directory and inside that directory other directories have it's on playbooks and configurations sometimes I use [privilege_escalation] as below

[privilege_escalation]
become=true
become_method=sudo
become_user=root
become_ask_pass=false

My static inventory looks like as below, you might change the names it doesn't matter it's your choice.

[webservers]

node1.lab.example.com

node2.lab.example.com

[dbservers]

node3.lab.example.com

node4.lab.example.com

 

As you know from RHCSA you need to modify your hostname file on each VM to meet the requirements, and as you know too you might need to create a file inside /etc/sudoers.d/ directory as your user's name and add a line as below, as you know you need the root to create that file if I am not wrong.

 

ansible ALL=(ALL) NOPASSWD: ALL

 

I hope this can help you to make things easier, Have a nice day.

khokha
Flight Engineer
Flight Engineer
  • 550 Views

Hi @jadolyo ,

Thanks for your reply i was having some issues with setting up the environment correctly, but fortunatelly i figures it out and it now works fine.

Again thanks for your reply and your help.

Have a great day

 

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