Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions extensions/eda/rulebooks/awx_bad_template_name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
# Basic rulebook with an invalid job template,
# to be used with https://github.com/Alex-Izquierdo/eda-awx-project-sample
- name: Basic short with an invalid job template name
hosts: all
sources:
- ansible.eda.range:
limit: 10
delay: 0.5
rules:
- name: Run an invalid JT at 8
condition: event.i == 8
actions:
- run_job_template:
organization: Default
name: run_bad_basic
job_args:
extra_vars:
fake_execution_time: "5"
36 changes: 36 additions & 0 deletions extensions/eda/rulebooks/awx_basic_custom_limit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Basic run with custom host limit
hosts: all
sources:
- ansible.eda.generic:
event_delay: 1
payload:
- user: "Rick"
universe: C-137
hosts:
- eda_localhost2

- user: "Morty"
universe: C-137

- user: "Rick"
universe: C-132

- user: "Rick"
universe: J-19-Zeta-1

- user: "Beth"
universe: K-22

- user: "Jerry"
universe: C-137

rules:
- name: Run basic with custom host limit
condition: event.user == "Rick" and event.universe == "C-137"
actions:
- run_job_template:
organization: Default
name: run_basic
job_args:
limit: "{{ event.hosts }}"
38 changes: 38 additions & 0 deletions extensions/eda/rulebooks/awx_long_running.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- name: Long Running with Awx JT
hosts: all
sources:
- ansible.eda.generic:
loop_count: "{{ total_loops | default(63072000) | int }}" # default two years
loop_delay: 1
event_delay: 5
create_index: iteration
payload:
- user: "Rick"
universe: C-137

- user: "Morty"
universe: C-137

- user: "Rick"
universe: C-132

- user: "Rick"
universe: J-19-Zeta-1

- user: "Beth"
universe: K-22

- user: "Jerry"
universe: C-137

rules:
- name: Awx long running rule
condition: event.user == "Rick" and event.universe == "C-137"
actions:
- run_job_template:
organization: Default
name: run_basic

- debug:
msg: "Awx long running rulebook, event {{ event.iteration }}"
29 changes: 29 additions & 0 deletions extensions/eda/rulebooks/awx_storm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: "Launch storm of JT's"
hosts: all
sources:
- ansible.eda.generic:
shutdown_after: 3600
repeat_count: 100
create_index: "index"
payload:
- state: "down"


rules:
- name: "Run job template - storm mode"
condition: event.state == "down"
actions:
- debug:
msg: "JT launched for #{{ event.index }}"

- run_job_template:
name: run_basic
organization: Default
job_args:
extra_vars:
fake_execution_time: "10"

- debug:
msg: "JT executed for #{{ event.index }}"

22 changes: 22 additions & 0 deletions extensions/eda/rulebooks/awx_storm_single_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
- name: "Launch storm of JT's with a single action"
hosts: all
sources:
- ansible.eda.generic:
shutdown_after: 3600
repeat_count: 100
create_index: "index"
payload:
- state: "down"


rules:
- name: "Run job template - storm mode - single action"
condition: event.state == "down"
action:
run_job_template:
name: run_basic
organization: Default
job_args:
extra_vars:
fake_execution_time: "10"
18 changes: 18 additions & 0 deletions extensions/eda/rulebooks/basic_batch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
# Basic rulebook with job template,
# to be used with https://github.com/Alex-Izquierdo/eda-awx-project-sample
- name: Basic Batch
hosts: all
sources:
- ansible.eda.range:
limit: 20
#delay: 0.5
rules:
- name: Run JT at 8
condition: event.i < 800
actions:
- run_job_template:
organization: Default
name: run_basic

execution_strategy: "parallel"
25 changes: 25 additions & 0 deletions extensions/eda/rulebooks/basic_short.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# Basic rulebook with job template,
# it will run a job template against single host in the inventory
# incase of the payload ke of letters is equle to "aaa"
- name: Basic short
hosts: all
sources:
- ansible.eda.webhook:
port: 5000
rules:
- name: Run job template when the event is aaa
condition: event.payload.letters== "aaa"
actions:
- run_job_template:
organization: Default
name: run_basic
job_args:
limit: "{{ event.payload.meta.hosts }}"
extra_vars:
pause_time_min: 5

- debug:
msg: "Basic short rulebook, event {{ event }}"

