Giter Site home page Giter Site logo

xml_fragment's People

Contributors

alexjfisher avatar areson avatar silug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xml_fragment's Issues

Package new release for Puppet Forge

There have been several pull requests, so it's time to package a new release. This is a reminder to test, package, and deploy a new version of the module.

Unwanted attributes not removed

Consider this XML file

<settings>                                                                                                                                                                                                                                   
  <setting name="foo" unwanted_attribute="bar">baz</setting>
</settings>

and this puppet code

xml_fragment { 'test':
  path    => 'test.xml',
  xpath   => '/settings/setting[@name=\'foo\']',
  content => {
    value      => 'baz',
    attributes => {
      'name' => 'foo',
    },
  },
}

I would expect the puppet to remove unwanted_attribute, but this doesn't happen.

Attributes are not added to node if it already exists but has no attributes

I was trying to use this to edit some xml based config files, but I ran into an issue: consider the following xml file somefile.xml

<config>
  <setting>
</config>

And the following manifest

xml_fragment { 'set setting.value to 1` :
  ensure => 'present'
  path => 'somefile.xml',
  xpath => '/config/setting',
  content => {
    attributes => {
      value => 1
    }
  }

Will result in an unchanged somefile.xml, however if the somefile.xml file was instead:

<config>
  <setting value=2>
</config>

You would instead end up with

<config>
  <setting value=1>
</config>

This is of course a simplified example, but it causes bugs when you try to use this to edit IIS config files, which use the convention of having attributes represent leaf settings that can be assigned values and the absence of a given attribute means that the setting the attribute represents takes its default value.

Unable to insert xml node if it already exists in xpath

Given the following XML

  <filter>
    <filter-name>wsfilter</filter-name>
    <filter-class>com.peoplesoft.pt.events.WSFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>
  <filter-mapping>
    <filter-name>wsfilter</filter-name>
    <url-pattern>/ws/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>wsfilter</filter-name>
    <url-pattern>/aws/*</url-pattern>
  </filter-mapping>

I want to modify the xml to be

<filter>
    <filter-name>PortalServletFilter</filter-name>
    <filter-class>com.peoplesoft.pt.custom.filter.PortalServletFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>
  <filter-mapping>
    <filter-name>PortalServletFilter</filter-name>
    <url-pattern>/psp/*</url-pattern>
    <url-pattern>/psc/*</url-pattern>
    <url-pattern>/cs/*</url-pattern>
  </filter-mapping>
  <filter>
    <filter-name>wsfilter</filter-name>
    <filter-class>com.peoplesoft.pt.events.WSFilter</filter-class>
    <async-supported>true</async-supported>
  </filter>
  <filter-mapping>
    <filter-name>wsfilter</filter-name>
    <url-pattern>/ws/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>wsfilter</filter-name>
    <url-pattern>/aws/*</url-pattern>
  </filter-mapping>

When attempting to do this, xml_fragment will use the given xpath and append to it rather than create a new entry.

Would it be possible to add a way to tell xml_fragment to create a new node even if it exists?

When using `purge` file is overwritten on every puppet run

I've noticed that my xml file is being overwritten (with no changes) on every puppet run. This has a side-effect of causing my application server (mono aspnet in this case) to restart the application every 30 minutes.
I think it is purge_tags that is always calling save.

Duplicates, then newer versions fail

We've been using version 1.0.2, which looks like commit 898890e, for a while now to add xml code to a Newrelic config file. The problem: while the readme file says:

The default behavior of the xml_fragment resource is to create or update the tag indicated by the xpath parameter. If the tag does not exist it will be created. If it exists the value and attributes of the tag will be updated if needed.

What I'm seeing is that the entire set of entries is added to what's already in the area that's being managed by puppet every time a puppet run is done. The servers in question have about 30 entries to be added. If I start from blank in the managed section, the first run will put the 30 entries in. On the second run, 30 more entries are added, and there are now two copies of each entry in that section now. On the third run, 30 more are added so that now there are 90 lines and 3 of each entry. Etc.

I tried to move to a newer commit to see if maybe this issue had been fixed. Commit 7db084f doesn't have a problem. But starting with commit ba835df, puppet runs fail with

Error: /Stage[main]/Newrelic::Dotnet_apm/Xml_fragment[NewRelic APM LicenseKey]: Could not evaluate: undefined method key?' for nil:NilClass Error: /Stage[main]/Newrelic::Dotnet_apm/Xml_fragment[NewRelic APM App Name]: Could not evaluate: undefined method key?' for nil:NilClass

None of the Puppet manifests that call xml_fragment have changed any of the parameters, and it looks from the readme file that there are no new requirements for calling this type.

I can provide more specific code if someone has some ideas. But again: the only thing I'm changing is the commit of xml_fragment. Everything else is the same.

Parser Syntax Error

I am attempting to set up a text of this module, with the intention to modify the machine.config XML file used for .NET Framework configuration. Here is the code in my init.pp:

  xml_fragment { 'Framework64 v4':
    path    => 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config',
    ensure  => 'present',
    xpath   => '/configuration/system.web/machineKey',
    content => {
      attributes {
        'validationKey' => '1234',
        'decryptionKey' => '5678',
        'validation'    => 'AES',
        'decryption'    => 'AES',
      }
    }
  }

However, when I run the parser validation I get the following:

puppet parser validate modules/abp_app/manifests/init.pp
Error: Could not parse for environment production: Syntax error at '=>' at /etc/puppetlabs/code/environments/production/modules/abp_app/manifests/init.pp:29:25

This line correlates to the first line that has an attribute; in this example the one that has 'validationKey'. What am I missing?

Doc error, plus problems with getting xpath spec to work

The documentation is missing a "fat comma" in describing the use of the attributes clause:

xml_fragment { "Localhost Host":
path => "C:/hosts.xml",
ensure => 'present',
xpath => "/hosts/host[@ip='127.0.0.1']",
content => {
value => "Localhost",
attributes {
"ip" => "127.0.0.1"
}
}
}

It should be "attributes => { settings }

I'm also having trouble with the xpath spec. I'm working with the IIS applicationHost.config. In http://www.freeformatter.com/xpath-tester.html, using configuration/system.webServer/proxy takes me exactly where I want to go as I want to change one of the attributes in the proxy element.

But when I use that in Puppet, I get errors. The latest iteration of the clause I'm using is:

xml_fragment { "ReverseProxySettings":
path => "c:\windows\system32\inetsvc\config\applicationHost.config",
xpath => "/configuration/system.Webserver/proxy[@reverseRewriteHostInResponseHeaders='true']",
content => {
value => 'proxy',
attributes => {
"reverseRewriteHostInResponseHeaders" => "false"
}
}
}

But when I try to run a pass with puppet agent, I get the below error, a claim that no parents were found for /configuration/system.Webserver.

Notice: Xpath: /configuration/system.Webserver
Error: Could not set 'present' on ensure: Unable to set . No parents found for the xpath /configuration/system.Webserver at 49:/etc/puppetlabs/code/environments/omnireverserewrite/modules/core/manifests/web_app/omni.pp
Error: Could not set 'present' on ensure: Unable to set . No parents found for the xpath /configuration/system.Webserver at 49:/etc/puppetlabs/code/environments/omnireverserewrite/modules/core/manifests/web_app/omni.pp
Wrapped exception:
Unable to set . No parents found for the xpath /configuration/system.Webs
erver
Error: /Stage[main]/Core::Web_app::Omni/Xml_fragment[ReverseProxySettings]/ensure: change from absent to present failed: Could not set 'present' on ensure: Unable to set . No parents found for the xpath /configuration/system.Webserver at 49:/etc/puppetlabs/code/environments/omnireverserewrite/modules/core/manifests/web_app/omni.pp

XML Quoting Request

Would it be possible to create an additional param to change to double quotes from single? I have seen there is a property for this on the XML document object in the gem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.