getting 'play recap' changed variable from playbook

55 views
Skip to first unread message

Pieter Voet

unread,
Jan 10, 2017, 9:04:58 AM1/10/17
to Ansible Project
Hi all,

if any play in a  playbook actually changes something, I want to display a 'please restart something' message to the playbook user.
Is there a way to get the 'PLAY RECAP' changed  variable value from a playbook ?

something like this pseudo playbook:

---
- hosts: all
  tasks:
  - name: Do something
    shell: doit.sh

  - debug: msg="Please restart server to effectuate changes..."
    when: play_recap | Changed


I don't want a restart to get initiated from the playbook. The playbook should be used to possibly make a configuration change,
and when it did change something, the user should be notified to schedule the required restart later..

Wasn't able to find anything using on this using Google so far.. 
Thanks for any hints.

pieter.

Kai Stian Olstad

unread,
Jan 11, 2017, 5:14:18 AM1/11/17
to ansible...@googlegroups.com
On 10.01.2017 15:04, Pieter Voet wrote:
> Hi all,
>
> if any play in a playbook actually changes something, I want to
> display a
> 'please restart something' message to the playbook user.
> Is there a way to get the 'PLAY RECAP' changed variable value from a
> playbook ?

I think the only way is to write you own callback plugin.


> something like this pseudo playbook:
>
> ---
> - hosts: all
> tasks:
> - name: Do something
> shell: doit.sh
>
> - debug: msg="Please restart server to effectuate changes..."
> when: play_recap | Changed
>
>
> I don't want a restart to get initiated from the playbook. The playbook
> should be used to possibly make a configuration change,
> and when it did change something, the user should be notified to
> schedule
> the required restart later..

You could use a handler like so

---
- hosts: all
tasks:
- name: Do something
shell: doit.sh
notify: Inform user to reboot

handlers:
- name: Inform user to reboot
debug: msg="Please restart server to effectuate changes..."

--
Kai Stian Olstad

Pieter Voet

unread,
Jan 11, 2017, 11:12:13 AM1/11/17
to Ansible Project
Thanks Kai !  Will look into that...
Reply all
Reply to author
Forward
0 new messages