Giter Site home page Giter Site logo

aap-eda-demo's Introduction

Red Hat Ansible Automation Platform Demo

eda-demo architecture

This repository contains the code to showcase a demo of Ansible Automation Platform on the following topics:

  • Config as Code AAP management
  • ServiceNow CMDB Dynamic inventory
  • Event Driven Ansible and self Remediation
  • ServiceNow ITSM integration

Requirements

AAP and EDA Controller

You can install a Containerized Automation Platform and EDA controller

Alertmanager

This demo contains a simple containerized Alertmanager that you can execute with podman play kube

  1. Configure the Alertmanager istance: within the alertmanager configuration file utils/alermanager/alertmanager/alertmanager.yml you can set the webhook_configs url with the EDA Alertmanager receiver

  2. Start the containerized instance

$ cd utils/alermanager/
$ podman play kube alertmanager-pod.yaml --start
$ podman logs -f alertmanager-alertmanager

The instance can be stopped with podman play kube alertmanager-pod.yaml --down

Service Now instance

You can easily sign-up for a developer instance on https://developer.servicenow.com/

Configuration

Before executing the demo you have to create a var file based on the config-as-code/vars-empty.yml file.

Token Configuration

In order to connect AAP and the EDA controller you have to:

  1. Generate a Token in AAP ( Access / Users -> admin -> token -> Add) with write scope
  2. Import the Token into the EDA Controller (Access / Users -> admin -> token -> Create Controller Token)

Alternatively you can configure the token with the provided playbook:

$ cd config-as-code
$ ansible-playbook create_token.yml -e @var.yml

Configuration deployment

Once the token is configured you can deploy the configuration just executing the aap_configuration.yml playbook:

$ ansible-playbook aap_configuration.yml -e @var.yml

This playbook creates all the needed resources in AAP:

  • Job template Setup AAP EDA Demo triggering the aap_configuration.yml playbook
  • Job templates Demo EDA Webhook handler and Demo EDA Alertmanager handler to handle the EDA events
  • servicenow.itsm new credential type
  • Automation Hub, Controller and Service Now credentials
  • Service Now execution environment for the Dynamic inventory
  • An inventory with an inventory source integrating the Service Now CMDB

Demo

ServiceNow CMDB Ansible Dynamic Inventory

Building the Execution Environment

The demo needs an Execution Environment (EE) containing the Ansible servicenow.itsm collection. The demo is using the existing EE from quay.io/pbertera/snow_ee:latest.

Optionally you can build your own EE following the next steps.

Configure Ansible Galaxy:
[galaxy]
server_list = automation_hub

[galaxy_server.automation_hub]
url=https://console.redhat.com/api/automation-hub/content/published/
auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
token=$TOKEN

More info on the Automation Hub documentation

Building the Execution Environment
  1. Login on registry.redhat.io
$ podman login --log-level debug registry.redhat.io
  1. Create the Containerfile into the context dir
$ cd ee
$ ansible-builder create -v 3
  1. Build the EE
$ podman build -f context/Containerfile context --no-cache -t quay.io/pbertera/snow_ee:latest
  1. Tag the image and push it to quay.io (or another registry)
$ podman login quay.io
$ podman push quay.io/pbertera/snow_ee:latest
$ cd ..
  1. Configure the the aap2_controller_execution_environment_image variable into the vars file pointing to the right image

ServiceNow CMDB Inventory Sync

The playbook aap_configuration.yml configures the Dynamic inventory sync creating a new Inventory with a dynamic source pointing to the scm_url repository. The file now.yml contains the sync configuration. For more information please consult the upstream documentation.

To demonstrate the Inventory Sync you can modify the hosts from the CMDB and trigger a new Ansible Inventory source synchronization.

EDA: Webhook

The playbook aap_configuration.yml creates a RuleBook activation on EDA listening on port 5000. The activation executes the rulebooks/eda-rulebook-webhook.yml rulebook triggering the webhook-handler.yml playbook on AAP.

You can trigger the rulebook with the following curl request:

$ curl -X POST http://aap.demo.lab:5000 -d '{"name":"greeting","message":"hello test"}' -v

EDA: Alermanager and ServiceNow ITSM integration

The playbook aap_configuration.yml creates a RuleBook activation on EDA listening on port 5001. The activation executes the rulebooks/eda-rulebook-alertmanager.yml rulebook triggering the alertmanager-handler.yml playbook on AAP.

The playbook creates a ticket when the alert is firing and closes the ticket when the alert is resolved.

You can fire and resolve the alert with the utils/fire-alert.sh $ALERTMANAGER_URL script

Kudos

This demo is mainly inspired by the great kubealex work on another EDA demo

aap-eda-demo's People

Contributors

pbertera avatar

Stargazers

Alessandro Rossi avatar Valentino Uberti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.