inventory_hostname ‘ inventory_hostname ‘ contains the name of the current node being worked on…. (as in, what it is defined in your hosts file as) so if you want to skip a task for a single node – - name: Restart amavis service: name=amavis state=restarted when: inventory_hostname != "boris" (Don’t restart Amavis for boris, do for all others). You could also use : ... when: inventory_hostname not in groups['group_name'] ... if your aim was to (perhaps skip) a task for some nodes in the specified group. Need to check whether you need to reboot for a kernel update? If /vmlinuz doesn’t resolve to the same kernel as we’re running Reboot Wait 45 seconds before carrying on… - name: Check for reboot hint. shell: if [ $(readlink -f /vmlinuz) != /boot/vmlinuz-$(uname -r) ]; then echo 'reboot'; else echo 'no'; fi ignore_errors: true register: reboot_hint - name: Rebooting ... command: shutdown -r now "Ansible kernel update applied...