Jump to content

[Offer] RHCE EX294


manofring

Recommended Posts

  • 4 weeks later...
  • 4 weeks later...
  • 1 month later...
  • 1 month later...
  • 2 weeks later...
How close this thing to the actual exam? I did notice in Q7 this variable in use (roles.yml)
haproxy_backend_servers:
- name: node3
address: 172.28.254.13
- name: node4
address: 172.28.254.14
but backends are hardcoded to webservers group. It doesn't make sense to use this variable. It doesn't look like real exam questions in this topic.

Any confirmation, guys?
Link to comment
Share on other sites

12 hours ago, zeroacidburn said:

How close this thing to the actual exam? I did notice in Q7 this variable in use (roles.yml)
haproxy_backend_servers:
- name: node3
address: 172.28.254.13
- name: node4
address: 172.28.254.14
but backends are hardcoded to webservers group. It doesn't make sense to use this variable. It doesn't look like real exam questions in this topic.

Any confirmation, guys?

You actually don't have to explicitly use these vars. 

Balancer role is downloaded in Q5 when you have to use ansible-galaxy to download roles.

 

Basically, what you need to do for it to work is following:

 

This is the hidden content, please

The trick is to use phpinfo role before balancer role, otherwise it will not work.

 

Edited by ihorvat2407
  • Like 27
  • Thanks 5
  • Haha 1
Link to comment
Share on other sites

11 hours ago, ihorvat2407 said:

You actually don't have to explicitly use these vars. 

Exactly! That's why I got confused about questions/answers. What's a point to use vars that don't exist in the role?!

Did you get a chance to pass ex294? I'm really interesting how close this Q/A to the real ex294 exam?

 

Quote

The trick is to use phpinfo role before balancer role

Thanks

Link to comment
Share on other sites

6 hours ago, zeroacidburn said:

Exactly! That's why I got confused about questions/answers. What's a point to use vars that don't exist in the role?!

Did you get a chance to pass ex294? I'm really interesting how close this Q/A to the real ex294 exam?

 

Thanks

Original autor (Manofring) answered your question somewhere on the first page.

Here's the link: 

 

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...
On 1/16/2023 at 7:12 PM, ihorvat2407 said:

You actually don't have to explicitly use these vars. 

Balancer role is downloaded in Q5 when you have to use ansible-galaxy to download roles.

 

Basically, what you need to do for it to work is following:

 

This is the hidden content, please

The trick is to use phpinfo role before balancer role, otherwise it will not work.

 

its not trick - its is normal ansible workflow, if group is used, group included to 'all' group. u may change execution order, but it is waste time on exam. sorry for my bad english. If u not used ansible roles u never know about its behavior, its have pros and cons

  • Like 12
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
On 12/6/2021 at 1:02 AM, manofring said:

 

Hidden Content

 

Q7: Use roles from Ansible Galaxy
Create a playbook called /home/greg/ansible/roles.yml as follows:
The playbook contains a play that runs on hosts in the balancers host group and uses the balancer role. This
role configures a service to load balance web server requests between hosts in the webservers host group.
When implemented, browsing to hosts in the balancers host group (for example
http://node5.realm8.example.com) should produce the following output:
Welcome to node3.realm8.example.com on 172.28.254.13
Reloading the browser should return output from the alternate web server:
Welcome to node4.realm8.example.com on 172.28.254.14
The playbook contains a play that runs on hosts in the webservers host group and uses the phpinfo role.
When implemented, browsing to hosts in the webservers host group with the URL /hello.php should
produce the following output:
Hello PHP World from FQDN
where FQDN is the fully qualified domain name of the host.
For example, browsing to

This is the hidden content, please
should produce the following output:
Hello PHP World from node3.realm8.example.com
along with various details of the PHP configuration including the version of PHP that is installed. Similarly,
browsing to
This is the hidden content, please
should produce the following output:
Hello PHP World from node4.realm8.example.com
along with various details of the PHP configuration including the version of PHP that is installed.

A7:

[greg@control ansible]$ nano -uET2 /home/greg/ansible/roles.yml
---
- name: Use balancer role
  hosts:
    - balancers
    - webservers
  vars:
    haproxy_backend_servers:
      - name: node3
        address: 172.28.254.13
      - name: node4
        address: 172.28.254.14
  roles:
    - { role: balancer, when: "inventory_hostname in groups['balancers']" }

- name: Use phpinfo role
  hosts: webservers
  roles:
    - phpinfo

or

[greg@control ansible]$ nano -uET2 /home/greg/ansible/roles.yml
---
- name: Use phpinfo role
  hosts: webservers
  roles:
    - phpinfo

- name: Use balancer role
  hosts: balancers
  vars:
    haproxy_backend_servers:
      - name: node3
        address: 172.28.254.13
      - name: node4
        address: 172.28.254.14
  roles:
    - balancer

P.S. 
First aproach work only on balancer hosts group but get facts from webserver hosts group in role filter "when"
  roles:
    - { role: balancer, when: "inventory_hostname in groups['balancers']" }
    
Second aproach work whithout when in roles becase "groups['webservers']" already filled 
[greg@control ansible]$ cat roles/balancer/templates/haproxy.cfg.j2 
.....
backend habackend
    mode http
    balance roundrobin
{% for host in groups['webservers'] %}
    server {{ hostvars[host].ansible_hostname }}  {{ hostvars[host].ansible_default_ipv4.address}}:80 check
{% endfor %}

 

# check results

# Test phpinfo role
[greg@control ansible]$ curl -S

This is the hidden content, please
| grep Hello
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Hello PHP World from node3.realm8.example.com<br>
100 59779    0 59779    0     0  7297k      0 --:--:-- --:--:-- --:--:-- 8339k
[greg@control ansible]$ curl -S
This is the hidden content, please
| grep Hello
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Hello PHP World from node4.realm8.example.com<br>
100 59778    0 59778    0     0  3891k      0 --:--:-- --:--:-- --:--:-- 3891k


# Test balancer role
[greg@control ansible]$ watch -n1 curl -S

This is the hidden content, please

[greg@control ansible]$ curl -S

This is the hidden content, please

Welcome to node3.realm8.example.com on 172.28.254.13

[greg@control ansible]$ curl -S

This is the hidden content, please

Welcome to node4.realm8.example.com on 172.28.254.14

[greg@control ansible]$ curl -S

This is the hidden content, please

Welcome to node3.realm8.example.com on 172.28.254.13

[greg@control ansible]$ curl -S

This is the hidden content, please

Welcome to node4.realm8.example.com on 172.28.254.14

 

 

Hi manofring, I followed both your first and second approach for question 7, both approaches also resulted in a haproxy error on the balancer node (See screenshot attached). How do I resolve this error?

Haproxy error.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...