---
# This playbook is intended to modify winrm parameters
# this is involved because changing winrm properties isn't allowed over winrm
# so the play uses a scheduled task to do it
- hosts: windows-boxes
gather_facts: true
tasks:
- name: display current minute of the hour
debug:
var: ansible_date_time.minute
- name: fail if its near the top of the hour because I am too lazy to handle special case of trying to run in 1 minute after 15:59
fail: msg="re-run a couple of minutes its not a good time to run a scheduled task"
when: ansible_date_time.minute|int > 58
- name: fetch original configuration
raw: winrm get winrm/config
register: old_configuration
- name: show original configuration
debug:
var: old_configuration
- name: set time scheduled fact
set_fact:
scheduled_time: "{{ ansible_date_time.hour|string}}:{{ (1 + ansible_date_time.minute|int) |string}}"
- name: schedule the config change
win_scheduled_task: name="Configure winrm timeouts 1" execute="winrm" frequency="daily" time="{{ scheduled_time }}" description="fix up winrm timeouts 1" enable=yes state=present user=SYSTEM argument='set winrm/config @{MaxTimeoutms = "36000000"}'
- name: wait for 2 minutes for the scheduled task to run
pause: minutes=2
- name: reboot the box to pick up new configuration
win_reboot:
- name: disable and remove the scheduled task
win_scheduled_task: name="Configure winrm timeouts 1" execute="winrm" frequency="daily" time="{{ scheduled_time }}" description="fix up winrm timeouts 1" enable=no state=absent user=SYSTEM argument='set winrm/config @{MaxTimeoutms = "36000000"}'
- name: fetch updated configuration
raw: winrm get winrm/config
register: new_configuration
- name: show updated configuration
debug:
var: new_configuration