11.3. EDA-Server
In this lab we will learn how to use EDA-Server to run our rulebooks. Some tasks have to be done on Ascender.
Task 1
To connect your EDA-Server to your Ansible Controller, you have to create an access token on Ascender and add it to EDA-Server
- On Ascender, create an access token for the user Ansible. Be sure to chose the write scope
- On EDA-Server add this controller token to the user Ansible
Solution Task 1
Go to the Ascender Web-GUI
- On the left hand side, chose
Access
, thenUsers
- Click on user
ansible
, then chose the tabTokens
and click on the blue buttonAdd
- Leave the
Application
field empty, add a description and chose the write scope. - Click the
Save
button. Copy the Token from the popup window. This token is shown only once, so remember it.
Go to the EDA-Server Web-GUI
- On the left-hand side, chose
User Access
and thenUsers
- On the right, chose user
ansible
- Now to the tab
Controller Tokens
- Click on the button
Create controller token
. If you created already one, you have to delete it first to be able to create a new one. - Enter a name, a description and paste in the token from Ascender in the
Token
field
Task 2
Now we add a git repository with our rulebooks as a project to EDA-Server
- Be sure, your ansible rulebooks are residing in a top level folder “rulebooks” inside your git repository
- Add a Project to EDA-Server pointing to your git repository
Note
After creation the status of the project will befailed
as long as you don’t have a directory extensions/eda/rulebooks
or rulebooks
(relative to the root of the repository) present.Solution Task 2
- On the left side navigate to
Resources
and thenProjects
. - On the right side click on the
Create project
button. - Enter a name, description, leave
SCM Type
asGit
. - As
SCM URL
enter the path to your git repository on your Controller node (https://<yourname>-controller.workshop.puzzle.ch:4000/ansible/techlab
). Remember to use port 4000. - Leave the
Credential
field empty. - Clink on
Create project
at the bottom of the page.
Task 3
The last step needed to be able to run rulebooks is creating a Decision Environment.
- Install
ansible-builder
with pip on your<yourname>-edaserver
. Be sure to installpodman
as well since it’s the default container engine foransible-builder
. - Prepare a yaml file
techlab-de.yml
with the definition for your Decision Environment. Take the blueprint from the ansible-rulebook Github project as your base. - Build the Decision Environment, name the image
techlab-de.yml
and tag it withlatest
. - Push it to the container registry provided by your teacher.
Solution Task 3
|
|
|
|
---
version: 3
images:
base_image:
name: 'registry.access.redhat.com/ubi9/python-311:latest'
dependencies:
galaxy:
collections:
- ansible.eda
python:
- azure-servicebus
- aiobotocore
- aiohttp
- aiokafka
- watchdog
- systemd-python
- dpath
- ansible-rulebook
ansible_core:
package_pip: ansible-core==2.14.4
ansible_runner:
package_pip: ansible-runner
system:
- java-17-openjdk-devel [platform:rpm]
|
|
|
|
|
|
Task 4
- Add the Decision Environment
techlab-de
you just created to EDA-Server
Solution Task 4
- On the left side of the EDA-Server Web-GUI navigate to
Resources
thenDecision Environments
. - On the right side, click on
Create decision environemnt
. - Enter a name and description.
- In the
Image
field enter the path with tag to your Decision Environment (<registry_url>/techlab-de:latest
) - Leave the
Credentials
field empty - Click on
Create decision environment
at the bottom of the page.
Task 5
Now have everything ready to run a ansible-rulebook. Ensure you have a job template Provision_Webserver
in the Organization Techlab
of your Ascender server. See the Ascender labs to set it up.
Make the following changes to your webserver_rulebook.yml
rulebook (Lab 11.1):
- Change the action of the rulebook to start a job template
Provision_Webserver
in the organizationTechlab
. - Be sure to push the changes into your git repository.
- On the EDA-Server create a
Rulebook Activation
Solution Task 5
|
|
|
|
- On the left side of the EDA-Server GUI, navigate to
Views
, thenRulebook Activiations
- On the right side click
Create rulebook activation
- Enter the name
Webserver Provisioning
, add a description and chose the projectTechlab Repo
. - Chose
webserver_rulebook.yml
in theRulebook
field. - (if no Rulebook shows up, sync the project)
- Chose
techlab-de
in theDecision environment
field. - Leave
Restart policy
set toOn failure
. - Click
Create rulebook activation
at the bottom of the page.
Task 6
After a successful creation of the Rulebook Activation
you can follow its logs
- Navigate to
Views
, thenRulebook Activations
on the left side and then click on yourWebserver Provisioning
Rulebook Activation. - Click on the
History
tab. - Now click on the running instance ot the activation.
- In the
Output
field have a look at the logs
Solution Task 6
Output filed of the activation:
|
|
Task 7
Now, we stop the webserver on node1 and see in the logs of the rulebook activation how the rule triggers the action to start the job template on ascender and rebuild the webservers.
Solution Task 7
On <yourname>-node1.workshop.puzzle.ch
:
|
|
In the logs on EDA-Server (see the last task to navigate there):
|
|
Check the webpage http://<yourname>-node1.workshop.puzzle.ch/
in your internet browser and ensure the page is available again.