Files
awx/awx_collection/tests/integration/targets/tower_notification/tasks/main.yml

217 lines
4.8 KiB
YAML

---
- name: Generate names
set_fact:
slack_not: "AWX-Collection-tests-tower_notification-slack-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
webhook_not: "AWX-Collection-tests-tower_notification-wehbook-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
email_not: "AWX-Collection-tests-tower_notification-email-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
twillo_not: "AWX-Collection-tests-tower_notification-twillo-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
pd_not: "AWX-Collection-tests-tower_notification-pd-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
hipchat_not: "AWX-Collection-tests-tower_notification-hipchat-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
irc_not: "AWX-Collection-tests-tower_notification-irc-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Create Slack notification
tower_notification:
name: "{{ slack_not }}"
organization: Default
notification_type: slack
token: a_token
channels:
- general
state: present
register: result
- assert:
that:
- result is changed
- name: Delete Slack notification
tower_notification:
name: "{{ slack_not }}"
organization: Default
notification_type: slack
state: absent
register: result
- assert:
that:
- result is changed
- name: Add webhook notification
tower_notification:
name: "{{ webhook_not }}"
organization: Default
notification_type: webhook
url: http://www.example.com/hook
headers:
X-Custom-Header: value123
state: present
register: result
- assert:
that:
- result is changed
- name: Delete webhook notification
tower_notification:
name: "{{ webhook_not }}"
organization: Default
notification_type: webhook
state: absent
register: result
- assert:
that:
- result is changed
- name: Add email notification
tower_notification:
name: "{{ email_not }}"
organization: Default
notification_type: email
username: user
password: s3cr3t
sender: tower@example.com
recipients:
- user1@example.com
host: smtp.example.com
port: 25
use_tls: false
use_ssl: false
state: present
register: result
- assert:
that:
- result is changed
- name: Delete email notification
tower_notification:
name: "{{ email_not }}"
organization: Default
notification_type: email
state: absent
register: result
- assert:
that:
- result is changed
- name: Add twilio notification
tower_notification:
name: "{{ twillo_not }}"
organization: Default
notification_type: twilio
account_token: a_token
account_sid: a_sid
from_number: '+15551112222'
to_numbers:
- '+15553334444'
state: present
register: result
- assert:
that:
- result is changed
- name: Delete twilio notification
tower_notification:
name: "{{ twillo_not }}"
organization: Default
notification_type: twilio
state: absent
register: result
- assert:
that:
- result is changed
- name: Add PagerDuty notification
tower_notification:
name: "{{ pd_not }}"
organization: Default
notification_type: pagerduty
token: a_token
subdomain: sub
client_name: client
service_key: a_key
state: present
register: result
- assert:
that:
- result is changed
- name: Delete PagerDuty notification
tower_notification:
name: "{{ pd_not }}"
organization: Default
notification_type: pagerduty
state: absent
register: result
- assert:
that:
- result is changed
- name: Add HipChat notification
tower_notification:
name: "{{ hipchat_not }}"
organization: Default
notification_type: hipchat
token: a_token
message_from: user1
api_url: https://hipchat.example.com
color: red
rooms:
- room-A
notify: true
state: present
register: result
- assert:
that:
- result is changed
- name: Delete HipChat notification
tower_notification:
name: "{{ hipchat_not }}"
organization: Default
notification_type: hipchat
state: absent
register: result
- assert:
that:
- result is changed
- name: Add IRC notification
tower_notification:
name: "{{ irc_not }}"
organization: Default
notification_type: irc
nickname: tower
password: s3cr3t
targets:
- user1
port: 8080
server: irc.example.com
use_ssl: false
state: present
register: result
- assert:
that:
- result is changed
- name: Delete IRC notification
tower_notification:
name: "{{ irc_not }}"
organization: Default
notification_type: irc
state: absent
register: result
- assert:
that:
- result is changed