execution_strategy: "parallel"
19 changes: 19 additions & 0 deletions extensions/eda/rulebooks/basic_workflow_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Test run workflow templates
hosts: all
sources:
- ansible.eda.range:
limit: 5
delay: 10
rules:
- name: "Run workflow template"
condition: event.i == 0
action:
run_workflow_template:
name: workflow_basic
job_args:
extra_vars:
fake_execution_time: "2"
retries: 1
delay: 10
organization: Default
19 changes: 19 additions & 0 deletions extensions/eda/rulebooks/basic_workflow_template_failed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Test run workflow templates with failure
hosts: all
sources:
- ansible.eda.range:
limit: 5
delay: 10
rules:
- name: "Run workflow template"
condition: event.i == 0
action:
run_workflow_template:
name: workflow_basic_fail
job_args:
extra_vars:
fake_execution_time: "2"
retries: 1
delay: 10
organization: Default
30 changes: 30 additions & 0 deletions extensions/eda/rulebooks/colons_with_spaces_in_condition.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
- name: colon with spaces in condition
hosts: all
sources:
- name: simple source
ansible.eda.generic:
payload:
- a: 'abc : def'
- b: 'xyz : 123'
- c: 'xyz : 345'
- url: http://www.example.com
rules:
- name: r1
condition: 'event.a == "abc : def"'
action:
print_event:
- name: r2
condition: >
event.b == "xyz : 123"
action:
print_event:
- name: r3
condition: |
event.c == "xyz : 345"
action:
print_event:
- name: r4
condition: event.url == "http://www.example.com"
action:
print_event:
66 changes: 66 additions & 0 deletions extensions/eda/rulebooks/compare_with_saved_event.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
- name: list checks with saved events
hosts: all
sources:
- name: my source
ansible.eda.generic:
payload:
- plu: 4132
apples:
- gala large apple
- gala small apple
- fruit: gala large apple
- plu: 4284
grapefruits:
- Ray Ruby
- Ruby Red
- fruit: Ruby Red
- fruit:
name: Braeburn
plu: 4101
- favorite_apple_plus:
- 4101
- 4103
- 4132
- 4133
- fruit:
name: Kent
plu: 3488
- favorite_mango_plus:
- 3488
- 4959
- 4051
- 4312
rules:
- name: Gala rules
condition:
all:
- events.match << event.plu == 4132
- event.fruit in events.match.apples
action:
print_event:
pretty: true
- name: Ruby Red rules
condition:
all:
- events.match << event.plu == 4284
- events.match.grapefruits contains event.fruit
action:
print_event:
pretty: true
- name: Braeburn rules
condition:
all:
- events.apple << event.fruit.name == "Braeburn"
- events.apple.fruit.plu in event.favorite_apple_plus
action:
print_event:
pretty: true
- name: Kent mango rules
condition:
all:
- events.mango << event.fruit.name == "Kent"
- event.favorite_mango_plus contains events.mango.fruit.plu
action:
print_event:
pretty: true
15 changes: 15 additions & 0 deletions extensions/eda/rulebooks/fails/awx_fail.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: Execute a JT that will always fail
hosts: all
sources:
- ansible.eda.range:
limit: 10
delay: 0.5
rules:
- name: Run fail JT at 8
condition: event.i == 8
action:
run_job_template:
organization: Default
name: fail_basic

19 changes: 19 additions & 0 deletions extensions/eda/rulebooks/fails/bad_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
# Basic rulebook with invalid action,
# to be used with https://github.com/ansible/eda-project-sample
- name: Bad action
hosts: all
sources:
- ansible.eda.range:
limit: 10
delay: 1
rules:
- name: run bad_action
condition: event.i == 1
actions:
- bad_action:
organization: Default
name: run_basic
job_args:
extra_vars:
fake_execution_time: "5"
15 changes: 15 additions & 0 deletions extensions/eda/rulebooks/fails/source_error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# Requires DE: https://quay.io/repository/aizquier/eda-testing
- name: Source error
hosts: all
sources:
- alex_izquierdo.eda_testing.eda_failer:
iterations: 10
fail_at_index: 3
delay: "{{ delay_seconds | default(1) | int }}"
rules:
- name: Expected to fail at index 3
condition: event.i is defined
action:
debug:
msg: "Event received: #{{ event.i }}"
Loading