Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have an exit code when reboot is required #2

Open
DJviolin opened this issue Aug 18, 2022 · 0 comments
Open

Have an exit code when reboot is required #2

DJviolin opened this issue Aug 18, 2022 · 0 comments

Comments

@DJviolin
Copy link

DJviolin commented Aug 18, 2022

For Ansible deployment, please provide an exit code when reboot of the system is required.

So far this is how I solve this problem:

# tasks/main.yml

- name: Update Raspberry Pi kernel and firmware
  ansible.builtin.shell:
    cmd: echo y | rpi-update
  register: rpi_update_result
  changed_when: "rpi_update_result.stdout | regex_search('reboot is needed')"
  notify: Reboot machine

- name: Force all notified handlers to run at this point, not waiting for normal sync points
  ansible.builtin.meta: flush_handlers

# handlers/main.yml

- name: Reboot machine
  ansible.builtin.reboot:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant