Skip to content
This repository was archived by the owner on Feb 24, 2021. It is now read-only.
This repository was archived by the owner on Feb 24, 2021. It is now read-only.

[New Resource] FileContentDsc #155

Closed

Description

A DSC resource for modifying XML files (elements, attributes, nodes etc) would be very useful. I know cXML is available but the project is stagnant and is fairly bare bones with no unit tests and practically no documentation.

Besides, the company I prefers not to use DSC resources that are maintained outside the DSC PowerShell team (e.g. 'c' resources).

If I have time I'll implement this - unless someone already has something they'd be able to bring into the DSC PowerShell team resources.

Activity

  1. ArieHein commented on Jul 19, 2016

    @ArieHein

    On a similar note I would go for a much broader Resource for JSON and INI files as well.
    There are some XML Powershell repos that are interesting like https://github.com/Jaykul/Xml
    I liked the Idea of a DSL for XML but that might be offtopic.

  2. PlagueHO commented on Jul 19, 2016

    @PlagueHO
    ContributorAuthor

    Definitely agree there. It seems like some generic text file content manipulation resources are needed.

    I'd say at least the following would be extremely useful:

    • XML
    • JSON
    • INI
    • Generic Regex/Replace

    If anyone out there already has created these resources and would like to submit them to the community but need help getting them up to minimum standards (unit tests, examples, style etc), I'm happy to help.

    Otherwise I'll add them to my list of resources I need to create when I have time 😄

  3. ArieHein commented on Jul 20, 2016

    @ArieHein

    question is, do you want it as a DSC resource or simply a PowerShell module.

    Do you want to make sure a Node configuration changes just because one INI entry doesn't match ?
    I can see valid usages but at the same time see it used wrongly on so many other ways.

    Something to ponder about ;)

  4. KarolKaczmarek commented on Jul 20, 2016

    @KarolKaczmarek
    Contributor

    Good point Arie Heinrich (@ArieHein), but one doesn't necessarily contradict another. One way to do it is to implement a PS module for operations mentioned above, publish it to PS Gallery, then use it in the implementation of the resource module itself by listing it as a dependency.

    That being said, PowerShell has access to e.g. System.Xml.XmlDocument for XML operations, so not sure how much value we can really add in the new module, but as you said that's one thing to consider - I'll leave it up to the author.

  5. added
    new module submission
    on Jul 20, 2016
  6. PlagueHO commented on Jul 21, 2016

    @PlagueHO
    ContributorAuthor

    Arie Heinrich (@ArieHein) - while I'm definitely a fan of encapsulating functionality into a modules (which can then be distributed via PS Gallery), in this case it would cause some problems:

    • It would require WMF5 or PS PackageManagement to be installed and available on all DSC nodes - many companies are not quite at this point yet (despite how much I wish they were 😄 )
    • It would require access to the PS Gallery from the target node or the module to be copied onto the target node during initial deployment - which in some cases isn't possible.
    • As Karol Kaczmarek (@KarolKaczmarek) says, we are just obfuscating functionality that is provided by the .NET System.XML classes (although I'll concede that System.XML can be a bit fiddly to use sometimes and wrapping it would be nice).

    I think this approach would probably cause more problems than it solves.

    Just my 2c!

  7. added and removed
    new module submission
    on Jul 21, 2016
  8. IngoGege commented on Aug 12, 2016

    @IngoGege

    Arie Heinrich (@ArieHein) I was going to request that my resource is added to DscResources. What do you think?

  9. ArieHein commented on Aug 12, 2016

    @ArieHein

    Thumbs up for that. Think Daniel Scott-Raynsford (@PlagueHO) started something as well. Team up as he has experience in how to build and setup the repo for all the checks and tests needed prior to moving the repo to MS hands. Perhaps some of the ideas mentioned here for ini and json and rest might be incorporated into a general TextStream Manipulation framework ;)

  10. IngoGege commented on Aug 12, 2016

    @IngoGege

    Arie Heinrich (@ArieHein) sounds good, but to get all the different types into one resource would be a huge effort. Wouldn't it be better to have them seperated. My resource is based on .NET functionality and looking only at XML...as Daniel Scott-Raynsford (@PlagueHO) mentioned it can be a bit fiddly to use (case-sensitivity).

  11. PlagueHO commented on Aug 13, 2016

    @PlagueHO
    ContributorAuthor

    Hi Arie Heinrich (@ArieHein), IngoGege - I'm all for including your resource (the more we existing stuff we use the better)!

    I'd definitely in agreement - we don't want to put all the functionality in one resource, but I'm thinking 3 resources in one resource module. E.g.:

    ConfigFileDsc - containing the following resources:
    MSFT_XMLConfig
    MSFT_JSONConfig
    MSFT_INIConfig

    The tricky part is getting a resource up to the requirements for getting it included in the MSFT Community Resource kit - that said, I'm definitely up for helping out on that one. I could start submitting some PRs with the tests into your repo if you like? I've got a few of my own resources that I'm working on getting included at the moment, but after that I'll have some more time.

  12. IngoGege commented on Aug 13, 2016

    @IngoGege

    Hi Daniel Scott-Raynsford (@PlagueHO) , Arie Heinrich (@ArieHein) ,
    I think this would be the best solution and I would be more than happy to get some PRs. How about a modules gets generated in the community and we just add the existing code as resources. I think this would make the most sense, or?
    Daniel Scott-Raynsford (@PlagueHO) : No rush!J

  13. PlagueHO commented on Sep 20, 2016

    @PlagueHO
    ContributorAuthor

    I'm thinking about working on these resources if I have the time. At the moment I'm just trying to throw out ideas so don't take anything I'm saying as "the right way to do it". Just looking for discussion at this point.

    What I was thinking was creating a new HQRM resource module called:
    ConfigFileDsc (or something along those lines).

    It could contain (with potential for more) the following WMF4 (non class based) HQRM resources:
    MSFT_XMLConfigDsc - for working with XML configs (IngoGege - would your resource fit the bill here? Would you want to have it submitted to the resource kit?)
    MSFT_JSONConfigDsc - for working with JSON files (this might be more difficult as it would really need an XPATH type query language for specifying nodes).
    MSFT_INIConfigDsc - for adding/removing INI settings.
    MSFT_StringConfigDsc - for using RegEx expressions for ensuring specific patterns are replaced with different text (this could handle other types of Config not specifically covered by the XML, JSON and INI).

    The above resources are just a rough guess off the top of my head and are likely to change.

    I have a need for these resources myself (for our workloads at IAG), but it would be useful to know if anyone else has requirements, suggestions etc.

    So, just wanted to kick off the conversation.

  14. 12 remaining items

  15. changed the title [-][New Resource] ConfigFileDsc[/-] [+][New Resource] FileContentDsc[/+] on Nov 25, 2016
  16. PlagueHO commented on Nov 25, 2016

    @PlagueHO
    ContributorAuthor

    Arie Heinrich (@ArieHein) - so a better name might be FileContentDsc?

    Agreed, the Regex replace pattern could be used across many scenarios, which is one of the reasons I am starting with it. The other reason being that we need to deploy some Java workloads and they have a crazy mishmash of config file types with some that I don't even think have names (I'm sure every framework/app vendor makes up a brand new config file style every time). So the Regex one will at least allow me to configure these for now.

    Plus, I'm going to include the ability to pass PSCredential objects across so that the values can be covered with MOF Encrpytion. This is because we often have to set things like Java Key Store passwords in config files (yep - in plain text - sigh).

  17. PlagueHO commented on Jun 17, 2017

    @PlagueHO
    ContributorAuthor

    This is now in progress: https://github.com/PlagueHO/FileContentDsc

    Mariah (@mbreakey3) - are you able to tag this as in progress?

    I aim to have the first 3 HQRM resources (ReplaceText, KeyValuePair and IniSettings) completed in the next week. JSON and XML will follow soon after with the possibility of YML as well. I won't release this to the PS Gallery, but will submit it for inclusion in the Resource Kit instead.

  18. PlagueHO commented on Jun 18, 2017

    @PlagueHO
    ContributorAuthor

    I've completed the first three resources in this module now. Working on XML, YML and JSON over the next few weeks.

    They should meet HQRM standards (full integration test suite, 99% unit test coverage) and also contain Wiki generated using the auto-documentation method.

    However, I have not released these to the PSGallery because I plan to submit this to the resource kit, so all the documentation is configured as if it is included. This is because reworking a module to get it included in the resource kit takes effort, so I thought I'd just save the time and just put it together as if I was already undergoing the submission process.

    The problem though is that modules do take a little while ( 😁 ) to be added to the resource kit. And if I release this module myself to the PSGallery, it will need to be renamed if it is released as part of the resource kit. Renaming a module is a lot of work for the maintainer and for any consumers of the resource module - so it would be good to avoid it.

    Zachary Alexander (@zjalexander) - what are your thoughts here? Should I just release this myself or hold out to get this added to the resource kit? I know there is a backlog of stuff to go in and the DSC team don't have the resource to review them, so do you have any advice?

    I do plan on adding additional modules (XML, JSON, YML) to this repo over the next few weeks, so even if it was accepted in the resource kit I'd likely be still adding to it.

  19. added
    in progress
    on Jun 19, 2017
  20. PlagueHO commented on Jun 30, 2017

    @PlagueHO
    ContributorAuthor

    I have one more resource I'd like to add to this module as well: a Text file templating resource.
    One of the needs our teams have is to take text based template config files out of a source repo (via HTTPS) and them merge some values into it.

    For example, we could have a file like this in our config repo:

    {
      "connectionstring": "{{value1}}",
      "somesetting": "{{value2}}",
    
      "machine": {
        "option3": "{{value3}}"
      }
    }

    We could then have resource called TextTemplateFile that looked like this (property names not final):

    TextTemplateFile myConfig {
        File = 'https:\\myconfigs\myapp\appsettingstemplate.json'
        Dest = 'c:\myapp\appsettings.json'
        Values = @(
            'This is my database connection string',
            'and somesetting',
            'and value3'
        )
    }

    The only problem with this is that the template has been copied and the values merged into it, it will be considered in state from ever after - even if the source template changes. So I'm not sure if this is that useful. I will still be completing the JSON repo which would handle this scenario.
    Does anyone have any thoughts on if this is useful or not?

  21. ArieHein commented on Jun 30, 2017

    @ArieHein

    There is a concept called Tokenization, when dealing with say a Release pipeline.
    You place a web.config for a website that instead of values has similar template as your template but where the values are replaces with Property
    and then in the pipeline process you have a step that searches for any Property and replaces I according to the environment your deploying to.

    Thus you have only one web.config in your code and the values for various fields are controlled outside of the repo once the website is released and deployed.

    There used to be a xTokeniztion in the old TFS Release Management, before it was embedded into the TFS itself.

    I Just consider your template idea as a special case of a single key-value translation. Doesn't the current state of the resource allows you to get to the same results without the template resource ?
    I can see this template resource used as its own resource and not specifically as part of the current one and based on a function library on the gallery, like Karol Kaczmarek (@KarolKaczmarek) noted in one of the earlier comments.

  22. PlagueHO commented on Sep 2, 2017

    @PlagueHO
    ContributorAuthor

    Hi Arie Heinrich (@ArieHein) - sorry I missed your comment here (too much going on at the same time). Thinking about your idea, it definitely could be really awesome. Definitely something I'd be keen on adding. So I'll get onto it 😁

  23. johlju commented on Apr 17, 2018

    @johlju
    Contributor

    Daniel Scott-Raynsford (@PlagueHO) the resource in https://github.com/PlagueHO/FileContentDsc seems like a good candidate to make a submission to DSC Resource Kit? Either way, maybe we should move any outstanding enhancement from this issue to new issues in that repo instead?

  24. PlagueHO commented on Apr 17, 2018

    @PlagueHO
    ContributorAuthor

    HI Johan Ljunggren (@johlju) - oh yes, I was meaning to submit all my other resources: FSRMDsc, WSManDsc, FileContentDsc, iSCSIDsc

    After the Azure Global Bootcamp is done this weekend I'll get some work done to submit these for inclusion. Thanks for the reminder!

  25. johlju commented on Apr 17, 2018

    @johlju
    Contributor

    Sounds good. 😄

    Wish you very much good luck with hosting the Azure Global Bootcamp, bet it will be fun and your attendees will learn a lot!

  26. johlju commented on May 30, 2018

    @johlju
    Contributor

    Daniel Scott-Raynsford (@PlagueHO) Can we close this one now?

  27. PlagueHO commented on May 30, 2018

    @PlagueHO
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions