Git Product home page Git Product logo

ansible-rulebook's Introduction

ansible-rulebook

https://codecov.io/gh/ansible/ansible-rulebook/branch/main/graph/badge.svg?token=U1mIB6PI9I https://github.com/ansible/ansible-rulebook/actions/workflows/ci.yml/badge.svg?branch=main Documentation Status
  • Free software: Apache Software License 2.0

Event driven automation for Ansible.

The real world is full of events that change the state of our software and systems. Our automation needs to be able to react to those events. Introducing ansible-rulebook; a command line tool that allows you to recognize events that you care about and react accordingly by running a playbook or other actions.

Features

  • Connect to event streams and handle events in near real time.
  • Conditionally launch playbooks or Tower's job templates based on rules that match events in event streams.
  • Store facts about the world from data in events
  • Limit the hosts where playbooks run based on event data
  • Run smaller jobs that run more quickly by limiting the hosts where playbooks run based on event data

Installation

Please follow the Installation guide to install ansible-rulebook.

Documentation

Please refer to the Getting Started guide to get started with ansible-rulebook.

Contributing

We ask all of our community members and contributors to adhere to the Ansible code of conduct. If you have questions or need assistance, please reach out to our community team at [email protected]

Refer to the Contributing guide to get started developing, reporting bugs or providing feedback.

Credits

ansible-rulebook is sponsored by Red Hat, Inc.

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

ansible-rulebook's People

Contributors

abaiken avatar akira6592 avatar alex-izquierdo avatar benthomasson avatar bzwei avatar cloin avatar cutwater avatar ddonahue007 avatar dhaustein avatar evacchi avatar evgeni avatar gebhardtr avatar hsong-rh avatar jamesmarshall24 avatar jeffmcutter avatar jouir avatar jshimkus-rh avatar konstruktoid avatar matburt avatar mkanoor avatar oranod avatar samccann avatar sc68cal avatar ssbarnea avatar tarilabs avatar tgonzales114 avatar ttuffin avatar vkrizan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-rulebook's Issues

got `Expected end of text, found '('` when trying out example snippet from doc

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

I'm trying a variation of this snippet example from the doc:

rules:
- name: r1
condition:
all:
- event.request.type == "Delete"
- event.friend_list.names contains events.m_0.request.friend_name
action:
print_event:

Accounting for #493
Using webhook instead of generic source (see also #494)

So the example I'm trying in full reads as:

---
- name: Delayed comparison
  hosts: all
  sources:
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5050 # use 5050 as on Mac OSX the 5000 is already reserved by default OS
  rules:
    - name: r1
      condition:
        all:
          - event.request.type == "Delete"
          - event.friend_list.names is select("search",  events.m_0.request.friend_name)
      action:
        print_event:
          pretty: true

but I get

ansible_rulebook.exception.ConditionParsingException: Error parsing: event.friend_list.names is select("search",  events.m_0.request.friend_name). Expected end of text, found '('  (at char 33), (line:1, col:34)

Environment

$ ansible-rulebook --version
__version__ = '0.11.0'

Steps to reproduce

  1. assume the example is in a file named example.yml
  2. run with ansible-rulebook --rulebook example.yml --verbose

Actual results

ansible_rulebook.exception.ConditionParsingException: Error parsing: event.friend_list.names is select("search",  events.m_0.request.friend_name). Expected end of text, found '('  (at char 33), (line:1, col:34)

Expected results

not an error ๐Ÿ™ƒ since it's copied from the docs

Additional information

I'm possibly doing something wrong, hope these details help to ultimately triage if there is some bugs or it's my fault (in that case sorry I raised this)

ansible-rulebook command should display help if run without arguments

  • ansible-rulebook version: 0.9.4
  • Python version: 3.10.8
  • Operating System: Ventura 13.0 (22A380)

Description

the command ansible-rulebook executed without arguments should follow the same pattern than other ansible commands such as ansible-playbook, ansible, ansible-lint, -doc where executing the commands without arguments default in the equivalent of doing a [ansible-command] --help

What I Did

example ansible command (others also behave similarly

$ ansible-playbook
usage: ansible-playbook [-h] [--version] [-v] [--private-key PRIVATE_KEY_FILE] [-u REMOTE_USER] [-c CONNECTION] [-T TIMEOUT]
                        [--ssh-common-args SSH_COMMON_ARGS] [--sftp-extra-args SFTP_EXTRA_ARGS] [--scp-extra-args SCP_EXTRA_ARGS]
                        [--ssh-extra-args SSH_EXTRA_ARGS] [-k | --connection-password-file CONNECTION_PASSWORD_FILE] [--force-handlers] [--flush-cache]
                        [-b] [--become-method BECOME_METHOD] [--become-user BECOME_USER] [-K | --become-password-file BECOME_PASSWORD_FILE] [-t TAGS]
                        [--skip-tags SKIP_TAGS] [-C] [--syntax-check] [-D] [-i INVENTORY] [--list-hosts] [-l SUBSET] [-e EXTRA_VARS]
                        [--vault-id VAULT_IDS] [--ask-vault-password | --vault-password-file VAULT_PASSWORD_FILES] [-f FORKS] [-M MODULE_PATH]
                        [--list-tasks] [--list-tags] [--step] [--start-at-task START_AT_TASK]
                        playbook [playbook ...]
ansible-playbook: error: the following arguments are required: playbook
.......
$
$ ansible-rulebook
$

KeyError: 'event' When assigning events after a match the var_root accesses invalid key

  • ansible-events version: 0.4.0
  • Python version:3.9.13
  • Operating System: MacOS

Description

Get a Key Error when we making an assignment to events after a match.

Trying to run a playbook after an assignment on an event match

condition: events.third << event.i == 2

Tell us what happened, what went wrong, and what you expected to happen.
E KeyError: 'event'
https://github.com/benthomasson/ansible-events/blob/38ba754fa97b2b188b424ed898ce084985544510/ansible_events/builtin.py#L134

What I Did

Ran a playbook as part of assigning a matched event.

Modified tests/test_simple.yml
changed
condition: event.i == 2
to
condition: events.second << event.i == 2

Ran pytest
pytest tests/test_engine.py::test_run_rules_simple

RFE: Documentation. Document Event Source plugins in a manner similar to the ansible collection index

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Feature type

New Feature

Feature Summary

Working with the available event sources is challenging as the available configuration parameters are not published and require scraping the python code to find the possible configuration parameters.

By including a collection index for these modules, similar to the ansible plugins docs, users can create their own rulebooks easier https://docs.ansible.com/ansible/latest/collections/all_plugins.html

Steps to reproduce

N/A

Current results

N/A

Sugested feature result

Additional Documentation page for the ansible.eda collection

Additional information

Willing to help contribute and create these files, but I don't know where to place the docs files or to get the templates from

Unhandled exception when dash in event name

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

An unexpected exception is thrown when using a dash (minus) as part of the condition string:

condition: event.payload.vendor-product.rule == "Test"

Environment

__version__ = '0.12.0'
  Executable location = /root/eda-venv/bin/ansible-rulebook
  Drools_jpy version = 0.3.0
  Java home = /etc/alternatives/jre
  Java version = 17.0.7
  Python version = 3.9.14 (main, Jan  9 2023, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]

Steps to reproduce

Trivial to reproduce:

# cat rulebook.yml 
---
- name: Listen for events on a webhook
  hosts: all
  sources:
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5000
  rules:
    - name: Check performance events
      condition: event.payload.vendor-product.rule == "Test"
      action:
        run_playbook:
          name: action.yml
# ansible-rulebook --inventory inventory.yml --rulebook rulebook.yml
2023-04-24 09:27:28,539 - ansible_rulebook.cli - ERROR - Unexpected exception
Traceback (most recent call last):
  File "/root/eda-venv/lib64/python3.9/site-packages/ansible_rulebook/condition_parser.py", line 320, in parse_condition
    return condition.parseString(condition_string, parse_all=True)[0]
  File "/root/eda-venv/lib64/python3.9/site-packages/pyparsing/core.py", line 1141, in parse_string
    raise exc.with_traceback(None)
pyparsing.exceptions.ParseException: Expected end of text, found '.'  (at char 28), (line:1, col:29)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/eda-venv/lib64/python3.9/site-packages/ansible_rulebook/cli.py", line 223, in main
    asyncio.run(app.run(args))
  File "/usr/lib64/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib64/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/root/eda-venv/lib64/python3.9/site-packages/ansible_rulebook/app.py", line 71, in run
    startup_args.rulesets = load_rulebook(
  File "/root/eda-venv/lib64/python3.9/site-packages/ansible_rulebook/app.py", line 171, in load_rulebook
    rulesets = rules_parser.parse_rule_sets(data, variables)
  File "/root/eda-venv/lib64/python3.9/site-packages/ansible_rulebook/rules_parser.py", line 72, in parse_rule_sets
    rules=parse_rules(rule_set.get("rules", {}), variables),
  File "/root/eda-venv/lib64/python3.9/site-packages/ansible_rulebook/rules_parser.py", line 143, in parse_rules
    condition=parse_condition(rule["condition"]),
  File "/root/eda-venv/lib64/python3.9/site-packages/ansible_rulebook/rules_parser.py", line 177, in parse_condition
    return rt.Condition("all", [parse_condition_value(condition)])
  File "/root/eda-venv/lib64/python3.9/site-packages/ansible_rulebook/condition_parser.py", line 324, in parse_condition
    raise ConditionParsingException(msg)
ansible_rulebook.exception.ConditionParsingException: Error parsing: event.payload.vendor-product.rule == "Test". Expected end of text, found '.'  (at char 28), (line:1, col:29)

Actual results

Unexcepted exception.

Expected results

No exception.

Additional information

While the code will likely be easy to fix I think the documentation should already at this point provide instruction how vendors should setup "namespace" for their products. I've now seen one project to use a generic condition name (event.payload.<rule-name> e.g. event.payload.lifecycle) while another tried to create a namespace with event.payload.project-component.rule type approach.

Since in most enterprises where only one port is expected for each service (such as EDA) instead of a separate port for each event source there needs to a way how to avoid overalapping names with different vendors and event sources. Perhaps we should a have separate doc issue for this.

Thanks.

When an asyncio.gather returns we are not checking for None before we deem it as an exception

  • ansible-events version: 0.6.0
  • Python version: 3.10.6
  • Operating System: Mac OS

Description

When running performance test there is an error reported

ansible-events --rules ./performance_test/1k_event_rules.yml --inventory ./performance_test/inventory1.yml -S ./performance_test/sources/

ERROR:ansible_events:None

What I Did

ansible-events --rules ./performance_test/1k_event_rules.yml --inventory ./performance_test/inventory1.yml -S ./performance_test/sources/

ansible_rulebook.rule_set_runner - ERROR - Error calling action run_playbook

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

I'm using Webhook event source to trigger ansible rulebook from the the command line using another locally installed service. The first time it triggers it almost always works but subsequent triggers I sometimes get an error (below)

Environment

1.0.3
Executable location = /usr/local/bin/ansible-rulebook
Drools_jpy version = 0.3.7
Java home = /usr/lib/jvm/java-17-openjdk-amd64
Java version = 17.0.8.1
Python version = 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]

Ubuntu 22.04.3 LTS on ESXi AMD64

Steps to reproduce

Using this rulebook:

---
- name: Run playbook
  hosts: all
  sources:
    - ansible.eda.webhook:
        host: 127.0.0.1
        port: 6000
  rules:
    - name: Webhook called
      condition: event.payload.cmd == 'start'
      action:
        run_playbook:
          name: /home/charlespick/playbook.yml

Actual results

2023-10-29 18:46:29,916 - ansible_rulebook.rule_set_runner - ERROR - Error calling action run_playbook, err [('/home/charlespick/.ansible/cp/47aa5da64f', '/tmp/edach48wb7s/project/.ansible/cp/47aa5da64f', "[Errno 6] No such device or address: '/home/charlespick/.ansible/cp/47aa5da64f'")]

Expected results

Playbook should execute reliably

Additional information

357c703fdf9d05295589f06bdd5da2ac3d25478f 1

EDA Credential Objects

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Feature type

New Feature

Feature Summary

In the current version of AAP, we have credential objects to leverage to pass in sensitive values to the playbook. In EDA, when leveraging the webhook plugin (and possibly others), securing this endpoint currently requires a plain text token committed to the code base. A credential object being available that was injected at runtime would alleviate this.

Steps to reproduce

Create a rulebook using any source plugin requiring a sensitive parameter

hosts: localhost
sources:
  - ansible.eda.webhook:
      host: 0.0.0.0
      port: 5000
      token: MySecretToken

Current results

The parameter needs to be committed in plain text

Sugested feature result

The ability to inject the sensitive value at runtime

hosts: localhost
sources:
  - ansible.eda.webhook:
      host: 0.0.0.0
      port: 5000
      token: {{ token }} 

Additional information

No response

run_job_template action returns 401 when 443 port is present in CONTROLLER_URL

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

When CONTROLLER_URL has an https scheme and it contains the default port (443) AWX returns a redirect without the port. A bug related with aiohttp library causes the deletion of the authorization header ending in a 401 response.

Regardless if the port is considered or not part of the host, this error can be avoided avoiding unnecessary redirects from AWX. This would not happen if the port is not the standard one (in that case AWX would return the port in the redirect and aiohttp client would resend the authorization header)

Environment

ansible-rulebook v1.0.0

Steps to reproduce

ansible-rulebook -r somerulebook.yml --controller-url https://some-awx:443 --controller-token some-valid-token --controller-ssl-verify no

Actual results

2023-07-18 19:23:22,870 - ansible_rulebook.job_template_runner - ERROR - Error connecting to controller 401, message='Unauthorized', url=URL('https://some-awx:443/api/v2/config/')
2023-07-18 19:23:22,872 - ansible_rulebook.cli - ERROR - Terminating 401, message='Unauthorized', url=URL('https://some-awx:443/api/v2/config/')

Expected results

The rulebook should work because it was provided a valid token.

Additional information

No response

ansible-rulebook requires psycopg python module

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

ansible-rulebook --version requires psycopg

Environment

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"

Steps to reproduce

Followed the installation steps here https://ansible.readthedocs.io/projects/rulebook/en/stable/installation.html
Run ansible-rulebook --version

Actual results

ansible-rulebook --version
Traceback (most recent call last):
  File "/home/meyers/.local/bin/ansible-rulebook", line 5, in <module>
    from ansible_rulebook.cli import main
  File "/home/meyers/.local/lib/python3.10/site-packages/ansible_rulebook/cli.py", line 36, in <module>
    from ansible_rulebook import app  # noqa: E402
  File "/home/meyers/.local/lib/python3.10/site-packages/ansible_rulebook/app.py", line 32, in <module>
    from ansible_rulebook.engine import run_rulesets, start_source
  File "/home/meyers/.local/lib/python3.10/site-packages/ansible_rulebook/engine.py", line 37, in <module>
    from ansible_rulebook.rule_set_runner import RuleSetRunner
  File "/home/meyers/.local/lib/python3.10/site-packages/ansible_rulebook/rule_set_runner.py", line 36, in <module>
    from ansible_rulebook.action.pg_notify import PGNotify
  File "/home/meyers/.local/lib/python3.10/site-packages/ansible_rulebook/action/pg_notify.py", line 20, in <module>
    from psycopg import AsyncClientCursor, AsyncConnection, OperationalError
ModuleNotFoundError: No module named 'psycopg'

Expected results

For the version information to be printed.

Additional information

Seems like psycopg should be added to the Installation instructions.

FQCN playbooks do not work on run_playbook action

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

Using FQCN playbooks on run_playbook they don't seem to work.
The rulebook process errors out that it cannot find it.

Environment

Fedora 34

Steps to reproduce

  1. Clone ansible/aap-containerized-installer repo
  2. Install it as a collection by running `ansible-galaxy collection install .'
  3. Create a rulebook with a rule with action such as:
      action:
        run_playbook:
          name: ansible.containerized_installer.install

Actual results

When the event gets triggered, I get:

May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]: 2023-05-24 12:43:24,546 - ansible_rulebook.rule_set_runner - ERROR - Error calling run_playbook
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]: Traceback (most recent call last):
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:   File "/usr/local/lib/python3.11/site-packages/ansible_rulebook/rule_set_runner.py", line 375, in _call_action
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:     await builtin_actions[action](
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:   File "/usr/local/lib/python3.11/site-packages/ansible_rulebook/builtin.py", line 303, in run_playbook
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:     temp_dir, playbook_name = await pre_process_runner(
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:                               ^^^^^^^^^^^^^^^^^^^^^^^^^
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:   File "/usr/local/lib/python3.11/site-packages/ansible_rulebook/builtin.py", line 647, in pre_process_runner
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]:     raise PlaybookNotFoundException(msg)
May 24 12:43:24 ip-172-31-17-143.ec2.internal ansible-rulebook[1164134]: ansible_rulebook.exception.PlaybookNotFoundException: Could not find a playbook for ansible.containerized_installer.install from /home/ec2-user/aap/servicediscovery/etc

However, the playbook looks fine, I can run it with ansible-playbook:

[ec2-user@ip-172-31-17-143 aap-containerized-installer]$ ansible-playbook ansible.containerized_installer.install
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
[WARNING]: running playbook inside collection ansible.containerized_installer

It seems the 'playbooks' folder is not searched within the collection.

Expected results

Action runs playbook using FQCN just fine.

Additional information

No response

Intermittent test failure for time window example

  • ansible-rulebook version: 0.10.1
  • Python version: 3.9
  • Operating System: Mac

Description

When running pytest one of the examples which uses a time window of 10 seconds gets a QueueEmpty exception. Since the rule engine is not not going to respond till after 10 seconds we might need to control how long to wait

What I Did

pytest

>           event = event_log.get_nowait()

/Users/madhukanoor/devsrc/ansible-rulebook/tests/test_examples.py:1398: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Queue at 0x105b4f4f0 maxsize=0>

    def get_nowait(self):
        """Remove and return an item from the queue.
    
        Return an item if one is immediately available, else raise QueueEmpty.
        """
        if self.empty():
>           raise QueueEmpty
E           asyncio.queues.QueueEmpty

/opt/homebrew/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/queues.py:189: QueueEmpty

Shutdown more gracefully

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Feature type

Enhancement to Existing Feature

Feature Summary

Currently, there doesn't seem to be a way to get ansible-rulebook to stop processing new events from event sources and allow all existing work to complete. Even using the shutdown action and a webhook, other rules will continue to pull work from the even sources and start kicking off playbook runs. This means that there's a high likelihood that ansible-rulebook will exit while a playbook is still executing.

There needs to be a way to have ansible-rulebook stop all the event sources, allow all work to complete, and then exit.

This would also be useful when handling SIGTERM signals. Allow the work to complete, then exit, instead of just exiting hard with work still in progress.

Steps to reproduce

Create a rulebook that contains an event source that is a queue, like the Kafka event source or Amazon SQS, and also has a webhook source that has a rule that matches the webhook and does a shutdown action.

Put an event into the Kafa or SQS queue, watch the playbook start running. Send an event to the webhook

Current results

Work continues up until the shutdown happens, with no real "graceful" behavior

Sugested feature result

Ability to stop ansible-rulebook cleanly, where all work that has been pulled from an event source has completed, while stopping pulling from an event source and allow work to queue up in event sources where this construct exists (SQS queue, etc).

Additional information

No response

host_vars and group_vars in inventory directory are ignored by ansible-rulebook

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

I have a simple ansible playbook which prints variables defined in host_vars and group_vars files defined in the inventory directory. If I execute the playbook with ansible-playbook (or ansible-runner), the tasks can be executed. If I trigger it by a webhook via ansible-rulebook the variables are not found.

Environment

OS: WSL2, Ubuntu 22.04.3 LTS
Ansible:

ansible [core 2.16.0]
  config file = None
  configured module search path = ['/home/evonlanthen/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/evonlanthen/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/evonlanthen/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/evonlanthen/.local/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

Ansible-rulebook:

1.0.6
  Executable location = /home/evonlanthen/.local/bin/ansible-rulebook
  Drools_jpy version = 0.3.9
  Java home = /usr/lib/jvm/java-17-openjdk-amd64
  Java version = 17.0.10
  Python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

Steps to reproduce

Directory structure:

.
โ”œโ”€โ”€ inventories
โ”‚ย ย  โ””โ”€โ”€ production
โ”‚ย ย      โ”œโ”€โ”€ group_vars
โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ mygroup.yml
โ”‚ย ย      โ”œโ”€โ”€ host_vars
โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ localhost.yml
โ”‚ย ย      โ””โ”€โ”€ hosts.yml
โ”œโ”€โ”€ playbook.yml
โ””โ”€โ”€ rulebook.yml

playbook.yml:

---
- hosts: mygroup
  gather_facts: false
  tasks:
    - name: Show vars
      ansible.builtin.debug:
        msg:
          - "groupvar: {{ mygroupvar }}"
          - "hostvar: {{ myhostvar }}"
      connection: local

rulebook.yml:

---
- name: Listen for selfservice events on a webhook
  hosts: all

  sources:
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5000
      filters:
        - ansible.eda.insert_hosts_to_meta:
            host_path: payload.host
  rules:
    - name: Test rule
      condition: 1 == 1
      actions:
        - print_event:
            pretty: true
        - run_playbook:
            name: playbook.yml
            copy_files: true

inventories/production/hosts.yml:

---
mygroup:
  hosts:
    localhost

inventories/production/group_vars/mygroup.yml:

---
mygroupvar: 'hello from group var'

ansible-playbook command:

evonlanthen@SWP-HM60793 ~/ansible/rulebook $ ansible-playbook -i inventories/production/hosts.yml playbook.yml

PLAY [mygroup] *********************************************************************************************************************************************************************************************************************************************

TASK [Show vars] *******************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": [
        "groupvar: hello from group var",
        "hostvar: hello from host var"
    ]
}

PLAY RECAP *************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

ansible-rulebook command:

evonlanthen@SWP-HM60793 ~/ansible/rulebook $ ansible-rulebook -i inventories/production/hosts.yml -r rulebook.yml -v
2024-05-15 15:39:28,769 - ansible_rulebook.app - INFO - Starting sources
2024-05-15 15:39:28,769 - ansible_rulebook.app - INFO - Starting rules
2024-05-15 15:39:28,769 - drools.ruleset - INFO - Using jar: /home/evonlanthen/.local/lib/python3.10/site-packages/drools/jars/drools-ansible-rulebook-integration-runtime-1.0.6-SNAPSHOT.jar
2024-05-15 15:39:29 201 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.AbstractRulesEvaluator - Start automatic pseudo clock with a tick every 100 milliseconds
2024-05-15 15:39:29,212 - ansible_rulebook.engine - INFO - load source ansible.eda.webhook
2024-05-15 15:39:29,505 - ansible_rulebook.engine - INFO - loading source filter ansible.eda.insert_hosts_to_meta
2024-05-15 15:39:29,505 - ansible_rulebook.engine - INFO - loading source filter eda.builtin.insert_meta_info
2024-05-15 15:39:29,786 - ansible_rulebook.engine - INFO - Waiting for all ruleset tasks to end
2024-05-15 15:39:29,786 - ansible_rulebook.rule_set_runner - INFO - Waiting for actions on events from Listen for selfservice events on a webhook
2024-05-15 15:39:29,786 - ansible_rulebook.rule_set_runner - INFO - Waiting for events, ruleset: Listen for selfservice events on a webhook
2024-05-15 15:39:29 786 [drools-async-evaluator-thread] INFO org.drools.ansible.rulebook.integration.api.io.RuleExecutorChannel - Async channel connected

webhook trigger:

evonlanthen@SWP-HM60793 ~ $ curl -H 'Content-Type: application/json' -d '{"host":"localhost"}' 127.0.0.1:5000/endpoint

ansible-rulebook output:

2024-05-15 15:41:27,647 - aiohttp.access - INFO - 127.0.0.1 [15/May/2024:14:41:27 +0100] "POST /endpoint HTTP/1.1" 200 159 "-" "curl/7.81.0"

** 2024-05-15 15:41:27.649608 [event] **********************************************************************************************************************************************************************************************************************
{'meta': {'endpoint': 'endpoint',
          'headers': {'Accept': '*/*',
                      'Content-Length': '20',
                      'Content-Type': 'application/json',
                      'Host': '127.0.0.1:5000',
                      'User-Agent': 'curl/7.81.0'},
          'hosts': ['localhost'],
          'received_at': '2024-05-15T13:41:27.647399Z',
          'source': {'name': 'ansible.eda.webhook',
                     'type': 'ansible.eda.webhook'},
          'uuid': '943699e9-eb36-4537-82f3-3df1e033c282'},
 'payload': {'host': 'localhost'}}
************************************************************************************************************************************************************************************************************************************************************

PLAY [mygroup] *****************************************************************

TASK [Show vars] ***************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'mygroupvar' is undefined. 'mygroupvar' is undefined\n\nThe error appears to be in '/tmp/eda131fp7ui/project/playbook.yml': line 5, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Show vars\n      ^ here\n"}

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
2024-05-15 15:41:28,185 - ansible_rulebook.action.runner - INFO - Ansible runner Queue task cancelled
2024-05-15 15:41:28,185 - ansible_rulebook.action.run_playbook - INFO - Ansible runner rc: 2, status: failed
2024-05-15 15:41:28,185 - ansible_rulebook.action.run_playbook - ERROR -
PLAY [mygroup] *****************************************************************

TASK [Show vars] ***************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'mygroupvar' is undefined. 'mygroupvar' is undefined\n\nThe error appears to be in '/tmp/eda131fp7ui/project/playbook.yml': line 5, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Show vars\n      ^ here\n"}

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Actual results

Ansible-playbook run fails with undefined variable (it doesn't matter if a variable from group_vars or hosts_vars is used first).

Expected results

Successful ansible playbook run.

Additional information

No response

Get error when running run_workflow_template

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

run_workflow_template does not seem to work. When I do try and use it, I get the following error in daphne.log:

Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]: 2023-11-16 03:31:40,839 ERROR    Exception inside application: ['โ€œโ€ value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]: Traceback (most recent call last):
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/channels/routing.py", line 62, in __call__
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return await application(scope, receive, send)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/channels/routing.py", line 116, in __call__
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return await application(
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/channels/routing.py", line 116, in __call__
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return await application(
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/channels/consumer.py", line 94, in app
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return await consumer(scope, receive, send)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/channels/consumer.py", line 62, in __call__
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    await await_many_dispatch([receive], self.dispatch)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/channels/utils.py", line 50, in await_many_dispatch
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    await dispatch(result)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/channels/consumer.py", line 73, in dispatch
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    await handler(message)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/channels/generic/websocket.py", line 194, in websocket_receive
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    await self.receive(text_data=message["text"])
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/aap_eda/wsapi/consumers.py", line 92, in receive
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    await self.handle_actions(ActionMessage.parse_obj(data))
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/aap_eda/wsapi/consumers.py", line 135, in handle_actions
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    await self.insert_audit_rule_data(message)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/asgiref/sync.py", line 448, in __call__
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    ret = await asyncio.wait_for(future, timeout=None)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib64/python3.9/asyncio/tasks.py", line 442, in wait_for
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return await fut
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib64/python3.9/concurrent/futures/thread.py", line 58, in run
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    result = self.fn(*self.args, **self.kwargs)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/channels/db.py", line 13, in thread_handler
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return super().thread_handler(loop, *args, **kwargs)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/asgiref/sync.py", line 490, in thread_handler
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return func(*args, **kwargs)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/aap_eda/wsapi/consumers.py", line 204, in insert_audit_rule_data
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    audit_rule = models.AuditRule.objects.filter(
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return getattr(self.get_queryset(), name)(*args, **kwargs)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/query.py", line 941, in filter
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return self._filter_or_exclude(False, args, kwargs)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    clone._filter_or_exclude_inplace(negate, args, kwargs)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    self._query.add_q(Q(*args, **kwargs))
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1416, in add_q
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    clause, _ = self._add_q(q_object, self.used_aliases)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1435, in _add_q
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    child_clause, needed_inner = self.build_filter(
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1370, in build_filter
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    condition = self.build_lookup(lookups, col, value)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/sql/query.py", line 1216, in build_lookup
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    lookup = lookup_class(lhs, rhs)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/lookups.py", line 25, in __init__
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    self.rhs = self.get_prep_lookup()
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/lookups.py", line 77, in get_prep_lookup
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return self.lhs.output_field.get_prep_value(self.rhs)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1406, in get_prep_value
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    value = super().get_prep_value(value)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1266, in get_prep_value
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    return self.to_python(value)
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:  File "/usr/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 1388, in to_python
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]:    raise exceptions.ValidationError(
Nov 15 22:31:40 eda01 automation-eda-controller-daphne[821839]: django.core.exceptions.ValidationError: ['โ€œโ€ value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']

Here's my stanza:

    - name: Fiber Adapters
      condition: event.payload.event_tags.playbook is select("==", "Tune Fiber Adapters")
      action:
        run_workflow_template: 
          name: Tune Fiber Adapters
          organization: Default
          job_args:
            extra_vars:
              key: "{{ event.payload.event_tags.key[0] }}"
              run: "{{ event.payload.host_host }}"
              context: "fiber"
              device: "{{ event.payload.event_tags.device[0] }}"
        ```





### Environment

[root@eda01 log]# ansible-rulebook --version
__version__ = '1.0.0'
  Executable location = /usr/bin/ansible-rulebook
  Drools_jpy version = 0.3.4
  Java home = /usr/lib/jvm/java-17-openjdk-17.0.9.0.9-2.el8.x86_64
  Java version = 17.0.9
  Python version = 3.9.16 (main, Sep 22 2023, 17:57:55) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)]

### Steps to reproduce

Create a workflow template with a few steps

Try and run it using EDA.

### Actual results

Error in daphne log.

### Expected results

It to run the workflow template job on AAP.

### Additional information

_No response_

source `generic` is not released in Ansible EDA hence rulebook example fails

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

This source is mentioned in the doc:

sources:
- generic:
payload:

The generic source (in my understanding formally ansible.eda.generic), is not available in the 1.3.3/(galaxy 1.3.4) from EDA:

https://github.com/ansible/event-driven-ansible/tree/v1.3.3?search=1

but it's only available from main branch: https://github.com/ansible/event-driven-ansible/blob/main/extensions/eda/plugins/event_source/generic.py

which is NOT yet released.

Hence, a user (like me ๐Ÿ˜… ) trying out the example from the documentation fails as described below.

Environment

latests of all collections:

ansible.eda       1.3.4

(even if I cannot find it on github ๐Ÿค” )

$ ansible-rulebook --version
__version__ = '0.11.0'

Steps to reproduce

  1. copy-paste snippet example from doc
  2. account for #493
  3. use simpler condition as condition: event.request is defined

Actual results

2023-04-27 08:29:42,245 - ansible_rulebook.engine - ERROR - Source error
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/ansible_rulebook/engine.py", line 93, in start_source
raise Exception(
Exception: Could not find source plugin for generic

Expected results

simple example from doc to be working

Additional information

No response

run_workflow_template only passes variables when prompt on launch selected in Workflow Job Template

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

When using the run_workflow_template and a survey, the workflow job only receives the variables when prompt on launch is also selected for extra vars. This is not an issue when directly calling the API, but is an issue when using the run_workflow_template action

Environment

ansible-rulebook-1.0.3
Ansible Automation Platform Controller 4.4.8

Steps to reproduce

  1. Create a workflow job template
  2. Create and enable a survey (do NOT check prompt on launch for extra variables in the WF)
  3. Create a rulebook with the run_workflow_job template and the job_args to populate that variable
  4. Trigger the rulebook

Actual results

If the survey is set to required, it fails saying that variable is needed to start

2023-11-27 16:00:40,040 - ansible_rulebook.rule_set_runner - INFO - action args: {'name': 'Automated Response Node Exporter Down EDA', 'organization': 'Security', 'job_args': {'extra_vars': {'vm_name': 'rhel8.shadowman.dev'}}}

2023-11-27 16:00:40,041 - ansible_rulebook.action.run_workflow_template - INFO - running workflow template: Automated Response Node Exporter Down EDA, organization: Security

2023-11-27 16:00:40,041 - ansible_rulebook.action.run_workflow_template - INFO - ruleset: Automatic Remediation from Alert Manager, rule Prometheus Node Exporter Down

2023-11-27 16:00:40,292 - ansible_rulebook.job_template_runner - WARNING - Workflow template Automated Response Node Exporter Down EDA does not accept limit, removing it

2023-11-27 16:00:40,292 - ansible_rulebook.job_template_runner - WARNING - Workflow template Automated Response Node Exporter Down EDA does not accept extra vars, removing it

2023-11-27 16:00:40,524 - ansible_rulebook.job_template_runner - ERROR - Error connecting to controller 400, message='Bad Request', url=URL('https://tower.shadowman.dev/api/v2/workflow_job_templates/612/launch/')

2023-11-27 16:00:40,524 - ansible_rulebook.job_template_runner - ERROR - Error {'variables_needed_to_start': ["'vm_name' value missing"]}

Expected results

The job should successfully run without setting prompt on launch for extra vars since the survey exists

Additional information

No response

run_job_template removes relative path from controller URL

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

When specifying a URL with a relative path to the controller (AWX), the API call is sent to the absolute path /api/v2.

Configured eda.yml:

$ cat eda.yaml 
# eda.yaml
apiVersion: eda.ansible.com/v1alpha1
kind: EDA
metadata:
  name: my-eda
spec:
  automation_server_url: http://awx-demo-service.awx/awx/
  service_type: ClusterIP
  ingress_type: ingress

Here's the output of the rulebook activation:

2024-01-19 23:32:13,505 - ansible_rulebook.websocket - INFO - websocket ws://my-eda-daphne:8001/api/eda/ws/ansible-rulebook connected
2024-01-19 23:32:13,552 - ansible_rulebook.job_template_runner - INFO - Attempting to connect to Controller http://awx-demo-service.awx/awx
2024-01-19 23:32:13,553 - ansible_rulebook.job_template_runner - ERROR - Error connecting to controller 404, message='Not Found', url=URL('http://awx-demo-service.awx/api/v2/config/')
2024-01-19 23:32:13,554 - ansible_rulebook.cli - ERROR - Terminating 404, message='Not Found', url=URL('http://awx-demo-service.awx/api/v2/config/') 

After removing the leading "/" from UNIFIED_TEMPLATE_SLUG and CONFIG_SLUG. It started to work locally for me.

Environment

eda-server-operator 2.10.0 with quay.io/ansible/ansible-rulebook:v1.0.4

Steps to reproduce

You'll need AWX installed on a different path than '/`.

I installed ansible-rulebook from brew (OSX).

Export the following variable (CLI options or documentation didn't work).

export EDA_CONTROLLER_URL="http://localhost:8081/awx/"
export EDA_CONTROLLER_TOKEN="ZesMMFepb2WYfHNEfvv1pMz0PMbUkE"

Start a simple rulebook using job_run_template.
Verify it doesn't connect.

My output looked like this on ansible-rulebook ran locally:

$ ansible-rulebook -r rulebooks/hello.yaml -vv 
2024-01-19 20:02:55,303 - asyncio - DEBUG - Using selector: KqueueSelector
2024-01-19 20:02:55,304 - ansible_rulebook.app - DEBUG - Loading rules from the file system rulebooks/hello.yaml
2024-01-19 20:02:55,309 - ansible_rulebook.condition_parser - DEBUG - [Identifier(value='event.i'), '==', Integer(value=1)]
2024-01-19 20:02:55,309 - ansible_rulebook.job_template_runner - INFO - Attempting to connect to Controller http://localhost:8081/awx/
2024-01-19 20:02:55,317 - ansible_rulebook.cli - ERROR - Terminating Expecting value: line 1 column 1 (char 0)

Once I remove the trailing slash (there is a different error):

$ ansible-rulebook -r rulebooks/hello.yaml -vv 
2024-01-19 20:16:46,145 - asyncio - DEBUG - Using selector: KqueueSelector
2024-01-19 20:16:46,145 - ansible_rulebook.app - DEBUG - Loading rules from the file system rulebooks/hello.yaml
2024-01-19 20:16:46,150 - ansible_rulebook.condition_parser - DEBUG - [Identifier(value='event.i'), '==', Integer(value=1)]
2024-01-19 20:16:46,151 - ansible_rulebook.job_template_runner - INFO - Attempting to connect to Controller http://localhost:8081/awx/
2024-01-19 20:16:46,259 - ansible_rulebook.app - INFO - AAP Version 23.6.0
2024-01-19 20:16:46,259 - ansible_rulebook.app - INFO - Starting sources
2024-01-19 20:16:46,259 - ansible_rulebook.app - INFO - Starting rules
2024-01-19 20:16:46,259 - ansible_rulebook.engine - INFO - run_ruleset
2024-01-19 20:16:46,260 - drools.ruleset - INFO - Using jar: /opt/homebrew/lib/python3.9/site-packages/drools/jars/drools-ansible-rulebook-integration-runtime-1.0.5-SNAPSHOT.jar
2024-01-19 20:16:46,508 - drools.ruleset - DEBUG - Creating Drools Ruleset
2024-01-19 20:16:46 801 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.AbstractRulesEvaluator - Start automatic pseudo clock with a tick every 100 milliseconds
2024-01-19 20:16:46,805 - drools.ruleset - DEBUG - Ruleset Session ID : 1
2024-01-19 20:16:46,805 - ansible_rulebook.engine - INFO - ruleset define: {"name": "Hello Events", "hosts": ["localhost"], "sources": [{"EventSource": {"name": "ansible.eda.range", "source_name": "ansible.eda.range", "source_args": {"limit": 5}, "source_filters": []}}], "rules": [{"Rule": {"name": "Say Hello", "condition": {"AllCondition": [{"EqualsExpression": {"lhs": {"Event": "i"}, "rhs": {"Integer": 1}}}]}, "actions": [{"Action": {"action": "run_job_template", "action_args": {"name": "Hello World", "organization": "Default"}}}], "enabled": true}}]}
2024-01-19 20:16:46,805 - drools.dispatch - DEBUG - Establishing async channel
2024-01-19 20:16:46,817 - ansible_rulebook.engine - INFO - load source
2024-01-19 20:16:47,077 - ansible_rulebook.engine - ERROR - Source error Could not find source plugin for ansible.eda.range
2024-01-19 20:16:47,077 - ansible_rulebook.engine - ERROR - Shutting down source: ansible.eda.range error : Could not find source plugin for ansible.eda.range

Actual results

404 error due to improper path

Expected results

Expecting the api call to use the base url.

Additional information

This was difficult enough to bring up as a server (EDA Controller + AWX).

Because I needed to have AWX and EDA on the same port, I had to configured AWX on the /awx router which is supported by the operator.

$ cat awx-demo.yml 
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx-demo
spec:
  service_type: nodeport
  ingress_type: ingress
  ingress_path: /awx

Code to reproduce the issue in the code:

>>> from urllib.parse import urljoin
>>> UNIFIED_TEMPLATE_SLUG = "/api/v2/unified_job_templates/"
>>> CONFIG_SLUG = "/api/v2/config/"
>>> host="http://awx-demo-service/awx"
>>> url = urljoin(host, href_slug)
>>> url = urljoin(host, CONFIG_SLUG)
>>> print(url)
http://awx-demo-service/api/v2/config/

^^^ Incorrect

Removing the "/" in CONFIG_SLUG:

>>> CONFIG_SLUG = "api/v2/config/"
>>> print(urljoin(host, CONFIG_SLUG))
http://awx-demo-service/awx/api/v2/config/

Using an Ansible INI file as inventory source is not supported

  • ansible-rulebook version:
__version__ = '0.9.4'
b1098dab-ac28-4b68-b604-d4b7bcebc07c
  • Python version: Python 3.10.6
  • Operating System: Ubuntu 22.04.1 LTS

Description

TASK [Gathering Facts] *********************************************************
fatal: [...]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname ...: Name or service not known", "unreachable": true}
ok: [127.0.0.1]

What I Did

~$ ansible-rulebook --verbose --inventory inventory --rulebook otx.yml
INFO:ansible_rulebook.app:Starting sources
INFO:ansible_rulebook.app:Starting rules
INFO:ansible_rulebook.engine:run_ruleset
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
INFO:ansible_rulebook.engine:ruleset define: {"name": "otx events", "hosts": ["all"], "sources": [{"EventSource": {"name": "Match all messages", "source_name": "ansible.eda.otx", "source_args": {"count": "1"}, "source_filters": []}}], "rules": [{"Rule": {"name": "Send to playboox", "condition": {"AllCondition": [{"IsDefinedExpression": {"Event": "otx"}}]}, "action": {"Action": {"action": "run_playbook", "action_args": {"name": "otx_ufw.yml"}}}, "enabled": true}}]}
INFO:ansible_rulebook.engine:load source
INFO:ansible_rulebook.engine:load source filters
INFO:ansible_rulebook.engine:Calling main in ansible.eda.otx
INFO:ansible_rulebook.engine:Waiting for event from otx events
INFO:ansible_rulebook.rule_generator:calling Send to playboox
INFO:ansible_rulebook.engine:call_action run_playbook
INFO:ansible_rulebook.engine:substitute_variables [{'name': 'otx_ufw.yml'}] [{'event': {'otx': {'ip': '193.105.210.113'}}, 'fact': {'otx': {'ip': '193.105.210.113'}}}]
INFO:ansible_rulebook.engine:action args: {'name': 'otx_ufw.yml'}
INFO:ansible_rulebook.builtin:running Ansible playbook: otx_ufw.yml
INFO:ansible_rulebook.builtin:ruleset: otx events, rule: Send to playboox
INFO:ansible_rulebook.builtin:Calling Ansible runner

PLAY [otx events] **************************************************************

TASK [Gathering Facts] *********************************************************
fatal: [...]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname ...: Name or service not known", "unreachable": true}
ok: [127.0.0.1]

TASK [debug msg] ***************************************************************
ok: [127.0.0.1] => {
    "msg": "debug task: 193.105.210.113"
}

PLAY RECAP *********************************************************************
...                        : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0   
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
^C
~$ ansible-inventory -i inventory --list
{
    "_meta": {
        "hostvars": {
            "127.0.0.1": {
                "ansible_connection": "local"
            }
        }
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    },
    "ungrouped": {
        "hosts": [
            "127.0.0.1"
        ]
    }
}
~$ cat otx*.yml
---
- name: otx events
  hosts: all
  sources:
    - name: Match all messages
      ansible.eda.otx:
        count: "1"
  rules:
    - name: Send to playboox
      condition: event.otx is defined
      action:
        run_playbook:
          name: otx_ufw.yml
...
---
- name: otx events
  hosts: all
  tasks:
    - name: debug msg
      ansible.builtin.debug:
        msg: "debug task: {{ event.otx.ip }}"
...

use lookup to set event_source arguments with environment vars

$ ansible-rulebook --version

__version__ = '0.9.4'
fca63ab1-f243-4459-97ef-bb546e3cc60d

$ ansible --version

ansible [core 2.12.2]
  config file = None
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
  
$ cat /etc/os-release 

NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal


Description

This could be a me issue because I am learning rulebooks & ansible at the same time.

---
- name: Simple Event Stream Usage Example
  hosts: all
  sources:
    - crowdstrike.falcon.eventstream:
        falcon_client_id: "{{ lookup('env', 'FALCON_CLIENT_ID') }}"
        falcon_client_secret: "{{ lookup('env', 'FALCON_CLIENT_SECRET') }}"
        falcon_cloud: "us-2"
        stream_name: "{{stream_name | default('eda')}}"

  rules:
    - name: print output
      condition: event.falcon is defined 
      action:
        debug:

Running:

ansible-rulebook -i inventory.yml --rulebook rulebooks/event_stream_example.yml --env-vars FALCON_CLIENT_ID,FALCON_CLIENT_SECRET

Results in this error (I've tried with and without --env-vars):

ERROR:ansible_rulebook.engine:Source error
Traceback (most recent call last):
 File "/usr/local/lib/python3.8/dist-packages/ansible_rulebook/engine.py", line 130, in start_source
   args = {
 File "/usr/local/lib/python3.8/dist-packages/ansible_rulebook/engine.py", line 131, in <dictcomp>
   k: substitute_variables(v, variables)
 File "/usr/local/lib/python3.8/dist-packages/ansible_rulebook/util.py", line 36, in substitute_variables
   return render_string_or_return_value(value, context)
 File "/usr/local/lib/python3.8/dist-packages/ansible_rulebook/util.py", line 28, in render_string_or_return_value
   return render_string(value, context)
 File "/usr/local/lib/python3.8/dist-packages/ansible_rulebook/util.py", line 21, in render_string
   return jinja2.Template(value, undefined=jinja2.StrictUndefined).render(
 File "/usr/local/lib/python3.8/dist-packages/jinja2/environment.py", line 1301, in render
   self.environment.handle_exception()
 File "/usr/local/lib/python3.8/dist-packages/jinja2/environment.py", line 936, in handle_exception
   raise rewrite_traceback_stack(source=source)
 File "<template>", line 1, in top-level template code
 File "/usr/local/lib/python3.8/dist-packages/jinja2/utils.py", line 83, in from_obj
   if hasattr(obj, "jinja_pass_arg"):
jinja2.exceptions.UndefinedError: 'lookup' is undefined

It looks like I do have the env lookup pluging

ansible-doc -t lookup -l | grep env
[WARNING]: Collection ibm.qradar does not support Ansible version 2.12.2
[WARNING]: Collection splunk.es does not support Ansible version 2.12.2
[WARNING]: Collection frr.frr does not support Ansible version 2.12.2
env                                               Read the value of environ...
 `ansible-rulebook -i inventory.yml --rulebook rulebooks/event_stream_example.yml --env-vars FALCON_CLIENT_ID,FALCON_CLIENT_SECRET`

jpy can not be compiled with python3.11

jpy can not be compiled with python3.11, as a consequence ansible-rulebook installation fails.
@benthomasson @mkanoor

PIP_NO_BINARY=jpy pip install jpy 
DEPRECATION: --no-binary currently disables reading from the cache of locally built wheels. In the future --no-binary will not influence the wheel cache. pip 23.1 will enforce this behaviour change. A possible replacement is to use the --no-cache-dir option. You can use the flag --use-feature=no-binary-enable-wheel-cache to test the upcoming behaviour. Discussion can be found at https://github.com/pypa/pip/issues/11453
Collecting jpy
  Using cached jpy-0.12.0.tar.gz (171 kB)
  Preparing metadata (setup.py) ... done
Installing collected packages: jpy
  DEPRECATION: jpy is being installed using the legacy 'setup.py install' method, because the '--no-binary' option was enabled for it and this currently disables local wheel building for projects that don't have a 'pyproject.toml' file. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/11451
  Running setup.py install for jpy ... error
  error: subprocess-exited-with-error
  
  ร— Running setup.py install for jpy did not run successfully.
  โ”‚ exit code: 1
  โ•ฐโ”€> [198 lines of output]
      /usr/local/lib/python3.11/site-packages/setuptools/dist.py:771: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
        warnings.warn(
      running install
      /usr/local/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
      copying jpyutil.py -> build/lib.linux-x86_64-cpython-311
      running build_ext
      building 'jpy' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/src
      creating build/temp.linux-x86_64-cpython-311/src/main
      creating build/temp.linux-x86_64-cpython-311/src/main/c
      creating build/temp.linux-x86_64-cpython-311/src/main/c/jni
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Isrc/main/c -I/usr/lib/jvm/java-17-openjdk-amd64/include -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux -I/usr/local/include/python3.11 -c src/main/c/jni/org_jpy_PyLib.c -o build/temp.linux-x86_64-cpython-311/src/main/c/jni/org_jpy_PyLib.o
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜Java_org_jpy_PyLib_setPythonHomeโ€™:
      src/main/c/jni/org_jpy_PyLib.c:170:31: warning: passing argument 1 of โ€˜PyMem_RawFreeโ€™ discards โ€˜constโ€™ qualifier from pointer target type [-Wdiscarded-qualifiers]
        170 |                 PyMem_RawFree(pythonHome);
            |                               ^~~~~~~~~~
      In file included from /usr/local/include/python3.11/pymem.h:96,
                       from /usr/local/include/python3.11/Python.h:41,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/cpython/pymem.h:8:38: note: expected โ€˜void *โ€™ but argument is of type โ€˜const wchar_t *โ€™ {aka โ€˜const int *โ€™}
          8 | PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
            |                                ~~~~~~^~~
      src/main/c/jni/org_jpy_PyLib.c:184:13: warning: โ€˜Py_SetPythonHomeโ€™ is deprecated [-Wdeprecated-declarations]
        184 |             Py_SetPythonHome(staticPythonHome);
            |             ^~~~~~~~~~~~~~~~
      In file included from /usr/local/include/python3.11/Python.h:94,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/pylifecycle.h:40:38: note: declared here
         40 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *);
            |                                      ^~~~~~~~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:187:27: warning: passing argument 1 of โ€˜PyMem_RawFreeโ€™ discards โ€˜constโ€™ qualifier from pointer target type [-Wdiscarded-qualifiers]
        187 |             PyMem_RawFree(pythonHome);
            |                           ^~~~~~~~~~
      In file included from /usr/local/include/python3.11/pymem.h:96,
                       from /usr/local/include/python3.11/Python.h:41,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/cpython/pymem.h:8:38: note: expected โ€˜void *โ€™ but argument is of type โ€˜const wchar_t *โ€™ {aka โ€˜const int *โ€™}
          8 | PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
            |                                ~~~~~~^~~
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜Java_org_jpy_PyLib_setProgramNameโ€™:
      src/main/c/jni/org_jpy_PyLib.c:237:31: warning: passing argument 1 of โ€˜PyMem_RawFreeโ€™ discards โ€˜constโ€™ qualifier from pointer target type [-Wdiscarded-qualifiers]
        237 |                 PyMem_RawFree(programName);
            |                               ^~~~~~~~~~~
      In file included from /usr/local/include/python3.11/pymem.h:96,
                       from /usr/local/include/python3.11/Python.h:41,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/cpython/pymem.h:8:38: note: expected โ€˜void *โ€™ but argument is of type โ€˜const wchar_t *โ€™ {aka โ€˜const int *โ€™}
          8 | PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
            |                                ~~~~~~^~~
      src/main/c/jni/org_jpy_PyLib.c:251:13: warning: โ€˜Py_SetProgramNameโ€™ is deprecated [-Wdeprecated-declarations]
        251 |             Py_SetProgramName(staticProgramName);
            |             ^~~~~~~~~~~~~~~~~
      In file included from /usr/local/include/python3.11/Python.h:94,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/pylifecycle.h:37:38: note: declared here
         37 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
            |                                      ^~~~~~~~~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:254:27: warning: passing argument 1 of โ€˜PyMem_RawFreeโ€™ discards โ€˜constโ€™ qualifier from pointer target type [-Wdiscarded-qualifiers]
        254 |             PyMem_RawFree(programName);
            |                           ^~~~~~~~~~~
      In file included from /usr/local/include/python3.11/pymem.h:96,
                       from /usr/local/include/python3.11/Python.h:41,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/cpython/pymem.h:8:38: note: expected โ€˜void *โ€™ but argument is of type โ€˜const wchar_t *โ€™ {aka โ€˜const int *โ€™}
          8 | PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
            |                                ~~~~~~^~~
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜Java_org_jpy_PyLib_startPython0โ€™:
      src/main/c/jni/org_jpy_PyLib.c:280:9: warning: โ€˜PySys_SetArgvExโ€™ is deprecated [-Wdeprecated-declarations]
        280 |         PySys_SetArgvEx(0, NULL, 0);
            |         ^~~~~~~~~~~~~~~
      In file included from /usr/local/include/python3.11/Python.h:96,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/sysmodule.h:14:38: note: declared here
         14 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
            |                                      ^~~~~~~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:284:9: warning: โ€˜PyEval_InitThreadsโ€™ is deprecated [-Wdeprecated-declarations]
        284 |         PyEval_InitThreads();
            |         ^~~~~~~~~~~~~~~~~~
      In file included from /usr/local/include/python3.11/Python.h:95,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/ceval.h:132:37: note: declared here
        132 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
            |                                     ^~~~~~~~~~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜Java_org_jpy_PyLib_executeCodeโ€™:
      src/main/c/jni/org_jpy_PyLib.c:1024:16: warning: returning โ€˜void *โ€™ from a function with return type โ€˜jlongโ€™ {aka โ€˜long intโ€™} makes integer from pointer without a cast [-Wint-conversion]
       1024 |         return NULL;
            |                ^~~~
      src/main/c/jni/org_jpy_PyLib.c:1029:101: warning: passing argument 7 of โ€˜executeInternalโ€™ discards โ€˜constโ€™ qualifier from pointer target type [-Wdiscarded-qualifiers]
       1029 |     result = executeInternal(jenv, jLibClass, jStart, jGlobals, jLocals, (DoRun)pyRunStringWrapper, codeChars);
            |                                                                                                     ^~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:890:128: note: expected โ€˜void *โ€™ but argument is of type โ€˜const char *โ€™
        890 | jlong executeInternal(JNIEnv* jenv, jclass jLibClass, jint jStart, jobject jGlobals, jobject jLocals, DoRun runFunction, void *runArg) {
            |                                                                                                                          ~~~~~~^~~~~~
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜Java_org_jpy_PyLib_getTypeโ€™:
      src/main/c/jni/org_jpy_PyLib.c:1364:14: warning: assignment to โ€˜PyObject *โ€™ {aka โ€˜struct _object *โ€™} from incompatible pointer type โ€˜PyTypeObject *โ€™ {aka โ€˜struct _typeobject *โ€™} [-Wincompatible-pointer-types]
       1364 |     pyObject = ((PyObject*) objId)->ob_type;
            |              ^
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜PyLib_CallAndReturnObjectโ€™:
      src/main/c/jni/org_jpy_PyLib.c:2350:68: warning: passing argument 4 of โ€˜PyLib_FromJObjectForTupleโ€™ discards โ€˜constโ€™ qualifier from pointer target type [-Wdiscarded-qualifiers]
       2350 |         pyArg = PyLib_FromJObjectForTuple(jenv, jArg, jParamClass, nameChars, i);
            |                                                                    ^~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:2270:91: note: expected โ€˜char *โ€™ but argument is of type โ€˜const char *โ€™
       2270 | PyObject* PyLib_FromJObjectForTuple(JNIEnv *jenv, jobject jArg, jclass jParamClass, char* nameChars, jint index) {
            |                                                                                     ~~~~~~^~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:2319:16: warning: unused variable โ€˜jArgParamTypeโ€™ [-Wunused-variable]
       2319 |     JPy_JType* jArgParamType;
            |                ^~~~~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:2318:16: warning: unused variable โ€˜explicitParamTypeโ€™ [-Wunused-variable]
       2318 |     JPy_JType* explicitParamType = NULL;
            |                ^~~~~~~~~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜PyLib_HandlePythonExceptionโ€™:
      src/main/c/jni/org_jpy_PyLib.c:2466:36: warning: passing argument 3 of โ€˜PyErr_Fetchโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
       2466 |     PyErr_Fetch(&pyType, &pyValue, &pyTraceback);
            |                                    ^~~~~~~~~~~~
            |                                    |
            |                                    PyTracebackObject ** {aka struct _traceback **}
      In file included from /usr/local/include/python3.11/Python.h:88,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/pyerrors.h:19:56: note: expected โ€˜PyObject **โ€™ {aka โ€˜struct _object **โ€™} but argument is of type โ€˜PyTracebackObject **โ€™ {aka โ€˜struct _traceback **โ€™}
         19 | PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
            |                                                        ^~~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:2469:49: warning: passing argument 3 of โ€˜PyErr_NormalizeExceptionโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
       2469 |     PyErr_NormalizeException(&pyType, &pyValue, &pyTraceback);
            |                                                 ^~~~~~~~~~~~
            |                                                 |
            |                                                 PyTracebackObject ** {aka struct _traceback **}
      In file included from /usr/local/include/python3.11/Python.h:88,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/pyerrors.h:40:67: note: expected โ€˜PyObject **โ€™ {aka โ€˜struct _object **โ€™} but argument is of type โ€˜PyTracebackObject **โ€™ {aka โ€˜struct _traceback **โ€™}
         40 | PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
            |                                                                   ^~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:2490:63: warning: passing argument 1 of โ€˜PyObject_GetAttrStringโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
       2490 |         linenoChars = PyLib_ObjToChars(PyObject_GetAttrString(pyTraceback, "tb_lineno"), &pyLinenoUtf8);
            |                                                               ^~~~~~~~~~~
            |                                                               |
            |                                                               PyTracebackObject * {aka struct _traceback *}
      In file included from /usr/local/include/python3.11/Python.h:44,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/object.h:289:47: note: expected โ€˜PyObject *โ€™ {aka โ€˜struct _object *โ€™} but argument is of type โ€˜PyTracebackObject *โ€™ {aka โ€˜struct _traceback *โ€™}
        289 | PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *);
            |                                               ^~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:2491:42: warning: passing argument 1 of โ€˜PyObject_GetAttrStringโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
       2491 |         pyFrame = PyObject_GetAttrString(pyTraceback, "tb_frame");
            |                                          ^~~~~~~~~~~
            |                                          |
            |                                          PyTracebackObject * {aka struct _traceback *}
      In file included from /usr/local/include/python3.11/Python.h:44,
                       from src/main/c/jni/org_jpy_PyLib.c:21:
      /usr/local/include/python3.11/object.h:289:47: note: expected โ€˜PyObject *โ€™ {aka โ€˜struct _object *โ€™} but argument is of type โ€˜PyTracebackObject *โ€™ {aka โ€˜struct _traceback *โ€™}
        289 | PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *);
            |                                               ^~~~~~~~~~
      src/main/c/jni/org_jpy_PyLib.c:2530:47: warning: passing argument 1 of โ€˜python_traceback_reportโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
       2530 |             int err = python_traceback_report(pyTraceback, &javaMessage, &bufLen);
            |                                               ^~~~~~~~~~~
            |                                               |
            |                                               PyTracebackObject * {aka struct _traceback *}
      src/main/c/jni/org_jpy_PyLib.c:48:46: note: expected โ€˜PyObject *โ€™ {aka โ€˜struct _object *โ€™} but argument is of type โ€˜PyTracebackObject *โ€™ {aka โ€˜struct _traceback *โ€™}
         48 | static int python_traceback_report(PyObject *tb, char **buf, int* bufLen);
            |                                    ~~~~~~~~~~^~
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜append_to_java_messageโ€™:
      src/main/c/jni/org_jpy_PyLib.c:2702:35: warning: comparison of integer expressions of different signedness: โ€˜size_tโ€™ {aka โ€˜long unsigned intโ€™} and โ€˜intโ€™ [-Wsign-compare]
       2702 |     if (strlen(*buf) + msgLen + 1 >= *bufLen) {
            |                                   ^~
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜format_python_tracebackโ€™:
      src/main/c/jni/org_jpy_PyLib.c:2743:25: error: invalid use of incomplete typedef โ€˜PyFrameObjectโ€™ {aka โ€˜struct _frameโ€™}
       2743 |             tb->tb_frame->f_code->co_filename != last_file ||
            |                         ^~
      src/main/c/jni/org_jpy_PyLib.c:2745:46: error: invalid use of incomplete typedef โ€˜PyFrameObjectโ€™ {aka โ€˜struct _frameโ€™}
       2745 |             last_name == NULL || tb->tb_frame->f_code->co_name != last_name) {
            |                                              ^~
      src/main/c/jni/org_jpy_PyLib.c:2752:37: error: invalid use of incomplete typedef โ€˜PyFrameObjectโ€™ {aka โ€˜struct _frameโ€™}
       2752 |             last_file = tb->tb_frame->f_code->co_filename;
            |                                     ^~
      src/main/c/jni/org_jpy_PyLib.c:2754:37: error: invalid use of incomplete typedef โ€˜PyFrameObjectโ€™ {aka โ€˜struct _frameโ€™}
       2754 |             last_name = tb->tb_frame->f_code->co_name;
            |                                     ^~
      src/main/c/jni/org_jpy_PyLib.c:2760:46: error: invalid use of incomplete typedef โ€˜PyFrameObjectโ€™ {aka โ€˜struct _frameโ€™}
       2760 |                                  tb->tb_frame->f_code->co_filename,
            |                                              ^~
      src/main/c/jni/org_jpy_PyLib.c:2762:46: error: invalid use of incomplete typedef โ€˜PyFrameObjectโ€™ {aka โ€˜struct _frameโ€™}
       2762 |                                  tb->tb_frame->f_code->co_name);
            |                                              ^~
      src/main/c/jni/org_jpy_PyLib.c: In function โ€˜python_traceback_reportโ€™:
      src/main/c/jni/org_jpy_PyLib.c:2781:36: warning: passing argument 1 of โ€˜format_python_tracebackโ€™ from incompatible pointer type [-Wincompatible-pointer-types]
       2781 |     return format_python_traceback(tb, buf, bufLen);
            |                                    ^~
            |                                    |
            |                                    PyObject * {aka struct _object *}
      src/main/c/jni/org_jpy_PyLib.c:2721:55: note: expected โ€˜PyTracebackObject *โ€™ {aka โ€˜struct _traceback *โ€™} but argument is of type โ€˜PyObject *โ€™ {aka โ€˜struct _object *โ€™}
       2721 | static int format_python_traceback(PyTracebackObject *tb, char **buf, int *bufLen)
            |                                    ~~~~~~~~~~~~~~~~~~~^~
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

ร— Encountered error while trying to install package.
โ•ฐโ”€> jpy

Depends on jpy-consortium/jpy#95

The event that triggered the playbook is not passed to the playbook

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

Hello. I have a weird issue recently. The playbook invoked by the rulebook doesn't know about the event that triggered it:
TASK [debug] *******************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'event' is undefined. 'event' is undefined\n\nThe error appears to be in '/tmp/run_playbookj7pb1b06/project/say-what.yml': line 7, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line
appears to be:\n\n tasks:\n - debug:\n ^ here\n"}
The code with issue is:

Environment

Redhat8

Steps to reproduce

Use https://github.com/ansible/ansible-rulebook/blob/main/Dockerfile to build a images, deploy and run it, have the rulebook listen to port 5010. send a webhook message:
curl -H 'Content-Type: application/json' -d "{"message": "Ansible is super cool", "sender": "deployer node"}" http://localhost:5010/endpoint

Actual results

Playbook fails with:
TASK [debug] *******************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'event' is undefined. 'event' is undefined\n\nThe error appears to be in '/tmp/run_playbookj7pb1b06/project/say-what.yml': line 7, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line
appears to be:\n\n tasks:\n - debug:\n ^ here\n"}
The code with issue is:

  • debug:
    msg: "Thank you!!!! {{ event.payload.sender }}!"

Expected results

playbook should run successfully and display: Thank you!!!! deployer node

Additional information

No response

Support Ansible Vault

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Feature type

New Feature

Feature Summary

Please add support for Ansible Vault.

Steps to reproduce

# Plaintext YAML file
$ cat secrets_file.enc
webhook_token: SuperSecretToken

# Encrypt the file with ansible-vault
$ ansible-vault encrypt secrets_file.enc
New Vault password:
Confirm New Vault password:
Encryption successful
# Rulebook
$ cat secrets-rulebook.yaml
- name: secrets example
  hosts: all
  sources:
    - ansible.eda.webhook:
        token: "{{ webhook_token }}"
$ ansible-rulebook --rulebook secrets-example.yml -i inventory.yml -e @secrets_file.enc

Current results

Variables are currently only read from a clear-text yaml files.

Sugested feature result

Support for secure use of sensitive data.

Additional information

Thank you.

Leverage inventory plugins for actions

  • ansible-rulebook version: 0.10.1
  • Python version: 3.11.0
  • Operating System: fedora:37

Description

I am trying to leverage the aws inventory plugin for an action. I would like my action to run against ec2 instances deployed in aws. The aws inventory plugin allows me to dynamically look up the instances I want to run against using the aws API.

I would also like to leverage the aws ssm connection plugin.

What I Did

I am running ansible-rulebook pointed to my aws inventory. This is the same inventory I want my action to use.

ansible-rulebook --rulebook rulebook.yml -i inventory/aws_ec2.yml --verbose

My rulebook...

---
- name: Listen for events on a webhook
  hosts: all
  sources:
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5000
  rules:
    - name: Prepare build server
      condition: event.payload.message == "Prep Build Server"
      action:
        run_playbook:
          name: tasks/build_server.yml

The file tasks/build_server.yml

- hosts: build_server
  vars:
    ansible_connection: aws_ssm
    ansible_aws_ssm_bucket_name: ansible-eda-demo
    ansible_aws_ssm_region: us-east-1
  tasks:
  - name: Install all packages for bender
    dnf:
      name:
      - python3-pip
      - buildah
      - podman
      - ansible
      - docker
  - name: Start dockerd
    systemd:
      name: docker
      state: started
  - name: install bender
    pip:
      name:
      - ansible-bender

My inventory leveraging the aws inventory plugin

plugin: aws_ec2
regions:
  - us-east-1
filters:
  instance-state-name: running
compose:
  ansible_host: instance_id
keyed_groups:
  - key: tags.Name
    separator: ''

Here is the output when ansible-rulebook attempts to run the action build_server.

2/3/2023, 2:16:41 PM | PLAY RECAP *************** | eda-demo
2/3/2023, 2:16:41 PM | skipping: no hosts matched | eda-demo
2/3/2023, 2:16:41 PM | [WARNING]: * Failed to parse /tmp/run_playbookmfk3b58g/inventory/hosts with | eda-demo
2/3/2023, 2:16:41 PM | yaml plugin: Plugin configuration YAML file, not YAML inventory | eda-demo
2/3/2023, 2:16:41 PM | [WARNING]: * Failed to parse /tmp/run_playbookmfk3b58g/inventory/hosts with | eda-demo
2/3/2023, 2:16:41 PM | ini plugin: Invalid host pattern 'compose:' supplied, ending in ':' is not | eda-demo
2/3/2023, 2:16:41 PM | allowed, this character is reserved to provide a port. | eda-demo
2/3/2023, 2:16:41 PM | [WARNING]: Unable to parse /tmp/run_playbookmfk3b58g/inventory/hosts as an | eda-demo
2/3/2023, 2:16:41 PM | inventory source | eda-demo
2/3/2023, 2:16:41 PM | [WARNING]: Unable to parse /tmp/run_playbookmfk3b58g/inventory as an inventory | eda-demo
2/3/2023, 2:16:41 PM | source | eda-demo
2/3/2023, 2:16:41 PM | [WARNING]: No inventory was parsed, only implicit localhost is available | eda-demo
2/3/2023, 2:16:41 PM | [WARNING]: provided hosts list is empty, only localhost is available. Note that | eda-demo
2/3/2023, 2:16:41 PM | the implicit localhost does not match 'all' | eda-demo
2/3/2023, 2:16:41 PM | [WARNING]: Could not match supplied host pattern, ignoring: build_server | eda-demo

From the output, it appears the action run is looking for a default host file and not the inventory that ansible-rulebook was passed. What inventory do the actions use? Is it possible to get an action to use a custom inventory?

Webhook triggers only if endpoint url is not empty

  • ansible-rulebook version:
__version__ = '0.9.4'
ad5944ee-3782-48d6-8dae-1e924d00197f
  • Python version: 3.10.8
    • aiohttp: 3.8.3
  • Operating System: MacOS, Ubuntu

Description

Webhook listener does trigger only if endpoint url in not empty, i.e. it's not possible to configure listener on / url.

Example code:

- name: example webhook
  hosts: all
  sources:
    - ansible.eda.webhook:
        host: localhost
        port: 5000

  rules:
    - name: trigger when meta is defined
      condition: event.meta is defined
      action:
        debug:

Execute:

ansible-rulebook --rulebook example.yml -i hosts.yml --verbose

What I Did

Example requests:

> curl -d "{\"data\": \"example\"}" http://localhost:5000/someurl 
webhook

Ansible-rulebook outputs:

INFO:aiohttp.access:127.0.0.1 [21/Nov/2022:17:39:41 +0000] "POST /someurl HTTP/1.1" 200 158 "-" "curl/7.79.1"
INFO:ansible_rulebook.rule_generator:calling trigger when meta is defined
INFO:ansible_rulebook.engine:call_action debug
INFO:ansible_rulebook.engine:substitute_variables [{}] [{'event': {'payload': {'data': 'example'}, 'meta': {'headers': {'Content_Type': 'application/x-www-form-urlencoded', 'Content_Length': '19', 'Accept': '*/*', 'Host': 'localhost:43005', 'User_Agent': 'curl/7.79.1'}, 'endpoint': 'someurl'}}, 'fact': {'payload': {'data': 'example'}, 'meta': {'headers': {'Content_Type': 'application/x-www-form-urlencoded', 'Content_Length': '19', 'Accept': '*/*', 'Host': 'localhost:5000', 'User_Agent': 'curl/7.79.1'}, 'endpoint': 'someurl'}}}]
INFO:ansible_rulebook.engine:action args: {}
============================================================================================================================================================================================================

When I make request to root url:

> curl -d "{\"data\": \"example\"}" http://localhost:5000/       
404: Not Found

Ansible-rulebook log outputs:

INFO:aiohttp.access:127.0.0.1 [21/Nov/2022:17:41:03 +0000] "POST / HTTP/1.1" 404 173 "-" "curl/7.79.1"

This issue is a copy of ansible/event-driven-ansible#57

No module named 'watchdog' error weh

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

When following the instructions at main/docs/installation.rst, on a fresh installation of Ubuntu Server you get a traceback ending with no module named watchdog found. I followed the instructions to a tee and also got the same result on Fedora server although I am not as familiar with Fedora so that may be my fault who knows.
I searched for other issues with the keyword "watchdog" and found nothing but I apologize if this is a duplicate.

Environment

Ubuntu 22.04.3 LTS Server
openjdk 17 installed with apt
python 3.10.12 preinstalled
pip3 installed with apt

Steps to reproduce

Install Ubuntu

apt-get --assume-yes install openjdk-17-jdk python3-pip
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH=$PATH:~/.local/bin
pip3 install ansible ansible-rulebook ansible-runner

from the docs
ansible-rulebook

Actual results

Traceback (most recent call last):
  File "/home/charlespick/.local/bin/ansible-rulebook", line 5, in <module>
    from ansible_rulebook.cli import main
  File "/home/charlespick/.local/lib/python3.10/site-packages/ansible_rulebook/cli.py", line 35, in <module>
    from ansible_rulebook import app  # noqa: E402
  File "/home/charlespick/.local/lib/python3.10/site-packages/ansible_rulebook/app.py", line 32, in <module>
    from ansible_rulebook.engine import run_rulesets, start_source
  File "/home/charlespick/.local/lib/python3.10/site-packages/ansible_rulebook/engine.py", line 25, in <module>
    from watchdog.events import FileSystemEventHandler
ModuleNotFoundError: No module named 'watchdog'

Expected results

Help message or results when run with parameters and rulebook

Additional information

No response

Reserved keywords can be overridden by action_args gives the error "got multiple values for keyword argument 'facts'"

  • ansible-events version: 0.4.0
  • Python version: 3.9.13
  • Operating System: Mac OS

Description

If an action has attribute names that conflict with the arguments being passed to the action we get an error

ERROR:root:Error calling run_playbook: ansible_events.builtin.run_playbook() got multiple values for keyword argument 'facts'

What I Did

Create a playbook with the following contents
---
- name: Demo rules multiple conditions reference assignment
  hosts: localhost
  sources:
    - benthomasson.eda.range:
        limit: 5
  rules:
    - name: multiple conditions
      condition:
        all:
          - event.i == 0
          - event.i == 1
      action:
        run_playbook:
          name: hello_playbook.yml
          post_events: true
          events: 12345
          facts: 789
          hello: "world"

The facts is being redefined by the user. We might have to protect the variables that we use when we call the action
https://github.com/benthomasson/ansible-events/blob/42102e2ecc1178c5243171fc7afa9bc8c3b754a2/ansible_events/engine.py#L198

rulebook json schema is invalid

The current JSON Schema file is invalid for at least two reasons and I would suggest running some schema validation using both python-jsonschema and the ajv library in order to ensure that the schema file can be consumed by most clients.

Identified problems:

Blocking: ansible/ansible-lint#3103

The run_job_template action is not passing the host limit correctly

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

When a condition is triggered, the run_job_template action is not successfully passing the limit variable to Automation Controller.

The log output from EDA looks correct, as seen in the 'Actual Results' log output, but Controller shows the limit as 'Limit: {{ event.payload.meta.hosts }}'

Environment

version = '0.13.0'
Executable location = /opt/app-root/bin/ansible-rulebook
Drools_jpy version = 0.3.1
Java home = /usr/lib/jvm/java-17-openjdk
Java version = 17.0.7
Python version = 3.9.16 (main, Dec 21 2022, 10:57:18) [GCC 8.5.0 20210514 (Red Hat 8.5.0-17)]

Steps to reproduce

Testing via curl

curl -X POST http://192.168.6.109:5000/endpoint -d '{"message": "BGP neighbor down","meta": {"hosts": "leaf3"}}' -H 'Content-Type: application/json'

Actual results

EDA log output

2023-05-18 17:03:06,051 - ansible_rulebook.engine - INFO - ruleset define: {"name": "Example", "hosts": ["all"], "sources": [{"EventSource": {"name": "ansible.eda.webhook", "source_name": "ansible.eda.webhook", "source_args": {"host": "0.0.0.0", "port": 5000}, "source_filters": []}}], "rules": [{"Rule": {"name": "Get device info if BGP neighbor down", "condition": {"AllCondition": [{"EqualsExpression": {"lhs": {"Event": "payload.message"}, "rhs": {"String": "BGP neighbor down"}}}]}, "actions": [{"Action": {"action": "run_job_template", "action_args": {"name": "Parsers", "job_args": {"limit": "{{ event.payload.meta.hosts }}"}, "organization": "MackNet"}}}], "enabled": true}}]}

2023-05-18 17:03:06,070 - ansible_rulebook.engine - INFO - load source

2023-05-18 17:03:07,047 - ansible_rulebook.engine - INFO - load source filters

2023-05-18 17:03:07,047 - ansible_rulebook.engine - INFO - loading eda.builtin.insert_meta_info

2023-05-18 17:03:08,189 - ansible_rulebook.engine - INFO - Calling main in ansible.eda.webhook

2023-05-18 17:03:08,194 - ansible_rulebook.websocket - INFO - websocket wss://host.containers.internal/api/eda/ws/ansible-rulebook connecting

2023-05-18 17:03:08,202 - ansible_rulebook.engine - INFO - Waiting for all ruleset tasks to end

2023-05-18 17:03:08 204 [drools-async-evaluator-thread] INFO org.drools.ansible.rulebook.integration.api.io.RuleExecutorChannel - Async channel connected

2023-05-18 17:03:08,249 - ansible_rulebook.rule_set_runner - INFO - Waiting for actions on events from Example

2023-05-18 17:03:08,249 - ansible_rulebook.rule_set_runner - INFO - Waiting for events, ruleset: Example

2023-05-18 17:03:08,285 - ansible_rulebook.websocket - INFO - websocket wss://host.containers.internal/api/eda/ws/ansible-rulebook connected

2023-05-18 17:03:42,874 - aiohttp.access - INFO - 10.0.2.100 [18/May/2023:17:03:42 +0000] "POST /endpoint HTTP/1.1" 200 158 "-" "curl/7.87.0"

2023-05-18 17:03:43 011 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.RegisterOnlyAgendaFilter - Activation of effective rule "Get device info if BGP neighbor down" with facts: {m={payload={meta={hosts=leaf3}, message=BGP neighbor down}, meta={headers={Accept=*/*, User-Agent=curl/7.87.0, Host=192.168.6.109:5000, Content-Length=59, Content-Type=application/json}, endpoint=endpoint, received_at=2023-05-18T17:03:42.870982Z, source={name=ansible.eda.webhook, type=ansible.eda.webhook}, uuid=a1cf2a8c-2af9-45e6-99c6-eb5e4560b059}}}

2023-05-18 17:03:43,034 - ansible_rulebook.rule_generator - INFO - calling Get device info if BGP neighbor down

2023-05-18 17:03:43,036 - ansible_rulebook.rule_set_runner - INFO - call_action run_job_template

2023-05-18 17:03:43,038 - ansible_rulebook.rule_set_runner - INFO - substitute_variables [{'name': 'Parsers', 'job_args': {'limit': '{{ event.payload.meta.hosts }}'}, 'organization': 'MackNet'}] [{'event': {'payload': {'meta': {'hosts': 'leaf3'}, 'message': 'BGP neighbor down'}, 'meta': {'headers': {'Accept': '*/*', 'User-Agent': 'curl/7.87.0', 'Host': '192.168.6.109:5000', 'Content-Length': '59', 'Content-Type': 'application/json'}, 'endpoint': 'endpoint', 'received_at': '2023-05-18T17:03:42.870982Z', 'source': {'name': 'ansible.eda.webhook', 'type': 'ansible.eda.webhook'}, 'uuid': 'a1cf2a8c-2af9-45e6-99c6-eb5e4560b059'}}}]

2023-05-18 17:03:43,054 - ansible_rulebook.rule_set_runner - INFO - action args: {'name': 'Parsers', 'job_args': {'limit': 'leaf3'}, 'organization': 'MackNet'}

2023-05-18 17:03:43,054 - ansible_rulebook.builtin - INFO - running job template: Parsers, organization: MackNet

2023-05-18 17:03:43,055 - ansible_rulebook.builtin - INFO - ruleset: Example, rule Get device info if BGP neighbor down

Controller limit setting:

Screenshot 2023-05-18 at 11 17 53 AM

Expected results

Automation controller shows the correct host limit and not the variable string.

Additional information

No response

Ansible-Rule passing incorrect payload information after first execution of run

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

Using Ansible Rulebook to pass along events payloads to the playbook, on first action/trigger and execution everything works as expected, when a second execution comes along instead of the proper events payload that i would expect to be sent, it sends the entire post instead of just the payload from the post.

Environment

[root@8cb336c8-8dc8-4fee-b9f1-fdaa7ec4cc61 f5-bd-ansible-security-labs]# ansible-rulebook --version
__version__ = '0.13.0'
  Executable location = /usr/local/bin/ansible-rulebook
  Drools_jpy version = 0.3.1
  Java home = /usr/lib/jvm/java-17-openjdk-17.0.7.0.7-1.el8_7.x86_64
  Java version = 17.0.7
  Python version = 3.9.13 (main, Nov  9 2022, 13:16:24) [GCC 8.5.0 20210514 (Red Hat 8.5.0-15)]

[root@8cb336c8-8dc8-4fee-b9f1-fdaa7ec4cc61 f5-bd-ansible-security-labs]# cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.7 (Ootpa)
[root@8cb336c8-8dc8-4fee-b9f1-fdaa7ec4cc61 f5-bd-ansible-security-labs]# 

Steps to reproduce

My Code can be found at https://github.com/f5devcentral/f5-bd-ansible-security-labs

The specific code i was launching was this rulebook - https://github.com/f5devcentral/f5-bd-ansible-security-labs/blob/main/rulebooks/webhook-block-ips.yaml
and this playbook from the rulebook - https://github.com/f5devcentral/f5-bd-ansible-security-labs/blob/main/f5-playbooks/block-ips-playbook/block-ips.yaml

I was in the base folder executing like the following -

[root@8cb336c8-8dc8-4fee-b9f1-fdaa7ec4cc61 f5-bd-ansible-security-labs]# ansible-rulebook --rulebook rulebooks/webhook-block-ips.yaml --inventory ../inventory/inventory_2.yml --print-events --verbose 

inventory file

[root@8cb336c8-8dc8-4fee-b9f1-fdaa7ec4cc61 f5-bd-ansible-security-labs]# cat ../inventory/inventory_2.yml 
[all:vars]
lab_version="udf"
#ansible_python_interpreter=/usr/bin/python3

[lb]
f5 ansible_host=10.1.1.4 ansible_user=admin ansible_password=supersecretpassword server_port=443

[local_system]
ansible-local ansible_host=10.1.1.11 ansible_user=root  

Actual results

This is the code i didnt expect to happen as you can see its the full post rather than the payload

TASK [debug] *******************************************************************
ok: [f5] => {
    "msg": {
        "meta": {
            "endpoint": "endpoint",
            "headers": {
                "Accept-Charset": "UTF-8",
                "Accept-Encoding": "gzip,deflate",
                "Connection": "Keep-Alive",
                "Content-Length": "376",
                "Content-Type": "application/json; charset=UTF-8",
                "Host": "10.1.1.11:5000",
                "User-Agent": "Apache-HttpClient/4.5.10 (Java/16.0.2)"
            },
            "received_at": "2023-05-17T19:45:02.128666Z",
            "source": {
                "name": "ansible.eda.webhook",
                "type": "ansible.eda.webhook"
            },
            "uuid": "ddf1b125-1e9b-45d0-bd71-c5a3f338bd57"
        },
        "payload": {
            "message": "Ansible Please Block Some IPs",
            "payload": "61.159.83.27, 106.31.225.181, 124.113.69.146, 110.193.169.10, 36.105.233.171, 36.117.197.225, 113.91.81.178, 115.207.239.18, 110.252.60.154, 117.42.208.29, 121.227.208.31, 121.227.153.3, 46.250.37.60, 118.224.199.107, 118.89.240.8, 36.101.190.239, 80.250.71.98, 58.38.47.241, 122.76.41.113, 59.108.107.170, "
        }
    }
}

Full Execution with 1st and second triggers

[root@8cb336c8-8dc8-4fee-b9f1-fdaa7ec4cc61 f5-bd-ansible-security-labs]# ansible-rulebook --rulebook rulebooks/webhook-block-ips.yaml --inventory ../inventory/inventory_2.yml --print-events --verbose
2023-05-17 15:39:40,415 - ansible_rulebook.app - INFO - Starting sources
2023-05-17 15:39:40,415 - ansible_rulebook.app - INFO - Starting rules
2023-05-17 15:39:40,415 - ansible_rulebook.engine - INFO - run_ruleset
2023-05-17 15:39:40,415 - drools.ruleset - INFO - Using jar: /usr/local/lib/python3.9/site-packages/drools/jars/drools-ansible-rulebook-integration-runtime-1.0.1-SNAPSHOT.jar
2023-05-17 15:39:41 137 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.AbstractRulesEvaluator - Start automatic pseudo clock with a tick every 100 milliseconds
2023-05-17 15:39:41,141 - ansible_rulebook.engine - INFO - ruleset define: {"name": "Listen for events on a webhook", "hosts": ["all"], "sources": [{"EventSource": {"name": "ansible.eda.webhook", "source_name": "ansible.eda.webhook", "source_args": {"host": "0.0.0.0", "port": 5000}, "source_filters": []}}], "rules": [{"Rule": {"name": "Say Hello", "condition": {"AllCondition": [{"EqualsExpression": {"lhs": {"Event": "payload.message"}, "rhs": {"String": "Ansible Please Block Some IPs"}}}]}, "actions": [{"Action": {"action": "run_playbook", "action_args": {"name": "f5-playbooks/block-ips-playbook/block-ips.yaml", "var_root": "payload", "post_events": true}}}], "enabled": true}}]}
2023-05-17 15:39:41,161 - ansible_rulebook.engine - INFO - load source
2023-05-17 15:39:41,741 - ansible_rulebook.engine - INFO - load source filters
2023-05-17 15:39:41,741 - ansible_rulebook.engine - INFO - loading eda.builtin.insert_meta_info
2023-05-17 15:39:42,304 - ansible_rulebook.engine - INFO - Calling main in ansible.eda.webhook
2023-05-17 15:39:42,307 - ansible_rulebook.engine - INFO - Waiting for all ruleset tasks to end
2023-05-17 15:39:42,307 - ansible_rulebook.rule_set_runner - INFO - Waiting for actions on events from Listen for events on a webhook
2023-05-17 15:39:42,307 - ansible_rulebook.rule_set_runner - INFO - Waiting for events, ruleset: Listen for events on a webhook
2023-05-17 15:39:42 307 [drools-async-evaluator-thread] INFO org.drools.ansible.rulebook.integration.api.io.RuleExecutorChannel - Async channel connected



2023-05-17 15:42:02,324 - aiohttp.access - INFO - 10.1.1.5 [17/May/2023:19:42:02 +0000] "POST /endpoint HTTP/1.1" 200 158 "-" "Apache-HttpClient/4.5.10 (Java/16.0.2)"
{   'meta': {   'endpoint': 'endpoint',
                'headers': {   'Accept-Charset': 'UTF-8',
                               'Accept-Encoding': 'gzip,deflate',
                               'Connection': 'Keep-Alive',
                               'Content-Length': '373',
                               'Content-Type': 'application/json; '
                                               'charset=UTF-8',
                               'Host': '10.1.1.11:5000',
                               'User-Agent': 'Apache-HttpClient/4.5.10 '
                                             '(Java/16.0.2)'},
                'received_at': '2023-05-17T19:42:02.323578Z',
                'source': {   'name': 'ansible.eda.webhook',
                              'type': 'ansible.eda.webhook'},
                'uuid': 'f7fba787-1b15-42c6-a64e-97b1f5673c45'},
    'payload': {   'message': 'Ansible Please Block Some IPs',
                   'payload': '114.225.248.7, 122.159.243.78, 49.66.141.203, '
                              '47.98.58.62, 139.203.90.78, 43.251.247.220, '
                              '113.97.123.155, 115.170.100.80, 106.27.28.238, '
                              '49.69.74.215, 125.86.131.83, 123.160.232.22, '
                              '120.76.45.146, 112.194.39.209, 122.236.26.112, '
                              '42.187.79.104, 60.2.184.96, 60.191.138.128, '
                              '124.65.127.96, 91.191.249.134, '}}
2023-05-17 15:42:02 360 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.RegisterOnlyAgendaFilter - Activation of effective rule "Say Hello" with facts: {m={payload={payload=114.225.248.7, 122.159.243.78, 49.66.141.203, 47.98.58.62, 139.203.90.78, 43.251.247.220, 113.97.123.155, 115.170.100.80, 106.27.28.238, 49.69.74.215, 125.86.131.83, 123.160.232.22, 120.76.45.146, 112.194.39.209, 122.236.26.112, 42.187.79.104, 60.2.184.96, 60.191.138.128, 124.65.127.96, 91.191.249.134, , message=Ansible Please Block Some IPs}, meta={headers={Accept-Charset=UTF-8, Connection=Keep-Alive, User-Agent=Apache-HttpClient/4.5.10 (Java/16.0.2), Host=10.1.1.11:5000, Accept-Encoding=gzip,deflate, Content-Length=373, Content-Type=application/json; charset=UTF-8}, endpoint=endpoint, received_at=2023-05-17T19:42:02.323578Z, source={name=ansible.eda.webhook, type=ansible.eda.webhook}, uuid=f7fba787-1b15-42c6-a64e-97b1f5673c45}}}
2023-05-17 15:42:02,368 - ansible_rulebook.rule_generator - INFO - calling Say Hello
2023-05-17 15:42:02,369 - ansible_rulebook.rule_set_runner - INFO - call_action run_playbook
2023-05-17 15:42:02,369 - ansible_rulebook.rule_set_runner - INFO - Update variables [{'event': {'payload': {'payload': '114.225.248.7, 122.159.243.78, 49.66.141.203, 47.98.58.62, 139.203.90.78, 43.251.247.220, 113.97.123.155, 115.170.100.80, 106.27.28.238, 49.69.74.215, 125.86.131.83, 123.160.232.22, 120.76.45.146, 112.194.39.209, 122.236.26.112, 42.187.79.104, 60.2.184.96, 60.191.138.128, 124.65.127.96, 91.191.249.134, ', 'message': 'Ansible Please Block Some IPs'}, 'meta': {'headers': {'Accept-Charset': 'UTF-8', 'Connection': 'Keep-Alive', 'User-Agent': 'Apache-HttpClient/4.5.10 (Java/16.0.2)', 'Host': '10.1.1.11:5000', 'Accept-Encoding': 'gzip,deflate', 'Content-Length': '373', 'Content-Type': 'application/json; charset=UTF-8'}, 'endpoint': 'endpoint', 'received_at': '2023-05-17T19:42:02.323578Z', 'source': {'name': 'ansible.eda.webhook', 'type': 'ansible.eda.webhook'}, 'uuid': 'f7fba787-1b15-42c6-a64e-97b1f5673c45'}}}] with new root [payload]
2023-05-17 15:42:02,369 - ansible_rulebook.rule_set_runner - INFO - substitute_variables [{'name': 'f5-playbooks/block-ips-playbook/block-ips.yaml', 'post_events': True}] [{'event': {'payload': '114.225.248.7, 122.159.243.78, 49.66.141.203, 47.98.58.62, 139.203.90.78, 43.251.247.220, 113.97.123.155, 115.170.100.80, 106.27.28.238, 49.69.74.215, 125.86.131.83, 123.160.232.22, 120.76.45.146, 112.194.39.209, 122.236.26.112, 42.187.79.104, 60.2.184.96, 60.191.138.128, 124.65.127.96, 91.191.249.134, ', 'message': 'Ansible Please Block Some IPs'}}]
2023-05-17 15:42:02,369 - ansible_rulebook.rule_set_runner - INFO - action args: {'name': 'f5-playbooks/block-ips-playbook/block-ips.yaml', 'post_events': True}
2023-05-17 15:42:02,370 - ansible_rulebook.builtin - INFO - running Ansible playbook: f5-playbooks/block-ips-playbook/block-ips.yaml
2023-05-17 15:42:02,372 - ansible_rulebook.builtin - INFO - ruleset: Listen for events on a webhook, rule: Say Hello
2023-05-17 15:42:02,372 - ansible_rulebook.builtin - INFO - Calling Ansible runner

PLAY [ASM Policy Update with Blocked URLS, IPs or Both] ************************

TASK [Setup provider] **********************************************************
ok: [f5]

TASK [debug] *******************************************************************
ok: [f5] => {
    "msg": {
        "message": "Ansible Please Block Some IPs",
        "payload": "114.225.248.7, 122.159.243.78, 49.66.141.203, 47.98.58.62, 139.203.90.78, 43.251.247.220, 113.97.123.155, 115.170.100.80, 106.27.28.238, 49.69.74.215, 125.86.131.83, 123.160.232.22, 120.76.45.146, 112.194.39.209, 122.236.26.112, 42.187.79.104, 60.2.184.96, 60.191.138.128, 124.65.127.96, 91.191.249.134, "
    }
}

TASK [debug] *******************************************************************
ok: [f5] => {
    "msg": "114.225.248.7, 122.159.243.78, 49.66.141.203, 47.98.58.62, 139.203.90.78, 43.251.247.220, 113.97.123.155, 115.170.100.80, 106.27.28.238, 49.69.74.215, 125.86.131.83, 123.160.232.22, 120.76.45.146, 112.194.39.209, 122.236.26.112, 42.187.79.104, 60.2.184.96, 60.191.138.128, 124.65.127.96, 91.191.249.134, "
}

TASK [Create Array from BlockedIPs] ********************************************
ok: [f5]

TASK [Create Array from BlockedIPs] ********************************************
ok: [f5]

TASK [debug] *******************************************************************
ok: [f5] => {
    "msg": [
        "114.225.248.7",
        "122.159.243.78",
        "49.66.141.203",
        "47.98.58.62",
        "139.203.90.78",
        "43.251.247.220",
        "113.97.123.155",
        "115.170.100.80",
        "106.27.28.238",
        "49.69.74.215",
        "125.86.131.83",
        "123.160.232.22",
        "120.76.45.146",
        "112.194.39.209",
        "122.236.26.112",
        "42.187.79.104",
        "60.2.184.96",
        "60.191.138.128",
        "124.65.127.96",
        "91.191.249.134"
    ]
}

TASK [Fetching ASM Policy] *****************************************************
changed: [f5]

TASK [Create tmp directory if it does not exist] *******************************
ok: [f5 -> localhost]

TASK [ansible.builtin.copy] ****************************************************
changed: [f5 -> localhost]

TASK [Validate Existing IP Addresses] ******************************************
failed: [f5 -> localhost] (item=114.225.248.7) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>114.225.248.7\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.006000", "end": "2023-05-17 15:42:15.423592", "item": "114.225.248.7", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:15.417592", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=122.159.243.78) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>122.159.243.78\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.006376", "end": "2023-05-17 15:42:15.675942", "item": "122.159.243.78", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:15.669566", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=49.66.141.203) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>49.66.141.203\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.006154", "end": "2023-05-17 15:42:15.903503", "item": "49.66.141.203", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:15.897349", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=47.98.58.62) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>47.98.58.62\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005651", "end": "2023-05-17 15:42:16.133725", "item": "47.98.58.62", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:16.128074", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=139.203.90.78) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>139.203.90.78\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005888", "end": "2023-05-17 15:42:16.361906", "item": "139.203.90.78", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:16.356018", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=43.251.247.220) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>43.251.247.220\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005859", "end": "2023-05-17 15:42:16.616423", "item": "43.251.247.220", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:16.610564", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=113.97.123.155) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>113.97.123.155\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005949", "end": "2023-05-17 15:42:16.846424", "item": "113.97.123.155", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:16.840475", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=115.170.100.80) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>115.170.100.80\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005615", "end": "2023-05-17 15:42:17.074025", "item": "115.170.100.80", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:17.068410", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=106.27.28.238) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>106.27.28.238\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.006197", "end": "2023-05-17 15:42:17.308347", "item": "106.27.28.238", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:17.302150", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=49.69.74.215) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>49.69.74.215\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005887", "end": "2023-05-17 15:42:17.540660", "item": "49.69.74.215", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:17.534773", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=125.86.131.83) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>125.86.131.83\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005887", "end": "2023-05-17 15:42:17.772369", "item": "125.86.131.83", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:17.766482", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=123.160.232.22) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>123.160.232.22\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005604", "end": "2023-05-17 15:42:18.002185", "item": "123.160.232.22", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:17.996581", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=120.76.45.146) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>120.76.45.146\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.006546", "end": "2023-05-17 15:42:18.235037", "item": "120.76.45.146", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:18.228491", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=112.194.39.209) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>112.194.39.209\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.006281", "end": "2023-05-17 15:42:18.468348", "item": "112.194.39.209", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:18.462067", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=122.236.26.112) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>122.236.26.112\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.006514", "end": "2023-05-17 15:42:18.712462", "item": "122.236.26.112", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:18.705948", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=42.187.79.104) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>42.187.79.104\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005660", "end": "2023-05-17 15:42:18.952829", "item": "42.187.79.104", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:18.947169", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=60.2.184.96) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>60.2.184.96\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.006056", "end": "2023-05-17 15:42:19.182045", "item": "60.2.184.96", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:19.175989", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=60.191.138.128) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>60.191.138.128\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.006157", "end": "2023-05-17 15:42:19.410286", "item": "60.191.138.128", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:19.404129", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=124.65.127.96) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>124.65.127.96\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005954", "end": "2023-05-17 15:42:19.649318", "item": "124.65.127.96", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:19.643364", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
failed: [f5 -> localhost] (item=91.191.249.134) => {"ansible_loop_var": "item", "changed": true, "cmd": "grep \"<ip_address>91.191.249.134\" /tmp/f5/WAF-POLICY.xml", "delta": "0:00:00.005733", "end": "2023-05-17 15:42:19.875205", "item": "91.191.249.134", "msg": "non-zero return code", "rc": 1, "start": "2023-05-17 15:42:19.869472", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
...ignoring

TASK [Add Disallowed IPs] ******************************************************
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>114.225.248.7" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:15.417592', 'end': '2023-05-17 15:42:15.423592', 'delta': '0:00:00.006000', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>114.225.248.7" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '114.225.248.7', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>122.159.243.78" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:15.669566', 'end': '2023-05-17 15:42:15.675942', 'delta': '0:00:00.006376', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>122.159.243.78" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '122.159.243.78', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>49.66.141.203" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:15.897349', 'end': '2023-05-17 15:42:15.903503', 'delta': '0:00:00.006154', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>49.66.141.203" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '49.66.141.203', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>47.98.58.62" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:16.128074', 'end': '2023-05-17 15:42:16.133725', 'delta': '0:00:00.005651', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>47.98.58.62" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '47.98.58.62', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>139.203.90.78" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:16.356018', 'end': '2023-05-17 15:42:16.361906', 'delta': '0:00:00.005888', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>139.203.90.78" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '139.203.90.78', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>43.251.247.220" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:16.610564', 'end': '2023-05-17 15:42:16.616423', 'delta': '0:00:00.005859', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>43.251.247.220" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '43.251.247.220', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>113.97.123.155" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:16.840475', 'end': '2023-05-17 15:42:16.846424', 'delta': '0:00:00.005949', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>113.97.123.155" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '113.97.123.155', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>115.170.100.80" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:17.068410', 'end': '2023-05-17 15:42:17.074025', 'delta': '0:00:00.005615', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>115.170.100.80" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '115.170.100.80', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>106.27.28.238" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:17.302150', 'end': '2023-05-17 15:42:17.308347', 'delta': '0:00:00.006197', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>106.27.28.238" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '106.27.28.238', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>49.69.74.215" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:17.534773', 'end': '2023-05-17 15:42:17.540660', 'delta': '0:00:00.005887', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>49.69.74.215" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '49.69.74.215', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>125.86.131.83" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:17.766482', 'end': '2023-05-17 15:42:17.772369', 'delta': '0:00:00.005887', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>125.86.131.83" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '125.86.131.83', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>123.160.232.22" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:17.996581', 'end': '2023-05-17 15:42:18.002185', 'delta': '0:00:00.005604', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>123.160.232.22" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '123.160.232.22', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>120.76.45.146" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:18.228491', 'end': '2023-05-17 15:42:18.235037', 'delta': '0:00:00.006546', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>120.76.45.146" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '120.76.45.146', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>112.194.39.209" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:18.462067', 'end': '2023-05-17 15:42:18.468348', 'delta': '0:00:00.006281', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>112.194.39.209" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '112.194.39.209', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>122.236.26.112" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:18.705948', 'end': '2023-05-17 15:42:18.712462', 'delta': '0:00:00.006514', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>122.236.26.112" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '122.236.26.112', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>42.187.79.104" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:18.947169', 'end': '2023-05-17 15:42:18.952829', 'delta': '0:00:00.005660', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>42.187.79.104" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '42.187.79.104', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>60.2.184.96" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:19.175989', 'end': '2023-05-17 15:42:19.182045', 'delta': '0:00:00.006056', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>60.2.184.96" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '60.2.184.96', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>60.191.138.128" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:19.404129', 'end': '2023-05-17 15:42:19.410286', 'delta': '0:00:00.006157', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>60.191.138.128" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '60.191.138.128', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>124.65.127.96" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:19.643364', 'end': '2023-05-17 15:42:19.649318', 'delta': '0:00:00.005954', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>124.65.127.96" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '124.65.127.96', 'ansible_loop_var': 'item'})
changed: [f5 -> localhost] => (item={'changed': True, 'stdout': '', 'stderr': '', 'rc': 1, 'cmd': 'grep "<ip_address>91.191.249.134" /tmp/f5/WAF-POLICY.xml', 'start': '2023-05-17 15:42:19.869472', 'end': '2023-05-17 15:42:19.875205', 'delta': '0:00:00.005733', 'failed': True, 'msg': 'non-zero return code', 'invocation': {'module_args': {'_raw_params': 'grep "<ip_address>91.191.249.134" /tmp/f5/WAF-POLICY.xml', '_uses_shell': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': [], 'stderr_lines': [], 'item': '91.191.249.134', 'ansible_loop_var': 'item'})

TASK [Create an LTM policy] ****************************************************
ok: [f5 -> localhost]

TASK [Import ASM policy] *******************************************************
changed: [f5 -> localhost]

TASK [Replace a forward action with an ASM action] *****************************
ok: [f5 -> localhost]

TASK [Deploy Draft ASM policy] *************************************************
ok: [f5 -> localhost]

TASK [Activate ASM Policy] *****************************************************
ok: [f5 -> localhost]

TASK [Publish ASM Policy via TMSH] *********************************************
[WARNING]: Using "write" commands is not idempotent. You should use a module
that is specifically made for that. If such a module does not exist, then
please file a bug. The command in question is "publish asm policy WAF-
POLICY..."
ok: [f5 -> localhost]

TASK [Change ASM Policy to Blocking] *******************************************
[WARNING]: Using "write" commands is not idempotent. You should use a module
that is specifically made for that. If such a module does not exist, then
please file a bug. The command in question is "modify asm policy WAF-POLICY
blocking-mo..."
changed: [f5]

PLAY RECAP *********************************************************************
f5                         : ok=18   changed=6    unreachable=0    failed=0    skipped=0    rescued=0    ignored=1   

  
2023-05-17 15:43:14,316 - ansible_rulebook.builtin - INFO - Ansible Runner Queue task cancelled
2023-05-17 15:43:14,317 - ansible_rulebook.builtin - INFO - Playbook rc: 0, status: successful
2023-05-17 15:43:14,320 - ansible_rulebook.rule_set_runner - INFO - Task action::run_playbook::Listen for events on a webhook::Say Hello finished, active actions 0
2023-05-17 15:45:02,129 - aiohttp.access - INFO - 10.1.1.5 [17/May/2023:19:45:02 +0000] "POST /endpoint HTTP/1.1" 200 158 "-" "Apache-HttpClient/4.5.10 (Java/16.0.2)"
{   'meta': {   'endpoint': 'endpoint',
                'headers': {   'Accept-Charset': 'UTF-8',
                               'Accept-Encoding': 'gzip,deflate',
                               'Connection': 'Keep-Alive',
                               'Content-Length': '376',
                               'Content-Type': 'application/json; '
                                               'charset=UTF-8',
                               'Host': '10.1.1.11:5000',
                               'User-Agent': 'Apache-HttpClient/4.5.10 '
                                             '(Java/16.0.2)'},
                'received_at': '2023-05-17T19:45:02.128666Z',
                'source': {   'name': 'ansible.eda.webhook',
                              'type': 'ansible.eda.webhook'},
                'uuid': 'ddf1b125-1e9b-45d0-bd71-c5a3f338bd57'},
    'payload': {   'message': 'Ansible Please Block Some IPs',
                   'payload': '61.159.83.27, 106.31.225.181, 124.113.69.146, '
                              '110.193.169.10, 36.105.233.171, 36.117.197.225, '
                              '113.91.81.178, 115.207.239.18, 110.252.60.154, '
                              '117.42.208.29, 121.227.208.31, 121.227.153.3, '
                              '46.250.37.60, 118.224.199.107, 118.89.240.8, '
                              '36.101.190.239, 80.250.71.98, 58.38.47.241, '
                              '122.76.41.113, 59.108.107.170, '}}
2023-05-17 15:45:02 132 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.RegisterOnlyAgendaFilter - Activation of effective rule "Say Hello" with facts: {m={payload={payload=61.159.83.27, 106.31.225.181, 124.113.69.146, 110.193.169.10, 36.105.233.171, 36.117.197.225, 113.91.81.178, 115.207.239.18, 110.252.60.154, 117.42.208.29, 121.227.208.31, 121.227.153.3, 46.250.37.60, 118.224.199.107, 118.89.240.8, 36.101.190.239, 80.250.71.98, 58.38.47.241, 122.76.41.113, 59.108.107.170, , message=Ansible Please Block Some IPs}, meta={headers={Accept-Charset=UTF-8, Connection=Keep-Alive, User-Agent=Apache-HttpClient/4.5.10 (Java/16.0.2), Host=10.1.1.11:5000, Accept-Encoding=gzip,deflate, Content-Length=376, Content-Type=application/json; charset=UTF-8}, endpoint=endpoint, received_at=2023-05-17T19:45:02.128666Z, source={name=ansible.eda.webhook, type=ansible.eda.webhook}, uuid=ddf1b125-1e9b-45d0-bd71-c5a3f338bd57}}}
2023-05-17 15:45:02,133 - ansible_rulebook.rule_generator - INFO - calling Say Hello
2023-05-17 15:45:02,133 - ansible_rulebook.rule_set_runner - INFO - call_action run_playbook
2023-05-17 15:45:02,134 - ansible_rulebook.rule_set_runner - INFO - substitute_variables [{'name': 'f5-playbooks/block-ips-playbook/block-ips.yaml', 'post_events': True}] [{'event': {'payload': {'payload': '61.159.83.27, 106.31.225.181, 124.113.69.146, 110.193.169.10, 36.105.233.171, 36.117.197.225, 113.91.81.178, 115.207.239.18, 110.252.60.154, 117.42.208.29, 121.227.208.31, 121.227.153.3, 46.250.37.60, 118.224.199.107, 118.89.240.8, 36.101.190.239, 80.250.71.98, 58.38.47.241, 122.76.41.113, 59.108.107.170, ', 'message': 'Ansible Please Block Some IPs'}, 'meta': {'headers': {'Accept-Charset': 'UTF-8', 'Connection': 'Keep-Alive', 'User-Agent': 'Apache-HttpClient/4.5.10 (Java/16.0.2)', 'Host': '10.1.1.11:5000', 'Accept-Encoding': 'gzip,deflate', 'Content-Length': '376', 'Content-Type': 'application/json; charset=UTF-8'}, 'endpoint': 'endpoint', 'received_at': '2023-05-17T19:45:02.128666Z', 'source': {'name': 'ansible.eda.webhook', 'type': 'ansible.eda.webhook'}, 'uuid': 'ddf1b125-1e9b-45d0-bd71-c5a3f338bd57'}}}]
2023-05-17 15:45:02,134 - ansible_rulebook.rule_set_runner - INFO - action args: {'name': 'f5-playbooks/block-ips-playbook/block-ips.yaml', 'post_events': True}
2023-05-17 15:45:02,134 - ansible_rulebook.builtin - INFO - running Ansible playbook: f5-playbooks/block-ips-playbook/block-ips.yaml
2023-05-17 15:45:02,137 - ansible_rulebook.builtin - INFO - ruleset: Listen for events on a webhook, rule: Say Hello
2023-05-17 15:45:02,138 - ansible_rulebook.builtin - INFO - Calling Ansible runner

PLAY [ASM Policy Update with Blocked URLS, IPs or Both] ************************

TASK [Setup provider] **********************************************************
ok: [f5]

TASK [debug] *******************************************************************
ok: [f5] => {
    "msg": {
        "meta": {
            "endpoint": "endpoint",
            "headers": {
                "Accept-Charset": "UTF-8",
                "Accept-Encoding": "gzip,deflate",
                "Connection": "Keep-Alive",
                "Content-Length": "376",
                "Content-Type": "application/json; charset=UTF-8",
                "Host": "10.1.1.11:5000",
                "User-Agent": "Apache-HttpClient/4.5.10 (Java/16.0.2)"
            },
            "received_at": "2023-05-17T19:45:02.128666Z",
            "source": {
                "name": "ansible.eda.webhook",
                "type": "ansible.eda.webhook"
            },
            "uuid": "ddf1b125-1e9b-45d0-bd71-c5a3f338bd57"
        },
        "payload": {
            "message": "Ansible Please Block Some IPs",
            "payload": "61.159.83.27, 106.31.225.181, 124.113.69.146, 110.193.169.10, 36.105.233.171, 36.117.197.225, 113.91.81.178, 115.207.239.18, 110.252.60.154, 117.42.208.29, 121.227.208.31, 121.227.153.3, 46.250.37.60, 118.224.199.107, 118.89.240.8, 36.101.190.239, 80.250.71.98, 58.38.47.241, 122.76.41.113, 59.108.107.170, "
        }
    }
}

TASK [debug] *******************************************************************
ok: [f5] => {
    "msg": {
        "message": "Ansible Please Block Some IPs",
        "payload": "61.159.83.27, 106.31.225.181, 124.113.69.146, 110.193.169.10, 36.105.233.171, 36.117.197.225, 113.91.81.178, 115.207.239.18, 110.252.60.154, 117.42.208.29, 121.227.208.31, 121.227.153.3, 46.250.37.60, 118.224.199.107, 118.89.240.8, 36.101.190.239, 80.250.71.98, 58.38.47.241, 122.76.41.113, 59.108.107.170, "
    }
}

TASK [Create Array from BlockedIPs] ********************************************
fatal: [f5]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'split'. 'dict object' has no attribute 'split'\n\nThe error appears to be in '/tmp/run_playbookcbp6leub/project/block-ips.yaml': line 32, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: Create Array from BlockedIPs\n    ^ here\n"}

PLAY RECAP *********************************************************************
f5                         : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
2023-05-17 15:45:03,245 - ansible_rulebook.builtin - INFO - Ansible Runner Queue task cancelled
2023-05-17 15:45:03,246 - ansible_rulebook.builtin - INFO - Playbook rc: 2, status: failed
2023-05-17 15:45:03,247 - ansible_rulebook.builtin - ERROR - 
PLAY [ASM Policy Update with Blocked URLS, IPs or Both] ************************

TASK [Setup provider] **********************************************************
ok: [f5]

TASK [debug] *******************************************************************
ok: [f5] => {
    "msg": {
        "meta": {
            "endpoint": "endpoint",
            "headers": {
                "Accept-Charset": "UTF-8",
                "Accept-Encoding": "gzip,deflate",
                "Connection": "Keep-Alive",
                "Content-Length": "376",
                "Content-Type": "application/json; charset=UTF-8",
                "Host": "10.1.1.11:5000",
                "User-Agent": "Apache-HttpClient/4.5.10 (Java/16.0.2)"
            },
            "received_at": "2023-05-17T19:45:02.128666Z",
            "source": {
                "name": "ansible.eda.webhook",
                "type": "ansible.eda.webhook"
            },
            "uuid": "ddf1b125-1e9b-45d0-bd71-c5a3f338bd57"
        },
        "payload": {
            "message": "Ansible Please Block Some IPs",
            "payload": "61.159.83.27, 106.31.225.181, 124.113.69.146, 110.193.169.10, 36.105.233.171, 36.117.197.225, 113.91.81.178, 115.207.239.18, 110.252.60.154, 117.42.208.29, 121.227.208.31, 121.227.153.3, 46.250.37.60, 118.224.199.107, 118.89.240.8, 36.101.190.239, 80.250.71.98, 58.38.47.241, 122.76.41.113, 59.108.107.170, "
        }
    }
}

TASK [debug] *******************************************************************
ok: [f5] => {
    "msg": {
        "message": "Ansible Please Block Some IPs",
        "payload": "61.159.83.27, 106.31.225.181, 124.113.69.146, 110.193.169.10, 36.105.233.171, 36.117.197.225, 113.91.81.178, 115.207.239.18, 110.252.60.154, 117.42.208.29, 121.227.208.31, 121.227.153.3, 46.250.37.60, 118.224.199.107, 118.89.240.8, 36.101.190.239, 80.250.71.98, 58.38.47.241, 122.76.41.113, 59.108.107.170, "
    }
}

TASK [Create Array from BlockedIPs] ********************************************
fatal: [f5]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'split'. 'dict object' has no attribute 'split'\n\nThe error appears to be in '/tmp/run_playbookcbp6leub/project/block-ips.yaml': line 32, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: Create Array from BlockedIPs\n    ^ here\n"}

PLAY RECAP *********************************************************************
f5                         : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

2023-05-17 15:45:03,248 - ansible_rulebook.rule_set_runner - INFO - Task action::run_playbook::Listen for events on a webhook::Say Hello finished, active actions 0

Expected results

i would have expected the payload with different ips than the first payload. i didnt expect the payload to be the entire post.

i expected like this code but with different ips

`TASK` [debug] *******************************************************************
ok: [f5] => {
    "msg": {
        "message": "Ansible Please Block Some IPs",
        "payload": "114.225.248.7, 122.159.243.78, 49.66.141.203, 47.98.58.62, 139.203.90.78, 43.251.247.220, 113.97.123.155, 115.170.100.80, 106.27.28.238, 49.69.74.215, 125.86.131.83, 123.160.232.22, 120.76.45.146, 112.194.39.209, 122.236.26.112, 42.187.79.104, 60.2.184.96, 60.191.138.128, 124.65.127.96, 91.191.249.134, "
    }
}

Additional information

No response

events/facts matching with non-literals strings

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

trying to figure how to parameterise a condition with the following rulebook, except that the commented line results in no match of the condition:

.
โ”œโ”€โ”€ hosts.yml
โ”œโ”€โ”€ local_copy.yml
โ”œโ”€โ”€ playbook-create.yml
โ”œโ”€โ”€ playbook-delete.yml
โ””โ”€โ”€ webhooks.yml

hosts.yml

all:
  children:
    local:
      hosts:
        localhost:
          ansible_connection: local

local_copy.yml

resource_list: []

playbook-create.yml

---
- hosts: local
  gather_facts: false
  vars:
    local_copy_file: "/tmp/local_copy.yml"
  tasks:
    - ansible.builtin.stat:
        path: "{{ local_copy_file }}"
      register: local_copy_stat

    - ansible.builtin.copy:
        dest: "{{ local_copy_file }}"
        content: "resource_list: []"
      when: local_copy_stat.stat.exists == false

    - ansible.builtin.include_vars:
        file: "{{ local_copy_file }}"
        name: observed

    - set_fact:
        cacheable: true
        active:
          resource_list: "{{ observed.resource_list + [ansible_eda.event.payload.resource_name] }}"

    - copy:
        dest: "{{ local_copy_file }}"
        content: "resource_list: {{ active.resource_list }}"

playbook-delete.yml

---
- hosts: local
  gather_facts: false
  vars:
    local_copy_file: "/tmp/local_copy.yml"
  tasks:
    - ansible.builtin.include_vars:
        file: "{{ local_copy_file }}"
        name: observed
    - set_fact:
        cacheable: true
        active:
          resource_list: "{{ observed.resource_list | difference([ansible_eda.events.m_0.payload.resource_name]) }}"
    - copy:
        dest: "{{ local_copy_file }}"
        content: "resource_list: {{ active.resource_list }}"

webhooks.yml

---
- name: Ruleset 1
  hosts: all
  sources:   
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5000
  rules:
    - name: Inspect Create request
      condition: >
        event.payload.event_name == "Create"
      action:
        run_playbook:
          name: playbook-create.yml
          post_events: true
          set_facts: true
    - name: Post Create request
      condition:
        all:
          - events.scoped << event.active.resource_list is defined
      action:
        post_event:
          ruleset: Ruleset 2
          event:
            payload:
              resource_list: "{{ events.scoped.active.resource_list }}"

- name: Ruleset 2
  hosts: all
  sources:   
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5001
  rules:
    - name: Process Delete
      condition:
        all:
          - event.payload.event_name == "Delete"
          - event.payload.resource_list is select("search", "r1")
#          - event.payload.resource_list is select("search", events.m_0.payload.resource_name)
      action:
        run_playbook:
          name: playbook-delete.yml

Environment

__version__ = '0.11.0'
  Executable location = /home/alialkhalidi/work/ansible-04062023/bin/ansible-rulebook
  Drools_jpy version = 0.2.8
  Java home = /usr/lib/jvm/java-17-openjdk-17.0.6.0.10-1.fc36.x86_64/
  Java version = 17.0.6
  Python version = 3.10.10 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]

Steps to reproduce

1- run the rulebook with: ansible-rulebook --rulebook webhooks.yml -i hosts.yml -v
2- run a call with: curl -d '{"event_name":"Create","resource_name":"r1"}' localhost:5000
3- run a call with: curl -d '{"event_name":"Delete","resource_name":"r1"}' localhost:5001
4- local_copy.yml will have active_list: []

Actual results

  • un-comment the line, and repeat steps 1-4, the condition for Ruleset 2 does not match, and playbook-delete.yml does not get triggered.

Expected results

the condition for Ruleset 2 matches, and playbook-delete.yml gets triggered.

Additional information

ansible-rulebook is from current tip main.

SOURCE_DIR only applies to source plugins, not filter plugins

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

When developing filter plugins, passing --source-dir does not allow for local filter plugins, only local local source plugins. This means that the filter plugin has to be published in a collection to be tested.

Environment

[root@dd6d2c871e07 cloin.eda]# ansible-rulebook --version
__version__ = '1.0.1'
  Executable location = /usr/local/bin/ansible-rulebook
  Drools_jpy version = 0.3.4
  Java home = /usr/lib/jvm/jre-17-openjdk
  Java version = 17.0.8
  Python version = 3.11.4 (main, Jun  7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]

Steps to reproduce

  • Create a filter plugin and keep it local.
  • Specify the filter plugin in a rulebook against an already published event source:
---
- name: Respond to webhook POST
  hosts: all
  sources:
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5000
      filters:
        - endpoint_as_namespace:
  • Run ansible-rulebook
    • ansible-rulebook -r webhook.yml -i inventory.yml -S ./extensions/eda/plugins/event_filter/ --verbose

Actual results

ansible-rulebook fails because it can't find the filter plugin

2023-08-11 15:17:06,126 - ansible_rulebook.engine - INFO - Cancelling all ruleset tasks
2023-08-11 15:17:06,127 - ansible_rulebook.engine - INFO - Waiting on gather
2023-08-11 15:17:06,127 - ansible_rulebook.engine - INFO - Returning from run_rulesets
2023-08-11 15:17:06,127 - ansible_rulebook.app - INFO - Cancelling event source tasks
2023-08-11 15:17:06,128 - ansible_rulebook.app - ERROR - Could not find source filter plugin for endpoint_as_namespace
2023-08-11 15:17:06,129 - ansible_rulebook.app - INFO - Main complete
2023-08-11 15:17:06,129 - ansible_rulebook.cli - ERROR - Terminating One of the source plugins failed

Expected results

ansible-rulebook finds the filter plugin based on the path in SOURCE_DIR

Additional information

No response

RFE: Add launch_job_workflow

Description

Feature request to add a new run_workflow_template action.

Currently we have a run_job_template action; in a similar fashion, when conditions are met, this would launch a workflow in the specified AutomationController or AWX instance.

Additional Info

  • ansible-rulebook version: v0.10.1

Throttle condition returns an 'unexpected' error

  • ansible-rulebook version: 0.10.1
  • Python version: 3.8.13
  • Operating System: RHEL 8.7

Description

When running a test rulebook with the 'throttle' parameter specified, ansible-rulebook returns the error:
jsonschema.exceptions.ValidationError: Additional properties are not allowed ('throttle' was unexpected)

What I Did

Rulebook.yml:

- name: Example
  hosts: all
  sources:
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 5000
  rules:
    - name: Get device info if BGP neighbor down
      condition: event.payload.message == "BGP neighbor down"
      throttle:
        once_within: 5 minutes
      action:
        run_job_template:
          name: Parsers
          job_args:
            limit: "{{ event.payload.meta.hosts }}"
          organization: MackNet

The command and error output

[amack@ansible-eda ansible-event-driven-automation]$ ansible-rulebook --rulebook rulebook.yml  -i inventory.yml --verbose
2023-02-10 17:52:42,045 - ansible_rulebook.validators - ERROR - Rulebook failed validation.
Traceback (most recent call last):
  File "/home/amack/.local/lib/python3.8/site-packages/ansible_rulebook/validators.py", line 36, in rulebook
    validate(instance=instance, schema=cls._get_schema())
  File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 1121, in validate
    raise error
jsonschema.exceptions.ValidationError: Additional properties are not allowed ('throttle' was unexpected)

Failed validating 'additionalProperties' in schema['items']['properties']['rules']['items']:
    {'additionalProperties': False,
     'properties': {'action': {'oneOf': [{'$ref': '#/$defs/run-playbook-action'},
                                         {'$ref': '#/$defs/run-module-action'},
                                         {'$ref': '#/$defs/run-job-template-action'},
                                         {'$ref': '#/$defs/post-event-action'},
                                         {'$ref': '#/$defs/set-fact-action'},
                                         {'$ref': '#/$defs/retract-fact-action'},
                                         {'$ref': '#/$defs/print-event-action'},
                                         {'$ref': '#/$defs/debug-action'},
                                         {'$ref': '#/$defs/none-action'},
                                         {'$ref': '#/$defs/shutdown-action'},
                                         {'$ref': '#/$defs/echo-action'}]},
                    'condition': {'anyOf': [{'type': 'string'},
                                            {'$ref': '#/$defs/all-condition'},
                                            {'$ref': '#/$defs/any-condition'}]},
                    'name': {'minLength': 1,
                             'pattern': '\\S',
                             'type': 'string'}},
     'required': ['name', 'condition', 'action'],
     'type': 'object'}

On instance[0]['rules'][0]:
    {'action': {'run_job_template': {'name': 'Parsers',
                                     'organization': 'MackNet'}},
     'condition': 'event.payload.message == "BGP neighbor down"',
     'name': 'Get device info if BGP neighbor down',
     'throttle': {'once_within': '5 minutes'}}
2023-02-10 17:52:42,074 - ansible_rulebook.cli - ERROR - Unexpected exception
Traceback (most recent call last):
  File "/home/amack/.local/lib/python3.8/site-packages/ansible_rulebook/cli.py", line 203, in main
    asyncio.run(app.run(args))
  File "/usr/lib64/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib64/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/amack/.local/lib/python3.8/site-packages/ansible_rulebook/app.py", line 65, in run
    rulesets = load_rulebook(parsed_args)
  File "/home/amack/.local/lib/python3.8/site-packages/ansible_rulebook/app.py", line 149, in load_rulebook
    Validate.rulebook(data)
  File "/home/amack/.local/lib/python3.8/site-packages/ansible_rulebook/validators.py", line 36, in rulebook
    validate(instance=instance, schema=cls._get_schema())
  File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 1121, in validate
    raise error
jsonschema.exceptions.ValidationError: Additional properties are not allowed ('throttle' was unexpected)

Failed validating 'additionalProperties' in schema['items']['properties']['rules']['items']:
    {'additionalProperties': False,
     'properties': {'action': {'oneOf': [{'$ref': '#/$defs/run-playbook-action'},
                                         {'$ref': '#/$defs/run-module-action'},
                                         {'$ref': '#/$defs/run-job-template-action'},
                                         {'$ref': '#/$defs/post-event-action'},
                                         {'$ref': '#/$defs/set-fact-action'},
                                         {'$ref': '#/$defs/retract-fact-action'},
                                         {'$ref': '#/$defs/print-event-action'},
                                         {'$ref': '#/$defs/debug-action'},
                                         {'$ref': '#/$defs/none-action'},
                                         {'$ref': '#/$defs/shutdown-action'},
                                         {'$ref': '#/$defs/echo-action'}]},
                    'condition': {'anyOf': [{'type': 'string'},
                                            {'$ref': '#/$defs/all-condition'},
                                            {'$ref': '#/$defs/any-condition'}]},
                    'name': {'minLength': 1,
                             'pattern': '\\S',
                             'type': 'string'}},
     'required': ['name', 'condition', 'action'],
     'type': 'object'}

On instance[0]['rules'][0]:
    {'action': {'run_job_template': {'name': 'Parsers',
                                     'organization': 'MackNet'}},
     'condition': 'event.payload.message == "BGP neighbor down"',
     'name': 'Get device info if BGP neighbor down',
     'throttle': {'once_within': '5 minutes'}}

could not find source plugin ansible.eda.range

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

Documentation for an ansible-rulebook content developer does not mention ansible-galaxy collection install ansible.eda, which is required to get the first example in the Rulebook working.

Environment

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"

Steps to reproduce

  • Read and complete the Installation docs
  • Read and complete the Usage docs
  • Move onto the Rulebook docs and try the first example

Actual results

ansible-rulebook --rulebook chaos.yml --inventory inventory.yml
2024-06-07 13:08:39,153 - ansible_rulebook.engine - ERROR - Source error Could not find source plugin for ansible.eda.range
2024-06-07 13:08:39,153 - ansible_rulebook.engine - ERROR - Shutting down source: ansible.eda.range error : Could not find source plugin for ansible.eda.range
2024-06-07 13:08:39,169 - ansible_rulebook.app - ERROR - Could not find source plugin for ansible.eda.range
2024-06-07 13:08:39,170 - ansible_rulebook.cli - ERROR - Terminating One of the source plugins failed

Expected results

After completing the Installation -> Usage and moving on to the Rulebook section of the docs. I expect to be able to run the first example.

Additional information

I had to install the ansible.eda collection via ansible-galaxy collection install ansible.eda. I didn't find this step in the Developer section, I just got lucky. Now I see it's in the Developer section but I'd argue it should be more front and center. Probably in the Installation section but I could see it in the Rulebook section too.

I wouldn't think to go to the Developer doc section because I figure that is for contributing to the ansible-rulebook project. I'm just looking to author content.

Support for standalone Booleans in conditions

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Feature type

Enhancement to Existing Feature

Feature Summary

This helps when we want to print events, process all messages in Kafka topic without knowing the contents of the event.
The literal boolean true allows the condition to pass and the action various action can be done for events.

Steps to reproduce

- name: print event always
  condition: true
  action:
    print_event:
      pretty: true

Current results

Cannot be done

Sugested feature result

Can be passed

Additional information

See this pull request

ansible-rulebook is failing due to version

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

i am trying to ansible-rulebook with rulebook option and also when I run ansible-rulebook --version and getting below error

raceback (most recent call last):
  File "/usr/local/bin/ansible-rulebook", line 5, in <module>
    from ansible_rulebook.cli import main
  File "/usr/local/lib/python3.8/site-packages/ansible_rulebook/cli.py", line 29, in <module>
    util.check_jvm()
  File "/usr/local/lib/python3.8/site-packages/ansible_rulebook/util.py", line 190, in check_jvm
    if version.parse(java_version) < version.parse("17"):
  File "/usr/local/lib/python3.8/site-packages/packaging/version.py", line 52, in parse
    return Version(version)
  File "/usr/local/lib/python3.8/site-packages/packaging/version.py", line 197, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
packaging.version.InvalidVersion: Invalid version: '1.8.0_312'

Environment

OS RHEL 8

Steps to reproduce

  1. install ansible-rulebook
  2. run ansible-rulebook --version

Actual results

version should display

Expected results

version is not displaying.

Additional information

No response

Increase json dictionary value limit from 255 to 346

  • ansible-rulebook version: 0.10.1
  • Python version: 3.8.13
  • Operating System: RHEL 7

Attempting to process an incoming webhook from Atlassian Jira, and it exceeds the maximum dictionary value of 255.

I was attempting to receive a webhook from Atlassian Jira for a rulebook, and the webhook utility in Jira sends a json package with too many dictionary values. It appears the max value for ansible-rulebook is 255, but a json package originating from the Jira provided webhook tool is 346.

Received the following message when the webhook hits our ansible-rulebook server while the rulebook is running:
_2023-01-30 09:28:02,479 - asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-8' coro=<RuleSetRunner.drain_source_queue() done, defined at /home/ansible/.local/lib/python3.8/site-packages/ansible_rulebook/engine.py:280> exception=Exception('Only 255 values supported per dictionary found 346')>

This causes the rulebook to error out and stop processing new incoming webhooks.

I experimented by increasing the limit in "ansible_rulebook/util.py" to 350 to see if the rulebook was able to run successfully. I did this by modifying the values in json_count(data) "if len(o) > 255" and " if s> 255:" to 350. This allowed the webhook to be processed successfully without causing the rulebook to exit with an error.

Jira doesn't currently have the ability to limit the json package values using the built in webhook tool. The custom variables provided using a custom webhook is very limited and only provides very basic functionality.

Thanks,
Pat

Can't use ansible.builtin filters in rulebook

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

When I try to manipulate some data I want to sent to the playbook in extra_vars using ansible builtin filters, it fails

Environment

Centos stream 9

$ ansible-rulebook --version
1.1.0
  Executable location = /home/bzjr2686/ansible-rulebook/venv/bin/ansible-rulebook
  Drools_jpy version = 0.3.9
  Java home = /usr/lib/jvm/java-17-openjdk-17.0.6.0.10-3.el9.x86_64
  Java version = 17.0.6
  Python version = 3.9.18 (main, Jan 24 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)]

Steps to reproduce

$ cat rule-test.yml
---
- name: Test webhook
  hosts: localhost

  sources:
    - ansible.eda.webhook:
        host: 0.0.0.0
        port: 8081

  rules:
    - name: Run playbook
      condition: True
      action:
        run_playbook:
          name: play-test.yml
          extra_vars:
            testkey1: testval1
            testfilter1: "{{ event.payload.hostname | ansible.builtin.regex_replace('\\w+_(\\w+)', '\\1') }}"

$ ansible-rulebook --rulebook rule-test.yml -i inventory.yaml
$ curl -k --header "Content-Type: application/json" --data '{ "hostname": "ABC_Hostname" }' http://localhost:8081

Actual results

2024-06-05 18:02:09,481 - ansible_rulebook.rule_set_runner - ERROR - Error calling action run_playbook, err No filter named 'ansible.builtin.regex_replace'.

Expected results

Playbook starting with testfilter1: Hostname in extra_vars

Additional information

No response

Tests are failing on power (ppc64le arch rhel8/9):Assertion and timeout error

  • ansible-rulebook version:
    version = '0.10.1'
    Executable location = /usr/local/bin/ansible-rulebook
    Drools_jpy version = 0.1.9
    Java home = /usr/lib/jvm/java-17-openjdk-17.0.4.1.1-6.el8.ppc64le
    Java version = 17.0.4.1
    Python version = 3.9.13 (main, Jun 15 2022, 11:39:48) [GCC 8.5.0 20210514 (Red Hat 8.5.0-13)]

  • Python version: 3.9.13 (main, Jun 15 2022, 11:39:48) [GCC 8.5.0 20210514 (Red Hat 8.5.0-13)]

  • Operating System:
    NAME="Red Hat Enterprise Linux"
    VERSION="8.7 (Ootpa)"

Also tested on
NAME="Red Hat Enterprise Linux"
VERSION="9.1.0 (Ootpa)"

*Arch :
ppc64le

Description

Building upstream repo on power machine which needs to be pass successfully.
Tried testing on different Os such as rhel8/rhel9 on power and faced same testcase failing result

Some of testcases are failing due to assertion error It should pass successfully with all 139 tests are passed.
power result : 19 failed, 120 passed, 2 xfailed in 506.72s (0:08:26)

(for s390x all tests are passing)
s390x result :
139 passed, 2 xfailed in 178.76s (0:02:58)

What I Did

Testing upstream repo on power machine (ppc64le)
clones repository is :
https://github.com/ansible/ansible-rulebook.git

Installed depedencies which are required from installation page
https://github.com/ansible/ansible-rulebook/blob/v0.10.1/docs/installation.rst


Summury of commands:

1. yum install java-17-openjdk-devel openssl-devel git wget tar python39-devel.ppc64le gcc rust cargo
2. wget https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz
3. tar -xzvf apache-maven-3.8.7-bin.tar.gz -C /opt/
4. ln -s /opt/apache-maven-3.8.7/bin/mvn /usr/local/bin/mvn
5. rm -f apache-maven-3.8.7-bin.tar.gz
6. git clone https://github.com/ansible/ansible-rulebook.git
7. cd ansible-rulebook
8. export JDK_HOME=/usr/lib/jvm/java-17-openjdk
9. export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
10. pip3 install -e .
11. pip3 install -r requirements_test.txt
12. ansible-galaxy collection install git+https://github.com/ansible/event-driven-ansible
13. pip3 install pyparsing jsonschema websockets drools-jpy 
14. pytest -v -n auto

output:

INFO     tests.e2e.test_operators:test_operators.py:387 Running command: ansible-rulebook -i /root/ansible-rulebook/tests/e2e/files/inventories/default_inventory.yml -S /root/ansible-rulebook/tests/e2e/../sources --rulebook /root/ansible-rulebook/tests/e2e/files/rulebooks/operators/test_not_operator.yml

=========================== short test summary info ============================
FAILED tests/e2e/test_actions.py::test_actions_sanity - subprocess.TimeoutExp...
FAILED tests/e2e/test_operators.py::test_less_operators[lt] - AssertionError:...
FAILED tests/e2e/test_operators.py::test_less_operators[le] - AssertionError:...
FAILED tests/e2e/test_operators.py::test_greater_operators[ge_operator] - Ass...
FAILED tests/e2e/test_operators.py::test_greater_operators[gt_operator] - Ass...
FAILED tests/e2e/test_operators.py::test_ne_operator[str] - AssertionError: a...
FAILED tests/e2e/test_operators.py::test_ne_operator[int] - AssertionError: a...
FAILED tests/e2e/test_operators.py::test_defined_operator[str] - AssertionErr...
FAILED tests/e2e/test_operators.py::test_defined_operator[int] - AssertionErr...
FAILED tests/e2e/test_operators.py::test_defined_operator[nested] - Assertion...
FAILED tests/e2e/test_operators.py::test_contains_operator[contains_str_single]
FAILED tests/e2e/test_operators.py::test_contains_operator[contains_int_single]
FAILED tests/e2e/test_operators.py::test_contains_operator[not_contains_str_combined]
FAILED tests/e2e/test_operators.py::test_in_operator[int_combined_multiple_extravars]
FAILED tests/e2e/test_operators.py::test_in_operator[not_in_int_extravars] - ...
FAILED tests/e2e/test_operators.py::test_in_operator[not_in_str_extravars] - ...
FAILED tests/e2e/test_operators.py::test_in_operator[str_single] - AssertionE...
FAILED tests/e2e/test_operators.py::test_in_operator[not_in_str_single] - Ass...
FAILED tests/e2e/test_operators.py::test_not_operator - AssertionError: asser...
============ 19 failed, 120 passed, 2 xfailed in 506.72s (0:08:26) =============



Ansible.cfg not being loaded

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Bug Summary

ansible.cfg seems to only be pulled if you use update /etc/ansible/ansible.cfg

When add ansible.cfg into the CWD, or via export ANSIBLE_CONFIG=./ansible.cfg it does not load the correct ansible.cfg information

Environment

Rocky 9.1

ansible-rulebook --version
version = '0.11.0'
Executable location = /usr/local/bin/ansible-rulebook
Drools_jpy version = 0.2.5
Java home = /usr/lib/jvm/java-17-openjdk-17.0.6.0.10-3.el9_1.x86_64
Java version = 17.0.6
Python version = 3.9.14 (main, Nov 7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]

Steps to reproduce

create a new working directory

mkdir /opt/ansible
vi ansible.cfg
[defaults]

paths to search for roles in, colon separated

library = ./library
collections_path = ./collections
roles_path = ./roles

vi kafka-playbook.yml

  • name: Read messages from a kafka topic and act on them
    hosts: localhost

    Define our source for events

    sources:

    • ansible.eda.kafka:
      host: localhost
      port: 9092
      topic: eda-topic
      group_id:

    Define the conditions we are looking for

    rules:

    • name: Say Hello
      condition: event.message == "Ansible is cool"

      Define the action we should take should the condition be met

      action:
      run_playbook:
      name: playbook.yml
      verbosity: 4

vi playbook.yml

  • name: HelloWorld
    hosts: localhost
    connection: local
    roles:
    • helloworld

mkdir -p ./roles/helloworld/tasks
vi ./roles/helloworld/tasks/main.yml

tasks file for HelloWorld

  • name: debug HelloWorld myvariable
    debug:
    msg: "{{ myvariable }}"

mkdir -p ./roles/helloworld/vars
vi ./roles/helloworld/vars/main.yml

vars file for HelloWorld

myvariable: "Hello World!

inventory.yaml
all:
hosts:
localhost:
ansible_connection: local

.
โ”œโ”€โ”€ ansible.cfg
โ”œโ”€โ”€ inventory.yml
โ”œโ”€โ”€ kafka-playbook.yml
โ”œโ”€โ”€ playbook.yml
โ””โ”€โ”€ roles
โ””โ”€โ”€ helloworld
โ”œโ”€โ”€ tasks
โ”‚ย ย  โ””โ”€โ”€ main.yml
โ””โ”€โ”€ vars
โ””โ”€โ”€ main.yml

ansible-galaxy collection install ansible.eda
export ANSIBLE_CONFIG=./ansible.cfg
echo $ANSIBLE_CONFIG
./ansible.cfg
ansible-rulebook --verbose --inventory inventory.yml --rulebook kafka-playbook.yml

So not quite sure if this isa ansible-rulebook issue as it i believe is calling ansible-playbook or if its an ansible-playbook issue and if this needs to be open here or ansible-playbook repo?

Actual results

ansible-rulebook --verbose --inventory inventory.yml --rulebook kafka-playbook.yml
2023-03-17 15:58:43,075 - ansible_rulebook.app - INFO - Starting sources
2023-03-17 15:58:43,075 - ansible_rulebook.app - INFO - Starting rules
2023-03-17 15:58:43,075 - ansible_rulebook.engine - INFO - run_ruleset
2023-03-17 15:58:43,792 - ansible_rulebook.engine - INFO - ruleset define: {"name": "Read messages from a kafka topic and act on them", "hosts": ["localhost"], "sources": [{"EventSource": {"name": "ansible.eda.kafka", "source_name": "ansible.eda.kafka", "source_args": {"host": "localhost", "port": 9092, "topic": "eda-topic", "group_id": null}, "source_filters": []}}], "rules": [{"Rule": {"name": "Say Hello", "condition": {"AllCondition": [{"EqualsExpression": {"lhs": {"Event": "message"}, "rhs": {"String": "Ansible is cool"}}}]}, "actions": [{"Action": {"action": "run_playbook", "action_args": {"name": "playbook.yml", "verbosity": 4}}}], "enabled": true}}]}
2023-03-17 15:58:43,808 - ansible_rulebook.engine - INFO - load source
2023-03-17 15:58:44,526 - ansible_rulebook.engine - INFO - load source filters
2023-03-17 15:58:44,527 - ansible_rulebook.engine - INFO - Calling main in ansible.eda.kafka
2023-03-17 15:58:44,527 - aiokafka.consumer.subscription_state - INFO - Updating subscribed topics to: frozenset({'eda-topic'})
2023-03-17 15:58:44,531 - ansible_rulebook.engine - INFO - Waiting for all ruleset tasks to end
2023-03-17 15:58:44 531 [drools-async-evaluator-thread] INFO org.drools.ansible.rulebook.integration.api.io.RuleExecutorChannel - Async channel connected
2023-03-17 15:58:44,532 - ansible_rulebook.rule_set_runner - INFO - Waiting for actions on events from Read messages from a kafka topic and act on them
2023-03-17 15:58:44,533 - ansible_rulebook.rule_set_runner - INFO - Waiting for events, ruleset: Read messages from a kafka topic and act on them
2023-03-17 15:58:44,538 - aiokafka.consumer.group_coordinator - INFO - Metadata for topic has changed from {} to {'eda-topic': 1}.
2023-03-17 15:58:52 553 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.RegisterOnlyAgendaFilter - Activation of effective rule "Say Hello" with facts: [Event DROOLS_PROTOTYPE with values = {message=Ansible is cool}]
2023-03-17 15:58:52,566 - ansible_rulebook.rule_generator - INFO - calling Say Hello
2023-03-17 15:58:52,567 - ansible_rulebook.rule_set_runner - INFO - call_action run_playbook
2023-03-17 15:58:52,567 - ansible_rulebook.rule_set_runner - INFO - substitute_variables [{'name': 'playbook.yml', 'verbosity': 4}] [{'event': {'message': 'Ansible is cool'}}]
2023-03-17 15:58:52,567 - ansible_rulebook.rule_set_runner - INFO - action args: {'name': 'playbook.yml', 'verbosity': 4}
2023-03-17 15:58:52,567 - ansible_rulebook.builtin - INFO - running Ansible playbook: playbook.yml
2023-03-17 15:58:52,570 - ansible_rulebook.builtin - INFO - ruleset: Read messages from a kafka topic and act on them, rule: Say Hello
2023-03-17 15:58:52,570 - ansible_rulebook.builtin - INFO - Calling Ansible runner
ansible-playbook [core 2.14.3]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible-playbook
python version = 3.9.14 (main, Nov 7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] (/usr/bin/python)
jinja version = 3.1.2
libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /tmp/run_playbookl9sh3_nm/inventory/hosts as it did not pass its verify_file() method
script declined parsing /tmp/run_playbookl9sh3_nm/inventory/hosts as it did not pass its verify_file() method
auto declined parsing /tmp/run_playbookl9sh3_nm/inventory/hosts as it did not pass its verify_file() method
Set default localhost to localhost
Parsed /tmp/run_playbookl9sh3_nm/inventory/hosts inventory source with yaml plugin
ERROR! the role 'helloworld' was not found in /tmp/run_playbookl9sh3_nm/project/roles:/root/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/run_playbookl9sh3_nm/project

The error appears to be in '/tmp/run_playbookl9sh3_nm/project/playbook.yml': line 5, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

roles:
- helloworld
^ here
2023-03-17 15:58:53,861 - ansible_rulebook.builtin - INFO - Ansible Runner Queue task cancelled
2023-03-17 15:58:53,864 - ansible_rulebook.builtin - INFO - Playbook rc: 1, status: failed
2023-03-17 15:58:53,865 - ansible_rulebook.builtin - ERROR - ansible-playbook [core 2.14.3]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible-playbook
python version = 3.9.14 (main, Nov 7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] (/usr/bin/python)
jinja version = 3.1.2
libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /tmp/run_playbookl9sh3_nm/inventory/hosts as it did not pass its verify_file() method
script declined parsing /tmp/run_playbookl9sh3_nm/inventory/hosts as it did not pass its verify_file() method
auto declined parsing /tmp/run_playbookl9sh3_nm/inventory/hosts as it did not pass its verify_file() method
Set default localhost to localhost
Parsed /tmp/run_playbookl9sh3_nm/inventory/hosts inventory source with yaml plugin
ERROR! the role 'helloworld' was not found in /tmp/run_playbookl9sh3_nm/project/roles:/root/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/run_playbookl9sh3_nm/project

The error appears to be in '/tmp/run_playbookl9sh3_nm/project/playbook.yml': line 5, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

roles:
- helloworld
^ here

Expected results

2023-03-17 15:58:53,865 - ansible_rulebook.builtin - ERROR - ansible-playbook [core 2.14.3]
config file = /etc/ansible/ansible.cfg

this should be taking it from my environment variable $ANSIBLE_CONFIG=./ansible.cfg
which is not the location above shown

If I edit /etc/ansible/ansible.cfg then I can get it working by pointing it to my CWD in /opt/ansible

Additional information

No response

env-vars has to be quoted and always returned as strings

hello_events.yml test file, only one rule was tested at a time and the others commented out.

~$ cat hello_events.yml
---
- name: Hello Events
  hosts: all
  sources:
    - ansible.eda.range:
        limit: 5
  rules:
    - name: First -- Say Hello when 1
      condition: event.i == 1
      action:
        print_event:

    - name: Second -- Say Hello when {{ EVENT_INTEGER }}
      condition: event.i == {{ EVENT_INTEGER }}
      action:
        print_event:

    - name: Third -- Say Hello when "{{ EVENT_INTEGER }}"
      condition: event.i == "{{ EVENT_INTEGER }}"
      action:
        print_event:
...
~$ echo $EVENT_INTEGER
1

First:

~$ ansible-rulebook --debug -i inventory --rulebook hello_events.yml --env-vars EVENT_INTEGER 
[...]
INFO:ansible_rulebook.engine:ruleset define: {"name": "Hello Events", "hosts": ["all"], "sources": [{"EventSource": {"name": "ansible.eda.range", "source_name": "ansible.eda.range", "source_args": {"limit": 5}, "source_filters": []}}], "rules": [{"Rule": {"name": "First -- Say Hello when 1", "condition": {"AllCondition": [{"EqualsExpression": {"lhs": {"Event": "i"}, "rhs": {"Integer": 1}}}]}, "action": {"Action": {"action": "print_event", "action_args": {}}}, "enabled": true}}]}
INFO:ansible_rulebook.rule_generator:calling First -- Say Hello when 1
INFO:ansible_rulebook.engine:substitute_variables [{}] [{'EVENT_INTEGER': '1', 'event': {'i': 1}, 'fact': {'i': 1}}]
INFO:ansible_rulebook.engine:action args: {}
{'i': 1}

Second:

~$ ansible-rulebook --debug -i inventory --rulebook hello_events.yml --env-vars EVENT_INTEGER 
[...]
INFO:ansible_rulebook.engine:ruleset define: {"name": "Hello Events", "hosts": ["all"], "sources": [{"EventSource": {"name": "ansible.eda.range", "source_name": "ansible.eda.range", "source_args": {"limit": 5}, "source_filters": []}}], "rules": [{"Rule": {"name": "Second -- Say Hello when {{ EVENT_INTEGER }}", "condition": {"AllCondition": [{"Event": "i"}]}, "action": {"Action": {"action": "print_event", "action_args": {}}}, "enabled": true}}]}

Third:

~$ ansible-rulebook --debug -i inventory --rulebook hello_events.yml --env-vars EVENT_INTEGER 
[...]
INFO:ansible_rulebook.engine:ruleset define: {"name": "Hello Events", "hosts": ["all"], "sources": [{"EventSource": {"name": "ansible.eda.range", "source_name": "ansible.eda.range", "source_args": {"limit": 5}, "source_filters": []}}], "rules": [{"Rule": {"name": "Third -- Say Hello when \"{{ EVENT_INTEGER }}\"", "condition": {"AllCondition": [{"EqualsExpression": {"lhs": {"Event": "i"}, "rhs": {"String": "1"}}}]}, "action": {"Action": {"action": "print_event", "action_args": {}}}, "enabled": true}}]}

Originally posted by @konstruktoid in #286 (comment)

ImportError: cannot import name 'OpAssoc' from 'pyparsing'

  • ansible-rulebook version: git upstream
  • Python version: python3.10
  • Operating System: Ubuntu 22.04.1 LTS

Description

ansible-rulebook fails with ImportError: cannot import name 'OpAssoc' from 'pyparsing' (/usr/lib/python3/dist-packages/pyparsing.py)

What I Did

~$ sudo apt-get -y install python3-pip
[...]
~$ pip3 install ansible-rulebook
[...]
Successfully installed ansible-rulebook-0.8.0 ansible-runner-2.2.1 async-timeout-4.0.2 asyncio-3.4.3 deprecated-1.2.13 docutils-0.19 dpath-2.0.6 drools-jpy-0.0.5 durable-rules-2.0.28 janus-1.0.0 jpy-0.12.0 lockfile-0.12.2 packaging-21.3 python-daemon-2.3.1 redis-4.3.4 typing-extensions-4.4.0 websockets-10.3 wrapt-1.14.1
~$ export PATH=$PATH:~/.local/bin
~$ ansible-rulebook --help
Traceback (most recent call last):
  File "/home/vagrant/.local/bin/ansible-rulebook", line 5, in <module>
    from ansible_rulebook.cli import main
  File "/home/vagrant/.local/lib/python3.10/site-packages/ansible_rulebook/cli.py", line 31, in <module>
    from ansible_rulebook import app
  File "/home/vagrant/.local/lib/python3.10/site-packages/ansible_rulebook/app.py", line 9, in <module>
    from ansible_rulebook import rules_parser as rules_parser
  File "/home/vagrant/.local/lib/python3.10/site-packages/ansible_rulebook/rules_parser.py", line 4, in <module>
    from ansible_rulebook.condition_parser import (
  File "/home/vagrant/.local/lib/python3.10/site-packages/ansible_rulebook/condition_parser.py", line 1, in <module>
    from pyparsing import (
ImportError: cannot import name 'OpAssoc' from 'pyparsing' (/usr/lib/python3/dist-packages/pyparsing.py)
~$ pip3 install pyparsing
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pyparsing in /usr/lib/python3/dist-packages (2.4.7)
~$ git clone https://github.com/ansible/ansible-rulebook.git
~$ cd ansible-rulebook/
~/ansible-rulebook$ pip3 install .
[...]
Successfully installed ansible-rulebook-0.8.0
~$  ansible-rulebook --help
Traceback (most recent call last):
  File "/home/vagrant/.local/bin/ansible-rulebook", line 5, in <module>
    from ansible_rulebook.cli import main
  File "/home/vagrant/.local/lib/python3.10/site-packages/ansible_rulebook/cli.py", line 31, in <module>
    from ansible_rulebook import app
  File "/home/vagrant/.local/lib/python3.10/site-packages/ansible_rulebook/app.py", line 9, in <module>
    from ansible_rulebook import rules_parser as rules_parser
  File "/home/vagrant/.local/lib/python3.10/site-packages/ansible_rulebook/rules_parser.py", line 4, in <module>
    from ansible_rulebook.condition_parser import (
  File "/home/vagrant/.local/lib/python3.10/site-packages/ansible_rulebook/condition_parser.py", line 1, in <module>
    from pyparsing import (
ImportError: cannot import name 'OpAssoc' from 'pyparsing' (/usr/lib/python3/dist-packages/pyparsing.py)

Follow ansible-playbook logic

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that ansible-rulebook is open source software provided for free and that I might not receive a timely response.

Feature type

Enhancement to Existing Feature

Feature Summary

Feature suggestion to allow simpler adoption

'ansible-playbook' allows running a playbook simply by running 'ansible-playbook example-playbook.yml'.
Following the same logic it would be nice to have 'ansible-rulebook' to be allowed to be run with 'ansible-rulebook example-rulebook'.

Steps to reproduce

'ansible-rulebook example-rulebook.yml -i example-inventory.yml'

Current results

Command fails.

Sugested feature result

Rulebook to run.

Additional information

No response

Installation requirements missing

  • ansible-rulebook version: '0.9.4'
  • Python version: 3.10
  • Operating System: MacOS 12.6

Java Open JDK:

openjdk 19 2022-09-20
OpenJDK Runtime Environment Homebrew (build 19)
OpenJDK 64-Bit Server VM Homebrew (build 19, mixed mode, sharing)

Description

  1. Missing "Installation requirements section" and missing instructions for MacOS.
  2. This derives on an issue installing and running on MacOS on M1 where:

jpyutil - WARNING: Failed to preload JVM shared library. No shared library found.
WARNING:jpyutil:Failed to preload JVM shared library. No shared library found.
ERROR:ansible_rulebook.cli:Unexpected exception
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.10/site-packages/ansible_rulebook/cli.py", line 145, in main
asyncio.run(app.run(args))
File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/opt/homebrew/Cellar/[email protected]/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/opt/homebrew/lib/python3.10/site-packages/ansible_rulebook/app.py", line 66, in run
await run_rulesets(
File "/opt/homebrew/lib/python3.10/site-packages/ansible_rulebook/engine.py", line 289, in run_rulesets
rulesets_queue_plans = rule_generator.generate_rulesets(
File "/opt/homebrew/lib/python3.10/site-packages/ansible_rulebook/rule_generator.py", line 247, in generate_rulesets
drools_ruleset = DroolsRuleset(
File "", line 6, in init
File "/opt/homebrew/lib/python3.10/site-packages/drools/ruleset.py", line 31, in _make_jpy_instance
jpyutil.init_jvm(jvm_maxmem=max_mem, jvm_classpath=[jar_file_path])
File "/opt/homebrew/lib/python3.10/site-packages/jpyutil.py", line 453, in init_jvm
import jpy
ImportError: dlopen(/opt/homebrew/lib/python3.10/site-packages/jpy.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace (_JNI_CreateJavaVM)

What I Did

pip install wheel ansible-rulebook ansible ansible-runner                         ๎‚ฒ โœ” ๎‚ณ 08:30:07 AM ๏€— ๎‚ด
Requirement already satisfied: wheel in /opt/homebrew/lib/python3.10/site-packages (0.37.1)
Requirement already satisfied: ansible-rulebook in /opt/homebrew/lib/python3.10/site-packages (0.9.4)
Requirement already satisfied: ansible in /opt/homebrew/lib/python3.10/site-packages (6.5.0)
Requirement already satisfied: ansible-runner in /opt/homebrew/lib/python3.10/site-packages (2.2.1)
Requirement already satisfied: drools-jpy in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (0.0.8)
Requirement already satisfied: jinja2 in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (3.1.2)
Requirement already satisfied: janus in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (1.0.0)
Requirement already satisfied: pyparsing>=3.0 in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (3.0.9)
Requirement already satisfied: redis in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (4.3.4)
Requirement already satisfied: dpath in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (2.0.6)
Requirement already satisfied: websockets in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (10.3)
Requirement already satisfied: jsonschema in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (4.16.0)
Requirement already satisfied: durable-rules in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (2.0.28)
Requirement already satisfied: asyncio in /opt/homebrew/lib/python3.10/site-packages (from ansible-rulebook) (3.4.3)
Requirement already satisfied: ansible-core~=2.13.5 in /opt/homebrew/lib/python3.10/site-packages (from ansible) (2.13.5)
Requirement already satisfied: python-daemon in /opt/homebrew/lib/python3.10/site-packages (from ansible-runner) (2.3.1)
Requirement already satisfied: pexpect>=4.5 in /opt/homebrew/lib/python3.10/site-packages (from ansible-runner) (4.8.0)
Requirement already satisfied: pyyaml in /opt/homebrew/lib/python3.10/site-packages (from ansible-runner) (6.0)
Requirement already satisfied: packaging in /opt/homebrew/lib/python3.10/site-packages (from ansible-runner) (21.3)
Requirement already satisfied: six in /opt/homebrew/lib/python3.10/site-packages (from ansible-runner) (1.16.0)
Requirement already satisfied: cryptography in /opt/homebrew/lib/python3.10/site-packages (from ansible-core~=2.13.5->ansible) (38.0.1)
Requirement already satisfied: resolvelib<0.9.0,>=0.5.3 in /opt/homebrew/lib/python3.10/site-packages (from ansible-core~=2.13.5->ansible) (0.8.1)
Requirement already satisfied: MarkupSafe>=2.0 in /opt/homebrew/lib/python3.10/site-packages (from jinja2->ansible-rulebook) (2.1.1)
Requirement already satisfied: ptyprocess>=0.5 in /opt/homebrew/lib/python3.10/site-packages (from pexpect>=4.5->ansible-runner) (0.7.0)
Requirement already satisfied: jpy in /opt/homebrew/lib/python3.10/site-packages (from drools-jpy->ansible-rulebook) (0.12.0)
Requirement already satisfied: typing-extensions>=3.7.4.3 in /opt/homebrew/lib/python3.10/site-packages (from janus->ansible-rulebook) (4.4.0)
Requirement already satisfied: attrs>=17.4.0 in /opt/homebrew/lib/python3.10/site-packages (from jsonschema->ansible-rulebook) (22.1.0)
Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /opt/homebrew/lib/python3.10/site-packages (from jsonschema->ansible-rulebook) (0.18.1)
Requirement already satisfied: lockfile>=0.10 in /opt/homebrew/lib/python3.10/site-packages (from python-daemon->ansible-runner) (0.12.2)
Requirement already satisfied: setuptools in /opt/homebrew/lib/python3.10/site-packages (from python-daemon->ansible-runner) (65.4.1)
Requirement already satisfied: docutils in /opt/homebrew/lib/python3.10/site-packages (from python-daemon->ansible-runner) (0.19)
Requirement already satisfied: deprecated>=1.2.3 in /opt/homebrew/lib/python3.10/site-packages (from redis->ansible-rulebook) (1.2.13)
Requirement already satisfied: async-timeout>=4.0.2 in /opt/homebrew/lib/python3.10/site-packages (from redis->ansible-rulebook) (4.0.2)
Requirement already satisfied: wrapt<2,>=1.10 in /opt/homebrew/lib/python3.10/site-packages (from deprecated>=1.2.3->redis->ansible-rulebook) (1.14.1)
Requirement already satisfied: cffi>=1.12 in /opt/homebrew/lib/python3.10/site-packages (from cryptography->ansible-core~=2.13.5->ansible) (1.15.1)
Requirement already satisfied: pycparser in /opt/homebrew/lib/python3.10/site-packages (from cffi>=1.12->cryptography->ansible-core~=2.13.5->ansible) (2.21)

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.