This commit is contained in:
Chris Evich 2017-09-22 17:19:13 +00:00 committed by GitHub
commit 887c39c1aa
4 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,29 @@
---
irc_server: "chat.freenode.net"
irc_port: 6665
irc_channel: "cri-o"
# Nick to join / send message
irc_from: "kry-oh"
# To whom should the message be addressed.
irc_to:
# If non-empty, use irc_nick_xlation file to set irc_to
commit_author:
# Author to nick translation file (in files subdir). CSV commit_author,irc_nick mapping
irc_nick_xlation: "author_to_nick.csv"
# jinja2 template filename (in templates subdir) to use for producing the message
irc_msg_template: "crio-integration-playbook.j2"
# Assertion-strings that must pass for above template
irc_msg_tmpl_asserts:
- 'verb | default()'
- 'irc_to | default()'
- 'commit | default() | trim | search("[0-9A-Fa-f]+")'
- 'pullrequest | default(0) | string | search("\d+")'
- 'irc_from | default()' # nick of sender
- 'commit_author | default() or irc_to | default()' # PR author / nick of recipient

View file

@ -0,0 +1,3 @@
willgates:cevich
rhatdan:dwalsh
TomSweeneyRedHat:tsweeney
1 willgates:cevich
2 rhatdan:dwalsh
3 TomSweeneyRedHat:tsweeney

View file

@ -0,0 +1,47 @@
---
- block: # delegate_to: localhost b/c 'is_file()', 'csvfile' and 'template' lookups
- name: All role assertions pass
assert:
that: # All are defined and non-empty
- 'irc_server | default()'
- 'irc_channel | default()'
- 'irc_from | default()'
- 'irc_to | default() or commit_author | default()'
- 'irc_msg_template | default()'
- 'irc_nick_xlation | default()'
- name: Relative paths are made absolute
set_fact:
_irc_msg_template: '{{ role_path ~ "/templates/" ~ irc_msg_template }}'
_irc_nick_xlation: '{{ role_path ~ "/files/" ~ irc_nick_xlation }}'
- name: Message recipient name is translated
set_fact:
irc_to: >
{{ lookup("csvfile",
commit_author ~
" file=" ~ _irc_nick_xlation ~
" col=1 delimiter=: default=" ~ irc_to) }}
when: commit_author | default() and _irc_nick_xlation | is_file
- name: All template assertions pass
assert:
that: '{{ irc_msg_tmpl_asserts }}'
- debug:
msg: 'Sending - {{ irc_server | trim }}#{{ irc_channel | trim }}: {{ irc_to |trim }}, {{ lookup("template", _irc_msg_template) | trim }}'
# FIXME: This is broken WRT freenode in Ansible 2.3
# possibly https://github.com/ansible/ansible/issues/24023
- name: Irc notification is sent
irc:
server: '{{ irc_server | trim }}'
port: '{{ irc_port | default(omit) }}'
channel: '{{ irc_channel | trim }}'
nick_to: '{{ irc_to | trim }}'
nick: '{{ irc_from | trim }}'
msg: '{{ lookup("template", _irc_msg_template) | trim }}'
delegate_to: localhost

View file

@ -0,0 +1,7 @@
{{ irc_to | trim }}, crio-integration-playbook {{ verb }} on {{
ansible_distribution ~ "-" ~ ansible_distribution_version }} for: {%
if pullrequest|default()
%}https://github.com/kubernetes-incubator/cri-o/pull/{{ pullrequest | trim }}{%
else
%}https://github.com/kubernetes-incubator/cri-o/commit/{{ commit | trim }}{%
endif %}