diff --git a/awx_collection/README.md b/awx_collection/README.md index df4508cf60..91fb00f35d 100644 --- a/awx_collection/README.md +++ b/awx_collection/README.md @@ -51,6 +51,7 @@ The following notes are changes that may require changes to playbooks: - Specified `tower_config` file used to handle `k=v` pairs on a single line; this is no longer supported. Please use a file formatted as `yaml`, `json` or `ini` only. - Some return values (e.g., `credential_type`) have been removed. Use of `id` is recommended. - `tower_job_template` no longer supports the deprecated `extra_vars_path` parameter, please use `extra_vars` with the lookup plugin to replace this functionality. + - `notification_configration` parameter of `tower_notification` has changed from a string to a dict. Please use the `lookup` plugin to read an existing file into a dict. ## Running Unit Tests diff --git a/awx_collection/plugins/modules/tower_notification.py b/awx_collection/plugins/modules/tower_notification.py index d8181750db..29fef09550 100644 --- a/awx_collection/plugins/modules/tower_notification.py +++ b/awx_collection/plugins/modules/tower_notification.py @@ -229,6 +229,7 @@ EXAMPLES = ''' - name: Add Slack notification tower_notification: name: slack notification + organization: Default notification_type: slack channels: - general @@ -236,6 +237,20 @@ EXAMPLES = ''' state: present tower_config_file: "~/tower_cli.cfg" +- name: Add custom messages to our notification + tower_notification: + name: slack notification + notification_type: slack + organization: Default + messages: + started: + message: "{{ '{{' }} job_friendly_name {{' }}' }} {{ '{{' }} job.id {{' }}' }} started" + success: + message: "{{ '{{' }} job_friendly_name {{ '}}' }} completed in {{ '{{' }} job.elapsed {{ '}}' }} seconds" + error: + message: "{{ '{{' }} job_friendly_name {{ '}}' }} FAILED! Please look at {{ '{{' }} job.url {{ '}}' }}" + tower_config_file: "~/tower_cli.cfg" + - name: Add webhook notification tower_notification: name: webhook notification @@ -319,6 +334,7 @@ EXAMPLES = ''' notification_type: email state: absent tower_config_file: "~/tower_cli.cfg" + ''' diff --git a/awx_collection/tests/integration/targets/tower_notification/tasks/main.yml b/awx_collection/tests/integration/targets/tower_notification/tasks/main.yml index d51b8e341f..de40fb91c5 100644 --- a/awx_collection/tests/integration/targets/tower_notification/tasks/main.yml +++ b/awx_collection/tests/integration/targets/tower_notification/tasks/main.yml @@ -66,7 +66,7 @@ # The 27 can be count from the size of the OLD_INPUT_NAMES list in the module - result['deprecations'] | length() == 27 -- name: Create Slack notification +- name: Create Slack notification with custom messages tower_notification: name: "{{ slack_not }}" organization: Default @@ -74,6 +74,13 @@ token: a_token channels: - general + messages: + started: + message: "{{ '{{' }} job_friendly_name {{' }}' }} {{ '{{' }} job.id {{' }}' }} started" + success: + message: "{{ '{{' }} job_friendly_name {{ '}}' }} completed in {{ '{{' }} job.elapsed {{ '}}' }} seconds" + error: + message: "{{ '{{' }} job_friendly_name {{ '}}' }} FAILED! Please look at {{ '{{' }} job.url {{ '}}' }}" state: present register: result