Well it turns out you can.  Here's a hacky playbook to tweak the timeout

---
# 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






On Thursday, September 22, 2016 at 11:24:15 AM UTC+1, J Hawkesworth wrote:
>
> Hi,
>
> Has anyone managed to successfully reconfigure winrm remotely via a 
> playbook?  I need to up some timeouts and increase the MaxMemoryPerShellMB 
>
> I know that reconfiguring winrm is one of the things that is specifically 
> disallowed over winrm remoting, but I imagine a scheduled task could do it. 
>  I'm aware you also have to restart winrm, but in my case I could happily 
> wait through a win_reboot.  Reconfiguring it manually via RDP is not really 
> an option - too many servers to change!
>
> Many thanks,
>
> Jon
>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e9ed03ce-67cd-407c-b40f-fa8aa9682049%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to