LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-20-2019, 09:22 AM   #1
hallomoto
Member
 
Registered: Nov 2018
Posts: 30

Rep: Reputation: Disabled
How to stop ansible from running a yum update playbook when it fails on the host before it?


Let's say the 2nd host of 20 hosts fail since I'm doing updates in pairs. How can I tell ansible to stop if the 2nd, or any in the host group fails?

Code:
---
- hosts: test
  gather_facts: yes
  remote_user: root
  become: yes
  become_method: sudo
  serial: 2
  tasks:
  - name: Yum Update
    yum:
      name: "*"
      state: latest
      exclude: nvidia*
      skip_broken: yes

  - name: Check for reboot hint.
    shell: LAST_KERNEL=$(rpm -q --last kernel | awk 'NR==1{sub(/kernel-/,""); print $1}'); CURRENT_KERNEL=$(uname -r); if [ $LAST_KERNEL != $CURRENT_KERNEL ]; then echo 'reboot'; else echo 'no'; fi
    ignore_errors: true
    register: reboot_hint

  - name: Rebooting ...
    command: shutdown -r now "Reboot required"
    async: 0
    poll: 0
    ignore_errors: true
    when: reboot_hint.stdout.find("reboot") != -1
    register: rebooting

#  - name: Wait for thing to reboot...
#    local_action: wait_for_host={{ ansible_ssh_host | default(inventory_hostname) }} state=started port=22 delay=30 timeout=300 connect_timeout=15
#    when: rebooting|changed
 
Old 02-20-2019, 01:02 PM   #2
hallomoto
Member
 
Registered: Nov 2018
Posts: 30

Original Poster
Rep: Reputation: Disabled
Adding:
Code:
any_errors_fatal: true
worked for me
 
  


Reply

Tags
ansible, centos7, rhel6, rhel7



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to stop ansible from running a yum update playbook when it fails on the host before it? hallomoto Linux - Newbie 0 02-20-2019 07:44 PM
Using passwords in ansible playbook pgb205 Linux - Server 1 12-27-2016 12:20 AM
ansible will not execute whole playbook DimTheo Linux - Server 1 11-23-2016 11:59 PM
Vagrant+Ansible playbooks. How to use same playbook on non vagrant provision markotitel Linux - Virtualization and Cloud 1 12-06-2013 09:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration