• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

UnixArena

  • Home
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • Backup
    • Vembu BDR
    • Veeam
    • Nakivo
    • Azure Backup
    • Altaro VMBackup
    • Spinbackup
  • Tutorials
    • Openstack Tutorial
    • Openstack Beginner’s Guide
    • VXVM-Training
    • ZFS-Tutorials
    • NetApp cDot
    • LVM
    • Cisco UCS
    • LDOM
    • Oracle VM for x86
  • Linux
    • How to Articles
    • Q&A
    • Networking
    • RHEL7
  • DevOps Instructor-led Training
  • Contact

Ansible reboot module – Shutdown Command Not found on Linux

July 6, 2019 By Cloud_Devops Leave a Comment

Ansible is a widely used configuration management tool. Opensource community and RedHat aggressively developing to create modules for each task. In Ansible 2.7, reboot module is responsible to reboot the host and wait to come back. But the Linux image development varies for each organization. In some environment, engineers might remove shutdown command from the command search path or keeping shutdown binary in the custom path. If you bring those machines in Ansible automation, reboot module will fail with error ” shutdown command not found” This article will walk you through how to resolve that issue.

 

Environment:

  • Ansible 2.7 / 2.8
  • Ansible Clients – Linux

 

1. Login to Ansible server.

 

2. Here is the reboot ansible playbook.

---
- hosts: all
  become: yes

  tasks:
   - name: Check the uptime
     shell: uptime
     register: UPTIME_PRE_REBOOT

   - debug: msg={{UPTIME_PRE_REBOOT.stdout}}

   - name: Unconditionally reboot the machine with all defaults
     reboot:

   - name: Check the uptime after reboot
     shell: uptime
     register: UPTIME_POST_REBOOT

   - debug: msg={{UPTIME_POST_REBOOT.stdout}}

 

If you get shut down command not found, you have the following options.

  • Update Ansible Engine to 2.8. (# yum update ansible) and follow from step number 3.
  • Use legacy reboot method.

 

If you are running with Ansible engine 2.8, then tweak the playbook like below.

 

3. In Ansible 2.8, Ansible’s reboot module had the option to include the command search path as argument. In my hosts, shutdown command has been kept in /usr/sbin/custom/

---
- hosts: all
  become: yes

  tasks:
   - name: Check the uptime
     shell: uptime
     register: UPTIME_PRE_REBOOT

   - debug: msg={{UPTIME_PRE_REBOOT.stdout}}

   - name: Unconditionally reboot the machine with all defaults
     reboot:
         search_paths: /usr/sbin/custom/

   - name: Check the uptime after reboot
     shell: uptime
     register: UPTIME_POST_REBOOT

   - debug: msg={{UPTIME_POST_REBOOT.stdout}}

 

The search_path argument is responsible provide the shutdown command path for reboot module. Try the playbook in the test environment and validate the results.

 

Share it! Comment it!! Be Sociable

Filed Under: Ansible engine, Automation, Configuration Management, DevOps Tagged With: Ansible, Linux

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version