reboot host based on ansible output

14 views
Skip to first unread message

Tony Wong

unread,
Jun 16, 2023, 9:47:10 AM6/16/23
to Ansible Project
I got pb that based on output will say:

reboot required: True
or reboot required: False

if its false how do i skip the reboot on the following task?

Will McDonald

unread,
Jun 16, 2023, 10:07:45 AM6/16/23
to ansible...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/de46990a-8d98-4dd9-82a8-54299a1e32adn%40googlegroups.com.

Tony Wong

unread,
Jun 16, 2023, 1:52:22 PM6/16/23
to ansible...@googlegroups.com
can i do something like this instead. using when condition

    - name: Run Esxcli command

      vmware_host_esxcli:

        hostname: '{{ vcenter_hostname }}'

        username: '{{ admin}}'

        password: '{{ pass }}'

        esxi_hostname: "{{ inventory_hostname }}"

        validate_certs: no

        cmd: '{{ cmd }}'

      delegate_to: localhost

      register: esxcli_output

 

    - name: Display esxcli output

      debug:

        var: esxcli_output.stdout_lines

 

    - name: Reboot ESXi host

      vmware_host_powerstate:

        hostname: '{{ vcenter_hostname }}'

        username: '{{ admin}}'

        password: '{{ pass }}'

        esxi_hostname: "{{ inventory_hostname }}"

        validate_certs: no

        state: reboot-host

      delegate_to: localhost

      when: "esxcli_output.stdout_lines[0] != 'Reboot Required: false'"


You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/brtCjCFdvoU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAKtKohQe5TSq%3DNW0BH1Vm3mdO0dhd7NqmJWpcB-WCF7D9OQW5Q%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages