Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iis_site :config action not idempotent (Windows 2012 R2/IIS 8.5) #249

Closed
stuartpreston opened this issue Feb 18, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@stuartpreston
Copy link
Contributor

commented Feb 18, 2016

Looking at https://github.com/chef-cookbooks/iis/blob/master/providers/site.rb#L143-L145 where the output from appcmd is inspected, idempotency cannot be achieved:

    is_new_log_directory = new_or_empty_value?(doc.root, 'SITE/logFiles/@directory', new_resource.log_directory.to_s)
    is_new_log_period = new_or_empty_value?(doc.root, 'SITE/logFile/@period', new_resource.log_period.to_s)
    is_new_log_trunc = new_or_empty_value?(doc.root, 'SITE/logFiles/@truncateSize', new_resource.log_truncsize.to_s)

All three of these always return true - this is because the xpath is wrong (there are two <site> elements and the logFile element is called logFile, not logFiles, as shown in the following output:

PS C:\windows\system32\inetsrv> .\appcmd list site "MyWebSite" /xml /config:*

returns the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<appcmd>
    <SITE SITE.NAME="MyWebSite" SITE.ID="1" bindings="http/*:80:,https/*:443:" state="Started">
        <site name="MyWebSite" id="1" serverAutoStart="true">
[...]
            <logFile logExtFileFlags="Date, Time, ClientIP, UserName, ServerIP, Method, UriStem, UriQuery, HttpStatus, Win32Status, TimeTaken, ServerPort, UserAgent, Referer, HttpSubStatus" customLogPluginClsid="" logFormat="W3C" logTargetW3C="File" directory="C:\inetpub\logs\LogFiles" period="Daily" truncateSize="1048576" localTimeRollover="false" enabled="true" logSiteId="true" flushByEntryCountW3CLog="0" maxLogLineLength="65536">
                <customFields maxCustomFieldLength="4096">
                </customFields>
            </logFile>
[...]
        </site>
    </SITE>

Therefore I believe the corrections to be as follows:

    is_new_log_directory = new_or_empty_value?(doc.root, 'SITE/site/logFile/@directory', new_resource.log_directory.to_s)
    is_new_log_period = new_or_empty_value?(doc.root, 'SITE/site/logFile/@period', new_resource.log_period.to_s)
    is_new_log_trunc = new_or_empty_value?(doc.root, 'SITE/site/logFile/@truncateSize', new_resource.log_truncsize.to_s)

When I get time I'll try and look into a PR for fixing this unless I'm wrong and someone knows why the current code is there?

@EasyAsABC123

This comment has been minimized.

Copy link
Collaborator

commented Feb 19, 2016

Good catch! I never used the feature so I wouldn't know if that is correct. Looks like the right fix, do some testing and I'd love a PR

Justin Schuhmann

On Feb 18, 2016, at 6:34 PM, Stuart Preston notifications@github.com wrote:

Looking at https://github.com/chef-cookbooks/iis/blob/master/providers/site.rb#L143-L145 where the output from appcmd is inspected, idempotency cannot be achieved:

is_new_log_directory = new_or_empty_value?(doc.root, 'SITE/logFiles/@directory', new_resource.log_directory.to_s)
is_new_log_period = new_or_empty_value?(doc.root, 'SITE/logFile/@period', new_resource.log_period.to_s)
is_new_log_trunc = new_or_empty_value?(doc.root, 'SITE/logFiles/@truncateSize', new_resource.log_truncsize.to_s)

All three of these always return true - this is because the xpath is wrong (there are two elements and the logFile element is called logFile, not logFiles, as shown in the following output:

PS C:\windows\system32\inetsrv> .\appcmd list site "MyWebSite" /xml /config:*

returns the following XML:

[...] [...] Therefore I believe the corrections to be as follows:
is_new_log_directory = new_or_empty_value?(doc.root, 'SITE**/site/logFile**/@directory', new_resource.log_directory.to_s)
is_new_log_period = new_or_empty_value?(doc.root, 'SITE**/site/logFile**/@period', new_resource.log_period.to_s)
is_new_log_trunc = new_or_empty_value?(doc.root, 'SITE**/site/logFile**/@truncateSize', new_resource.log_truncsize.to_s)

When I get time I'll try and look into a PR for fixing this unless I'm wrong and someone knows why the current code is there?


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.