Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update stable 1.1 with main #726

Merged

Conversation

zkayyali812
Copy link
Contributor

Updates stable-1.1 branch with latest main
In draft state until version PR is merged - #725

mkanoor and others added 8 commits September 27, 2024 20:02
When we unconditionally send event data to the controller for a workflow
template the launch of the workflow template fails. With this option in
a rulebook the user can prevent event data from being sent by setting

   - include_events: false

The default value is true so existing rulebooks will keep sending events
to controller.
Fixes ansible#622 
https://issues.redhat.com/browse/AAP-13456

Root Cause Analysis:
In the Controller if you are running a workflow template you cannot send
event data to it unconditionally like we can do with job template. We
get an error from Controller

**Check the Prompt on Launch setting on the Workflow Job Template to
include Extra Variables.**

If a survey spec is involved then there are more constraints if there
are certain parameters that are marked as required in the survey spec.

So we get 2 distinct items

-   Prompt on Launch for Extra Variables
-   Survey Spec

The following use cases are supported for workflow job template with and
without survey spec.

The use cases are based on a rulebook that looks like the following with
the action being updated for every case.
```
---
- name: Test run job templates
  hosts: all
  sources:
    - ansible.eda.generic:
         payload:
           - name: Fred
             age: 25
  rules:
    - name: "Run job template"
      condition: event.age == 25
      action:
        run_workflow_template:
          name: workflow_mk
          organization: Default
```

### **Case 1:**
If your Workflow Template doesn't support Prompt on Launch for Extra
Vars and a Survey Spec is not enabled

```
run_workflow_template:
          name: workflow_mk
          include_events: false
          organization: Default
```
### **Case 2:**
If your Workflow Template supports Prompt on Launch for Extra Vars and a
Survey Spec is not enabled

```
 run_workflow_template:
          name: workflow_mk
          organization: Default
          job_args:
            extra_vars:
              name: "{{ event.name }}"
```
The payload sent to Controller

```
name: Fred
ansible_eda:
  ruleset: Test run job templates
  rule: Run job template
  event:
    meta:
      source:
        name: ansible.eda.generic
        type: ansible.eda.generic
      received_at: '2024-09-26T05:29:10.983346Z'
      uuid: 9570c7f8-9bc9-438f-9199-803707e31ccf
    name: Fred
    age: 25
```
### **Case 3:**
If your Workflow Template doesn't support Prompt on Launch for Extra
Vars and a Survey Spec is enabled
```
 run_workflow_template:
          name: workflow_mk
          include_events: false
          organization: Default
          job_args:
            extra_vars:
              name: "{{ event.name }}"
```
The payload sent to Controller

```
 name: Fred
```

### **Case 4:**
If your Workflow Template supports Prompt on Launch for Extra Vars and a
Survey Spec is enabled
```
action:
        run_workflow_template:
          name: workflow_mk
          organization: Default
          job_args:
            extra_vars:
              name: "{{ event.name }}"
```

The payload sent to Controller
```
name: Fred
ansible_eda:
  ruleset: Test run job templates
  rule: Run job template
  event:
    meta:
      source:
        name: ansible.eda.generic
        type: ansible.eda.generic
      received_at: '2024-09-26T07:26:42.160723Z'
      uuid: 46169e51-ba6f-4a55-963b-b626fff7cfdc
    name: Fred
    age: 25
```

### **Case 5:** Survey Spec has a required parameter and its not
provided
```
action:
        run_workflow_template:
          name: workflow_mk
          organization: Default
```

Missing args
2024-09-26 12:59:03,738 - ansible_rulebook.job_template_runner - ERROR -
Error {'variables_needed_to_start': ["'name' value missing"]}

### **Case 6:** Survey Spec has no required parameter and its not
provided
```
action:
        run_workflow_template:
          name: workflow_mk
          organization: Default
```

The Default Value is provided by the Survey Spec and it works
```
name: fred
ansible_eda:
  ruleset: Test run job templates
  rule: Run job template
  event:
    meta:
      source:
        name: ansible.eda.generic
        type: ansible.eda.generic
      received_at: '2024-09-26T07:55:15.320036Z'
      uuid: 68a6c25d-dcf5-4a1c-8eb2-7432376d2d88
    name: Fred
    age: 25
```
Yesterday, 3.11 version of `aiohttp` was released with [breaking changes
](https://github.com/aio-libs/aiohttp/releases/tag/v3.11.0 ) which
breaks `aioresponses` library used for our mocks and as consequence some
of our tests are failing.
Ref: pnuckowski/aioresponses#262

Regardless of whether this is fixed in aioresponses, aiohttp can
introduce breaking changes in minor versions, so I pin it to the latest
tested version as this library is critical for the stability in some of
our features.

Signed-off-by: Alex <[email protected]>
Adds support for python 3.12. 
Also updates a test with a race condition in 3.12

---------

Signed-off-by: Alex <[email protected]>
…nsible#711)

AAP Credential Types support File contents via file injectors.

https://docs.ansible.com/automation-controller/latest/html/userguide/credential_types.html

We create temporary files with the data sent from Server The source
plugin can access the temporary file names to access the data.

Supports single file as well as multiple files.

To access the filenames in the source rulebook you can use the following
extra vars

- eda.filename or
- eda.filename.<<key_name1>>
- eda.filename.<<key_name2>>

e.g.
```
- name: Use payload file to check events
  hosts: all
  sources:
    - ansible.eda.generic:
        payload_file: "{{ eda.filename.test_payload_file }}"
```

The env variables are treated like extra_vars and added to the current
processes environment

https://issues.redhat.com/browse/AAP-25519
This is a little enhancement when the source plugin fails and raises an
exception without message.
Also extends the source plugin development guide. 
Related with https://issues.redhat.com/browse/AAP-19598
Updates ansible-rulebook version to 1.1.2
@zkayyali812 zkayyali812 marked this pull request as ready for review December 9, 2024 16:45
Copy link

sonarqubecloud bot commented Dec 9, 2024

@zkayyali812 zkayyali812 merged commit 54edaf5 into ansible:stable-1.1 Dec 9, 2024
13 checks passed
@zkayyali812 zkayyali812 deleted the update-stable-1.1-with-main branch December 9, 2024 17:52
@zkayyali812 zkayyali812 restored the update-stable-1.1-with-main branch December 9, 2024 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants