This repository has been archived by the owner. It is now read-only.

win_firewall_rule fails if rule already exists #2882

Closed
okand opened this Issue Sep 8, 2016 · 10 comments

Comments

Projects
None yet
4 participants
@okand

okand commented Sep 8, 2016

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_firewall_rule

ANSIBLE VERSION
ansible 2.2.0 (devel 982db58aff) last updated 2016/09/08 10:42:53 (GMT +200)
  lib/ansible/modules/core: (detached HEAD db38f0c876) last updated 2016/09/08 10:42:58 (GMT +200)
  lib/ansible/modules/extras: (detached HEAD 8bfdcfcab2) last updated 2016/09/08 10:43:03 (GMT +200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

CONFIGURATION
OS / ENVIRONMENT

Managing five Windows Server 2012R2 servers and 1 Ubuntu 16.04.1 LTS server
Running Ansible on Ubuntu Gnome 16.04.1 LTS

SUMMARY

I'm testing a role to install Check_MK Raw on a server and add some windows clients to the monitoring.
Most of it works great but if the windows firewall rule I'm trying to add already exists the task fails.
My first task adds the rule as intended but the second task that's supposed to just enable the rule to allow ICMP pings that's there but disabled by default fails. My own rule also fails when running the tasks a second time.

STEPS TO REPRODUCE

Run the following tasks twice

- name: open check_mk agent port (tcp 6556) in windows firewall
  win_firewall_rule:
    name: check_mk_agent
    enable: yes
    state: present
    action: allow
    localport: 6556
    protocol: tcp
    direction: in

- name: allow ping in windows firewall
  win_firewall_rule:
    name: File and Printer Sharing (Echo Request - ICMPv4-In)
    enable: yes
    state: present
    action: allow
    direction: in
EXPECTED RESULTS

The port is opened and pings are responded to.

ACTUAL RESULTS

On the first run the port opens and the ping rule fails to enable. On a second run the first rule fails because the name already exists but the values for the rule are somehow different.

First run:

ansible :: ~/Ansible % ansible-playbook -i hosts testing.yml -vvvv                                     
Using /etc/ansible/ansible.cfg as config file
Loading callback plugin default of type stdout, v2.0 from /home/alexander/Ansible-dev/lib/ansible/plugins/callback/__init__.pyc

PLAYBOOK: testing.yml **********************************************************
1 plays in testing.yml

PLAY [testest] *****************************************************************

TASK [setup] *******************************************************************
Using module file /home/alexander/Ansible-dev/lib/ansible/modules/core/windows/setup.ps1
<10.18.50.227> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 5986 TO 10.18.50.227
<10.18.50.227> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1473343551.53-126456624515737").FullName | Write-Host -Separator '';
<10.18.50.227> PUT "/tmp/tmpqi3n7G" TO "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343551.53-126456624515737\setup.ps1"
<10.18.50.227> EXEC Set-StrictMode -Version Latest
Try
{
& 'C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343551.53-126456624515737\setup.ps1'
}
Catch
{
$_obj = @{ failed = $true }
If ($_.Exception.GetType)
{
$_obj.Add('msg', $_.Exception.Message)
}
Else
{
$_obj.Add('msg', $_.ToString())
}
If ($_.InvocationInfo.PositionMessage)
{
$_obj.Add('exception', $_.InvocationInfo.PositionMessage)
}
ElseIf ($_.ScriptStackTrace)
{
$_obj.Add('exception', $_.ScriptStackTrace)
}
Try
{
$_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
Finally { Remove-Item "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343551.53-126456624515737" -Force -Recurse -ErrorAction SilentlyContinue }
ok: [app01] => {
    "ansible_facts": {
        "ansible_architecture": "64-bit", 
        "ansible_bios_date": "05-23-2012", 
        "ansible_bios_version": "090006 ", 
        "ansible_date_time": {
            "date": "2016-09-08", 
            "day": "08", 
            "epoch": "1473350758,17984", 
            "hour": "16", 
            "iso8601": "2016-09-08T14:05:58Z", 
            "iso8601_basic": "20160908T160558117332", 
            "iso8601_basic_short": "20160908T160558", 
            "iso8601_micro": "2016-09-08T14:05:58.117332Z", 
            "minute": "05", 
            "month": "09", 
            "second": "58", 
            "time": "16:05:58", 
            "tz": "W. Europe Standard Time", 
            "tz_offset": "+02:00", 
            "weekday": "Thursday", 
            "weekday_number": "4", 
            "weeknumber": "36", 
            "year": "2016"
        }, 
        "ansible_distribution": "Microsoft Windows Server 2012 R2 Datacenter", 
        "ansible_distribution_major_version": "6", 
        "ansible_distribution_version": "6.3.9600.0", 
        "ansible_domain": "", 
        "ansible_env": {
            "ALLUSERSPROFILE": "C:\\ProgramData", 
            "APPDATA": "C:\\Users\\Administrator\\AppData\\Roaming", 
            "COMPUTERNAME": "WIN-PLDULKMKPDS", 
            "ComSpec": "C:\\Windows\\system32\\cmd.exe", 
            "CommonProgramFiles": "C:\\Program Files\\Common Files", 
            "CommonProgramFiles(x86)": "C:\\Program Files (x86)\\Common Files", 
            "CommonProgramW6432": "C:\\Program Files\\Common Files", 
            "FP_NO_HOST_CHECK": "NO", 
            "LOCALAPPDATA": "C:\\Users\\Administrator\\AppData\\Local", 
            "MODULE_COMPLEX_ARGS": "{\"_ansible_version\": \"2.2.0\", \"_ansible_selinux_special_fs\": [\"fuse\", \"nfs\", \"vboxsf\", \"ramfs\"], \"_ansible_no_log\": false, \"gather_timeout\": 10, \"_ansible_module_name\": \"setup\", \"_ansible_verbosity\": 4, \"_ansible_syslog_facility\": \"LOG_USER\", \"gather_subset\": \"all\", \"_ansible_diff\": false, \"_ansible_debug\": false, \"_ansible_check_mode\": false}", 
            "NUMBER_OF_PROCESSORS": "2", 
            "OS": "Windows_NT", 
            "PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL", 
            "PROCESSOR_ARCHITECTURE": "AMD64", 
            "PROCESSOR_IDENTIFIER": "Intel64 Family 6 Model 29 Stepping 1, GenuineIntel", 
            "PROCESSOR_LEVEL": "6", 
            "PROCESSOR_REVISION": "1d01", 
            "PROMPT": "$P$G", 
            "PSExecutionPolicyPreference": "Unrestricted", 
            "PSModulePath": "C:\\Users\\Administrator\\Documents\\WindowsPowerShell\\Modules;C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules", 
            "PUBLIC": "C:\\Users\\Public", 
            "Path": "C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0", 
            "ProgramData": "C:\\ProgramData", 
            "ProgramFiles": "C:\\Program Files", 
            "ProgramFiles(x86)": "C:\\Program Files (x86)", 
            "ProgramW6432": "C:\\Program Files", 
            "SystemDrive": "C:", 
            "SystemRoot": "C:\\Windows", 
            "TEMP": "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp", 
            "TMP": "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp", 
            "USERDOMAIN": "WIN-PLDULKMKPDS", 
            "USERNAME": "Administrator", 
            "USERPROFILE": "C:\\Users\\Administrator", 
            "windir": "C:\\Windows"
        }, 
        "ansible_fqdn": "WIN-PLDULKMKPDS.", 
        "ansible_hostname": "WIN-PLDULKMKPDS", 
        "ansible_interfaces": [
            {
                "default_gateway": "10.18.50.254", 
                "dns_domain": "inet.graz", 
                "interface_index": 12, 
                "interface_name": "Microsoft Hyper-V Network Adapter"
            }, 
            {
                "default_gateway": null, 
                "dns_domain": null, 
                "interface_index": 14, 
                "interface_name": "Microsoft Hyper-V Network Adapter #2"
            }
        ], 
        "ansible_ip_addresses": [
            "10.18.50.227", 
            "169.254.180.170"
        ], 
        "ansible_kernel": "6.3.9600.0", 
        "ansible_lastboot": "2016-09-08 16:03:47Z", 
        "ansible_machine_id": "S-1-5-21-1882059894-3537946932-3193683812", 
        "ansible_memtotal_mb": 4096, 
        "ansible_nodename": "WIN-PLDULKMKPDS.", 
        "ansible_os_family": "Windows", 
        "ansible_os_name": "Microsoft Windows Server 2012 R2 Datacenter", 
        "ansible_owner_contact": "", 
        "ansible_owner_name": "Windows User", 
        "ansible_powershell_version": 4, 
        "ansible_processor": [
            "GenuineIntel", 
            "Intel(R) Xeon(R) CPU           E7450  @ 2.40GHz", 
            "GenuineIntel", 
            "Intel(R) Xeon(R) CPU           E7450  @ 2.40GHz"
        ], 
        "ansible_processor_cores": 2, 
        "ansible_processor_count": 1, 
        "ansible_processor_threads_per_core": 1, 
        "ansible_processor_vcpus": 2, 
        "ansible_product_name": "Virtual Machine", 
        "ansible_product_serial": "2685-6376-8029-1228-3000-3288-57", 
        "ansible_reboot_pending": false, 
        "ansible_swaptotal_mb": 0, 
        "ansible_system": "Win32NT", 
        "ansible_system_description": "", 
        "ansible_system_vendor": "Microsoft Corporation", 
        "ansible_uptime_seconds": 131, 
        "ansible_user_dir": "C:\\Users\\Administrator", 
        "ansible_user_gecos": "", 
        "ansible_user_id": "Administrator", 
        "ansible_user_sid": "S-1-5-21-1882059894-3537946932-3193683812-500", 
        "ansible_user_uid": 500, 
        "ansible_win_rm_certificate_expires": "2017-06-20 11:28:46", 
        "ansible_windows_domain": "WORKGROUP", 
        "module_setup": true
    }, 
    "changed": false, 
    "invocation": {
        "module_name": "setup"
    }
}

TASK [open check_mk agent port (tcp 6556) in windows firewall] *****************
task path: /home/alexander/Ansible/testing.yml:6
Using module file /home/alexander/Ansible-dev/lib/ansible/modules/extras/windows/win_firewall_rule.ps1
<10.18.50.227> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 5986 TO 10.18.50.227
<10.18.50.227> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1473343561.1-49594745031994").FullName | Write-Host -Separator '';
<10.18.50.227> PUT "/tmp/tmpM6YMhn" TO "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343561.1-49594745031994\win_firewall_rule.ps1"
<10.18.50.227> EXEC Set-StrictMode -Version Latest
Try
{
& 'C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343561.1-49594745031994\win_firewall_rule.ps1'
}
Catch
{
$_obj = @{ failed = $true }
If ($_.Exception.GetType)
{
$_obj.Add('msg', $_.Exception.Message)
}
Else
{
$_obj.Add('msg', $_.ToString())
}
If ($_.InvocationInfo.PositionMessage)
{
$_obj.Add('exception', $_.InvocationInfo.PositionMessage)
}
ElseIf ($_.ScriptStackTrace)
{
$_obj.Add('exception', $_.ScriptStackTrace)
}
Try
{
$_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
Finally { Remove-Item "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343561.1-49594745031994" -Force -Recurse -ErrorAction SilentlyContinue }
changed: [app01] => {
    "changed": true, 
    "difference": [], 
    "failed": false, 
    "fwsettings": {
        "Action": "allow", 
        "Direction": "in", 
        "Enabled": "yes", 
        "LocalIP": "any", 
        "LocalPort": 6556, 
        "Profiles": "any", 
        "Protocol": "tcp", 
        "RemoteIP": "any", 
        "RemotePort": "any", 
        "Rule Name": "check_mk_agent", 
        "Service": "any"
    }, 
    "invocation": {
        "module_name": "win_firewall_rule"
    }, 
    "msg": [
        "No rule could be found", 
        "Created firewall rule check_mk_agent"
    ]
}

TASK [allow ping in windows firewall] ******************************************
task path: /home/alexander/Ansible/testing.yml:16
Using module file /home/alexander/Ansible-dev/lib/ansible/modules/extras/windows/win_firewall_rule.ps1
<10.18.50.227> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 5986 TO 10.18.50.227
<10.18.50.227> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1473343567.55-117769774375936").FullName | Write-Host -Separator '';
<10.18.50.227> PUT "/tmp/tmpcGldOy" TO "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343567.55-117769774375936\win_firewall_rule.ps1"
<10.18.50.227> EXEC Set-StrictMode -Version Latest
Try
{
& 'C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343567.55-117769774375936\win_firewall_rule.ps1'
}
Catch
{
$_obj = @{ failed = $true }
If ($_.Exception.GetType)
{
$_obj.Add('msg', $_.Exception.Message)
}
Else
{
$_obj.Add('msg', $_.ToString())
}
If ($_.InvocationInfo.PositionMessage)
{
$_obj.Add('exception', $_.InvocationInfo.PositionMessage)
}
ElseIf ($_.ScriptStackTrace)
{
$_obj.Add('exception', $_.ScriptStackTrace)
}
Try
{
$_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
Finally { Remove-Item "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343567.55-117769774375936" -Force -Recurse -ErrorAction SilentlyContinue }
fatal: [app01]: FAILED! => {
    "changed": false, 
    "error": "The property 'Service' cannot be found on this object. Verify that the property exists.", 
    "failed": true, 
    "invocation": {
        "module_name": "win_firewall_rule"
    }, 
    "msg": [
        "The rule 'File and Printer Sharing (Echo Request - ICMPv4-In)' exists."
    ]
}
    to retry, use: --limit @testing.retry

PLAY RECAP *********************************************************************
app01                      : ok=2    changed=1    unreachable=0    failed=1   

Second run:

ansible :: ~/Ansible % ansible-playbook -i hosts testing.yml -vvvv
Using /etc/ansible/ansible.cfg as config file
Loading callback plugin default of type stdout, v2.0 from /home/alexander/Ansible-dev/lib/ansible/plugins/callback/__init__.pyc

PLAYBOOK: testing.yml **********************************************************
1 plays in testing.yml

PLAY [testest] *****************************************************************

TASK [setup] *******************************************************************
Using module file /home/alexander/Ansible-dev/lib/ansible/modules/core/windows/setup.ps1
<10.18.50.227> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 5986 TO 10.18.50.227
<10.18.50.227> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1473343614.92-105939556746754").FullName | Write-Host -Separator '';
<10.18.50.227> PUT "/tmp/tmpsst72Y" TO "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343614.92-105939556746754\setup.ps1"
<10.18.50.227> EXEC Set-StrictMode -Version Latest
Try
{
& 'C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343614.92-105939556746754\setup.ps1'
}
Catch
{
$_obj = @{ failed = $true }
If ($_.Exception.GetType)
{
$_obj.Add('msg', $_.Exception.Message)
}
Else
{
$_obj.Add('msg', $_.ToString())
}
If ($_.InvocationInfo.PositionMessage)
{
$_obj.Add('exception', $_.InvocationInfo.PositionMessage)
}
ElseIf ($_.ScriptStackTrace)
{
$_obj.Add('exception', $_.ScriptStackTrace)
}
Try
{
$_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
Finally { Remove-Item "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343614.92-105939556746754" -Force -Recurse -ErrorAction SilentlyContinue }
ok: [app01] => {
    "ansible_facts": {
        "ansible_architecture": "64-bit", 
        "ansible_bios_date": "05-23-2012", 
        "ansible_bios_version": "090006 ", 
        "ansible_date_time": {
            "date": "2016-09-08", 
            "day": "08", 
            "epoch": "1473350820,18939", 
            "hour": "16", 
            "iso8601": "2016-09-08T14:07:00Z", 
            "iso8601_basic": "20160908T160700158138", 
            "iso8601_basic_short": "20160908T160700", 
            "iso8601_micro": "2016-09-08T14:07:00.158138Z", 
            "minute": "07", 
            "month": "09", 
            "second": "00", 
            "time": "16:07:00", 
            "tz": "W. Europe Standard Time", 
            "tz_offset": "+02:00", 
            "weekday": "Thursday", 
            "weekday_number": "4", 
            "weeknumber": "36", 
            "year": "2016"
        }, 
        "ansible_distribution": "Microsoft Windows Server 2012 R2 Datacenter", 
        "ansible_distribution_major_version": "6", 
        "ansible_distribution_version": "6.3.9600.0", 
        "ansible_domain": "", 
        "ansible_env": {
            "ALLUSERSPROFILE": "C:\\ProgramData", 
            "APPDATA": "C:\\Users\\Administrator\\AppData\\Roaming", 
            "COMPUTERNAME": "WIN-PLDULKMKPDS", 
            "ComSpec": "C:\\Windows\\system32\\cmd.exe", 
            "CommonProgramFiles": "C:\\Program Files\\Common Files", 
            "CommonProgramFiles(x86)": "C:\\Program Files (x86)\\Common Files", 
            "CommonProgramW6432": "C:\\Program Files\\Common Files", 
            "FP_NO_HOST_CHECK": "NO", 
            "LOCALAPPDATA": "C:\\Users\\Administrator\\AppData\\Local", 
            "MODULE_COMPLEX_ARGS": "{\"_ansible_version\": \"2.2.0\", \"_ansible_selinux_special_fs\": [\"fuse\", \"nfs\", \"vboxsf\", \"ramfs\"], \"_ansible_no_log\": false, \"gather_timeout\": 10, \"_ansible_module_name\": \"setup\", \"_ansible_verbosity\": 4, \"_ansible_syslog_facility\": \"LOG_USER\", \"gather_subset\": \"all\", \"_ansible_diff\": false, \"_ansible_debug\": false, \"_ansible_check_mode\": false}", 
            "NUMBER_OF_PROCESSORS": "2", 
            "OS": "Windows_NT", 
            "PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL", 
            "PROCESSOR_ARCHITECTURE": "AMD64", 
            "PROCESSOR_IDENTIFIER": "Intel64 Family 6 Model 29 Stepping 1, GenuineIntel", 
            "PROCESSOR_LEVEL": "6", 
            "PROCESSOR_REVISION": "1d01", 
            "PROMPT": "$P$G", 
            "PSExecutionPolicyPreference": "Unrestricted", 
            "PSModulePath": "C:\\Users\\Administrator\\Documents\\WindowsPowerShell\\Modules;C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules", 
            "PUBLIC": "C:\\Users\\Public", 
            "Path": "C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0", 
            "ProgramData": "C:\\ProgramData", 
            "ProgramFiles": "C:\\Program Files", 
            "ProgramFiles(x86)": "C:\\Program Files (x86)", 
            "ProgramW6432": "C:\\Program Files", 
            "SystemDrive": "C:", 
            "SystemRoot": "C:\\Windows", 
            "TEMP": "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp", 
            "TMP": "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp", 
            "USERDOMAIN": "WIN-PLDULKMKPDS", 
            "USERNAME": "Administrator", 
            "USERPROFILE": "C:\\Users\\Administrator", 
            "windir": "C:\\Windows"
        }, 
        "ansible_fqdn": "WIN-PLDULKMKPDS.", 
        "ansible_hostname": "WIN-PLDULKMKPDS", 
        "ansible_interfaces": [
            {
                "default_gateway": "10.18.50.254", 
                "dns_domain": "inet.graz", 
                "interface_index": 12, 
                "interface_name": "Microsoft Hyper-V Network Adapter"
            }, 
            {
                "default_gateway": null, 
                "dns_domain": null, 
                "interface_index": 14, 
                "interface_name": "Microsoft Hyper-V Network Adapter #2"
            }
        ], 
        "ansible_ip_addresses": [
            "10.18.50.227", 
            "169.254.180.170"
        ], 
        "ansible_kernel": "6.3.9600.0", 
        "ansible_lastboot": "2016-09-08 16:03:47Z", 
        "ansible_machine_id": "S-1-5-21-1882059894-3537946932-3193683812", 
        "ansible_memtotal_mb": 4096, 
        "ansible_nodename": "WIN-PLDULKMKPDS.", 
        "ansible_os_family": "Windows", 
        "ansible_os_name": "Microsoft Windows Server 2012 R2 Datacenter", 
        "ansible_owner_contact": "", 
        "ansible_owner_name": "Windows User", 
        "ansible_powershell_version": 4, 
        "ansible_processor": [
            "GenuineIntel", 
            "Intel(R) Xeon(R) CPU           E7450  @ 2.40GHz", 
            "GenuineIntel", 
            "Intel(R) Xeon(R) CPU           E7450  @ 2.40GHz"
        ], 
        "ansible_processor_cores": 2, 
        "ansible_processor_count": 1, 
        "ansible_processor_threads_per_core": 1, 
        "ansible_processor_vcpus": 2, 
        "ansible_product_name": "Virtual Machine", 
        "ansible_product_serial": "2685-6376-8029-1228-3000-3288-57", 
        "ansible_reboot_pending": false, 
        "ansible_swaptotal_mb": 0, 
        "ansible_system": "Win32NT", 
        "ansible_system_description": "", 
        "ansible_system_vendor": "Microsoft Corporation", 
        "ansible_uptime_seconds": 193, 
        "ansible_user_dir": "C:\\Users\\Administrator", 
        "ansible_user_gecos": "", 
        "ansible_user_id": "Administrator", 
        "ansible_user_sid": "S-1-5-21-1882059894-3537946932-3193683812-500", 
        "ansible_user_uid": 500, 
        "ansible_win_rm_certificate_expires": "2017-06-20 11:28:46", 
        "ansible_windows_domain": "WORKGROUP", 
        "module_setup": true
    }, 
    "changed": false, 
    "invocation": {
        "module_name": "setup"
    }
}

TASK [open check_mk agent port (tcp 6556) in windows firewall] *****************
task path: /home/alexander/Ansible/testing.yml:6
Using module file /home/alexander/Ansible-dev/lib/ansible/modules/extras/windows/win_firewall_rule.ps1
<10.18.50.227> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 5986 TO 10.18.50.227
<10.18.50.227> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1473343621.97-27300945517997").FullName | Write-Host -Separator '';
<10.18.50.227> PUT "/tmp/tmpHBHPA_" TO "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343621.97-27300945517997\win_firewall_rule.ps1"
<10.18.50.227> EXEC Set-StrictMode -Version Latest
Try
{
& 'C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343621.97-27300945517997\win_firewall_rule.ps1'
}
Catch
{
$_obj = @{ failed = $true }
If ($_.Exception.GetType)
{
$_obj.Add('msg', $_.Exception.Message)
}
Else
{
$_obj.Add('msg', $_.ToString())
}
If ($_.InvocationInfo.PositionMessage)
{
$_obj.Add('exception', $_.InvocationInfo.PositionMessage)
}
ElseIf ($_.ScriptStackTrace)
{
$_obj.Add('exception', $_.ScriptStackTrace)
}
Try
{
$_obj.Add('error_record', ($_ | ConvertTo-Json | ConvertFrom-Json))
}
Catch
{
}
Echo $_obj | ConvertTo-Json -Compress -Depth 99
Exit 1
}
Finally { Remove-Item "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1473343621.97-27300945517997" -Force -Recurse -ErrorAction SilentlyContinue }
fatal: [app01]: FAILED! => {
    "changed": false, 
    "difference": [
        "any"
    ], 
    "failed": true, 
    "fwsettings": {
        "Action": "allow", 
        "Direction": "in", 
        "Enabled": "yes", 
        "LocalIP": "any", 
        "LocalPort": 6556, 
        "Profiles": "any", 
        "Protocol": "tcp", 
        "RemoteIP": "any", 
        "RemotePort": "any", 
        "Rule Name": "check_mk_agent", 
        "Service": "any"
    }, 
    "invocation": {
        "module_name": "win_firewall_rule"
    }, 
    "msg": [
        "The rule 'check_mk_agent' exists.", 
        "The rule exists but has different values", 
        "There was already a rule check_mk_agent with different values, use force=True to overwrite it"
    ]
}
    to retry, use: --limit @testing.retry

PLAY RECAP *********************************************************************
app01                      : ok=1    changed=0    unreachable=0    failed=1  

@okand okand changed the title from win_firewall_rule to win_firewall_rule fails if rule already exists Sep 8, 2016

@ansibot

This comment has been minimized.

Show comment
Hide comment
@ansibot

ansibot Sep 8, 2016

@TimothyVandenbrande ping, this issue is waiting for your response.
click here for bot help

ansibot commented Sep 8, 2016

@TimothyVandenbrande ping, this issue is waiting for your response.
click here for bot help

@t-v

This comment has been minimized.

Show comment
Hide comment
@t-v

t-v Sep 19, 2016

Contributor

Found a way to fix it again when the rule already existed, now I am still trying to figure out how to do the same with the default ones.
https://github.com/TimothyVandenbrande/ansible-modules-extras/blob/win_firewall_rule/windows/win_firewall_rule.ps1

Contributor

t-v commented Sep 19, 2016

Found a way to fix it again when the rule already existed, now I am still trying to figure out how to do the same with the default ones.
https://github.com/TimothyVandenbrande/ansible-modules-extras/blob/win_firewall_rule/windows/win_firewall_rule.ps1

@ansibot

This comment has been minimized.

Show comment
Hide comment
@ansibot

ansibot Oct 6, 2016

@TimothyVandenbrande, ping. This issue is still waiting on your response.
click here for bot help

ansibot commented Oct 6, 2016

@TimothyVandenbrande, ping. This issue is still waiting on your response.
click here for bot help

@ansibot

This comment has been minimized.

Show comment
Hide comment
@ansibot

ansibot Oct 22, 2016

@TimothyVandenbrande, ping. This issue is still waiting on your response.
click here for bot help

ansibot commented Oct 22, 2016

@TimothyVandenbrande, ping. This issue is still waiting on your response.
click here for bot help

@ansibot

This comment has been minimized.

Show comment
Hide comment
@ansibot

ansibot Nov 6, 2016

@TimothyVandenbrande, ping. This issue is still waiting on your response.
click here for bot help

ansibot commented Nov 6, 2016

@TimothyVandenbrande, ping. This issue is still waiting on your response.
click here for bot help

@ansibot

This comment has been minimized.

Show comment
Hide comment
@ansibot

ansibot Nov 22, 2016

@TimothyVandenbrande, ping. This issue is still waiting on your response.
click here for bot help

ansibot commented Nov 22, 2016

@TimothyVandenbrande, ping. This issue is still waiting on your response.
click here for bot help

@ansibot

This comment has been minimized.

Show comment
Hide comment
@ansibot

ansibot Dec 7, 2016

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

ansibot commented Dec 7, 2016

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

@dagwieers

This comment has been minimized.

Show comment
Hide comment
@dagwieers

dagwieers May 13, 2017

Member

@okand Can you please test if this issue is still present using PR ansible/ansible#23162. If not, please move this issue to https://github.com/ansible/ansible instead. Thanks !

Member

dagwieers commented May 13, 2017

@okand Can you please test if this issue is still present using PR ansible/ansible#23162. If not, please move this issue to https://github.com/ansible/ansible instead. Thanks !

@okand

This comment has been minimized.

Show comment
Hide comment
@okand

okand May 17, 2017

Sorry for the delay, I've been offline for a couple of weeks.

I don't have access to an environment to test this in anymore unfortunately but thanks anyway 😅

okand commented May 17, 2017

Sorry for the delay, I've been offline for a couple of weeks.

I don't have access to an environment to test this in anymore unfortunately but thanks anyway 😅

@dagwieers

This comment has been minimized.

Show comment
Hide comment
@dagwieers

dagwieers May 17, 2017

Member

@okand No problem. Can you please close this ticket ?

Member

dagwieers commented May 17, 2017

@okand No problem. Can you please close this ticket ?

@okand okand closed this May 17, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.