I am using Spacewalk release 2.9 to manage my CentOS Linux server. using below spacecmd command to push the new packages. I want to reboot the server once all the packages are installed on the machine. I am unsure how to monitor package upgrade and issue the reboot command. Any recommendations to achieve this? I would like to use Ansible playbook to do this reboot.

spacecmd  system_upgradepackage  <hostname> '*' -y

Thanks SR

  • Above spacecmd command invokes the packages to be pushed, it won't wait until task completed, we need to wait patches pushed and reboot the server. – sfgroups Aug 22 at 15:34

Ansible can reboot the server without using spacecmd, using the reboot command.

- name: Upgrading via spacewalk
  shell: spacecmd  system_upgradepackage  <hostname> '*' -y
- name: Reboot after upgrades
  shell: reboot
  async: 0
  poll: 0
- name: Waiting for host to come up
  local_action: wait_for host={{ ansible_ssh_host }} state=started

Adapted from: https://www.linux.com/tutorials/ansible-reboot-server-play-book-and-wait-it-come-back

  • we need to check patches pushed, before invoking os reboot. otherwise system will reboot in middle of patching. – sfgroups Aug 22 at 15:37

I'm not familiar with spacecmd, but you can use the wait_for module to monitor the PID.

From docs:

- name: Wait until the process is finished and PID was destroyed
    path: /proc/3466/status
    state: absent
  • spacecmd will be running from control host, we can check the PID status to check the patch push status. – sfgroups Aug 26 at 14:13
  • so we can wait until the PID gets exited in localhost – msp9011 Aug 26 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.