last task

18 views
Skip to first unread message

Frank

unread,
Aug 21, 2014, 1:27:26 PM8/21/14
to ansible...@googlegroups.com
Hi,

I am writing a role to setup ‘things’ on amazon ami (redhat based I suppose).

I have a yum upgrade step on it like so:

- name: upgrade all base packages
  yum: name=* state=latest

then ‘other stuff gets done’ like installing some additional software.

I want to put this next step in place to check if kernel version has changed or not and if so, reboot the server.

- name: Check what the new version is
  shell:  lsb_release -r | awk '{print $2}'
  register: new_release

- name: Reboot
  command: /sbin/reboot -t now
  when: {{ amzn_base_lsb_release }} != new_release.stdout

# amzn_base_lsb_release = defined in defaults/main.yml

Q: Is there a way for me to define this as the last step?
(this is a role and this task in defined in tasks/RedHat.yml inherited by tasks/main.yml)


Thanks in advance!

Yes, I’m going to release this as soon as it gets right (well, its my first role) :)

Cheers,
Frank

-- 
Change is the essential process of all existence.
-- Spock, "Let That Be Your Last Battlefield", stardate 5730.2

Michael DeHaan

unread,
Aug 22, 2014, 8:09:54 AM8/22/14
to ansible...@googlegroups.com
"Q: Is there a way for me to define this as the last step?"

Ansible is order based, so if you want a task to go last, make it the very last task in the last play in your playbook, and flush the handlers before running it

...

- meta: flush_handlers
- shell: echo "I am the last task"

This may it will make sure any other handlers complete before running the task.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/etPan.53f62bbf.6b8b4567.4eca%40Franciscos-MacBook-Air.local.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages