Me too new just from my scenario I am suggesting to use a handler on play 
book level.
And then added a notify to handler on each task where I expect a reboot to 
be done.

Below is a trial run we did.
.
├── README.md
├── ansible.cfg
├── group_vars
│   ├── all
│   ├── ccenter.yml
│   ├── linux.yml
│   └── windows.yml
├── handlers
│   └── main.yml
├── hosts
├── roles
│   ├── oc
│   │   └── tasks
│   │       └── main.yml
│   ├── todo
│   │   ├── files
│   │   │   └── temp_files
│   │   │       ├── 1.txt
│   │   │       ├── 2.txt
│   │   │       └── dummy
│   │   │           └── dummy.txt
│   │   └── tasks
│   │       └── main.yml
│   └── trial
│       ├── files
│       │   └── sample.xml
│       ├── meta
│       │   └── main.yml
│       └── tasks
│           ├── RedHat.yml
│           ├── Windows.yml
│           └── main.yml
├── site.retry
└── site.yml

*handler/main.yml*

- name: Reboot windows server
  win_reboot:
    msg: Reboot initiated by Ansible
    test_command: whoami
  register: win_reboot_result


*sample task in the playbook*

- name: Install Web Deploy 3.6
  win_package:
    name: Microsoft Web Deploy 3.6
    path: 
http://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_amd64_en-US.msi
    product_id: '{6773A61D-755B-4F74-95CC-97920E45E696}'
    arguments: '/q /norestart'
    state: present
    expected_return_code: [0, 666, 3010]
  notify:
    - Reboot windows server

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

Note: Reboot will be done if any change identified on that task.

Thanks,
Sivakumar

On Wednesday, October 4, 2017 at 6:41:57 PM UTC+8, Sunil Kumar wrote:
>
> Hi Jordon,
>
> I am almost there. Your code is working absolutely fine. But need to 
> handle below logic.
>
> 1) We can't say how many updates will ask for reboot so having win_updates 
> multiple times in playbook can't work (we cannot hard code)  --> If we have 
> the logic when ever reboot is triggered the control should go for 
> win_updates.
>
> 2) With the above given code. Second round of updates should execute only 
> if win_reboot is executed other wise it should skip.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/69bd4242-0dc4-4a88-bffe-011bed2dafbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to