I have defined a config file in my puppet manifest and I need to use an .erb template so I can load in dynamic parameters.
The problem is however that the application insists on changing a couple of lines in that file prior to puppet running. Such lines cannot be easily discovered and put into the template (for example, a build number that increments). If I tell puppet to refresh the service when the config file changes, then every puppet run I have my service being restarted, which isn't good.
Is there any way that I could use an .erb template with Puppet but tell it not to care if specific lines in it change? I'm not sure if this is possible or even if it's going to work, but it would be good to know.
Cheers
You can use either a file_line resource from stdlib module or an augeas lens to instruct puppet about what lines do you want at the config file. Those lines will be puppet managed, and rest of file will rest unchanged.
If you don't like file_line or augeas (one is a bit of a hack and the other difficult to figure out), you might have to create a custom fact to inform the master of the current state of the file. The master could then apply logic to update that content only if necessary.
Granted, that's not much more intuitive or maintainable than the aforementioned methods.
Related
I have two questions about cucumber frame work.
1-My .features files are not converting into feature format and showing as plan text file even though it works fine and I can run my TestRunner.
2- I have saved my all TestRunner files into a package Runner but in TestRunner file I have to give full path of my feature file in order to run TestRunner. e.g features= "Features" not working but
features="C:\Users\FourStar1\eclipse-workspace\com.freeTourTest\src\main\java\Features2\Addusers.feature"
works.
Take a careful look at the casing of your directory and package names. It's important you are consistent with these. It makes it easier to spot mistakes. Using lowercase is recommended.
Additionally tests and test resources should be put under src/test/java and src/test/resources respectively. Feature files are resources and will not be copied over target if you put them under java.
I would suggest learning the maven project layout by heart. It makes everything easier then making up your own organization.
I am trying to maintain a nonstandard hosts location using puppet's hosts resource type. Since it is nonstandard hosts file its content is not "prefetched" by puppet and then it is not possible to do something like purging entries.
In order to workaround the issue I want to remove the file before puppet is applying any changes to that file. However, I don't want to remove the file every time puppet is running but rather only if there is something to be changed. Is there a way to apply configurations for the resource only if there is going to change anything ?
Right now, I define hosts via hiera and use create_resources function to produce the desired hosts resources.
create_resources(host,$host_entries)
To make sure that there are not any other entries, my most simple idea is to make sure file doesnt exist, right before applying the host configuration:
file { '/nonstandard/hosts':
ensure => absent,
}
By doing so the hosts will be always removed, even if there is nothing to change. As it will be in 99 percent of the cases.
So what options I have to remove the file only in case of create_resources(host,$host_entries) will really bring something new.
Maybe there is a different and more simple approach ?
Is there a way to apply configurations for the resource only if there is going to change anything ?
Not in a general sense. What you could do instead is write a custom fact that provides a list of the hosts defined by your custom hosts file (only the hostnames are needed), and based on the value of that fact and your hiera data, generate Host resources to ensure absent those hosts for which you do not have definitions. That does, however, assume that all of the hosts that should be listed in the file are known to you from Hiera data.
Instead create multiple feature files is it possible to have just one feature file and another file where I can call different sequence of cucumber tags like:
#step1, #step2
#step1, #step2, #step3
#step1, #step2, #step3, #step4
So that I can just run this file from RubyMine?
Thanks
Of course you can put all the scenarios for a project in one file.
But is it something that you want to do?
Remember, Cucumber is a BDD tool designed to bridge conversive issues between the development team and the business people. Separating each feature into a new file means that the business can pull out an individual feature and view it when it is done, to understand why it is there in terms of business value, and when it needs improving it's easy to add to/edit the existing scenarios.
Having them in the same file may make it easier for you, but when something fails, it'll be harder to find the issue when you have to scroll down a 10,000 line long file.
Instead, improve your folder structure so that features are easier to find, and tag features and scenarios across the files. Create a bash script to run suites if you want to, or just use the command line: "cucumber --tags #tag1" for instance.
Due to the buggy nature of InstallShield, it is incorrectly modifying my app.config files replacing <clear /> with <clear></clear>
After my app.config file is copied to install path, I want to run a custom action that can scan for all config files and do a standard find and replace.
I don't need code for the find and replace, what I want to know is how / where to put this custom action using Installshield?
Your best bet would be creating a deferred execution custom action and place it near the end of the execution sequence. This will guarantee it would run after the files have been installed.
In the 'Custom Actions and Sequences', Create a new custom action of the appropriate type (depending on your implementation of this replacement action). Set it's In-Script Execution to 'Deferred' and in the Sequence section have add it to the Install Exec Sequence, After ScheduleReboot.
The easiest way to modify config/ini files after deployment of files is the option of INI File Changes or Text File Changes under the System Configuration tab. You can mention the config file location and the replacement changes that you want to perform. Please refer this link.
I've worked through the "Integrating Data" guide on the Spring website and have been trying to determine how to use configuration settings (substitution) in the integration.xml file rather than hard code various items. This is primarily driven by a desire to externalise some of the configuration from the XML and take advantage of Spring Boot's ability to allow for externalised configuration.
I've been trying to determine the solution for a while now and thought it's likely to be an easy answer (for those who know how).
In the snippet below (taken from the guide) I've used ${outputDir} as a placeholder for a configuration item I'll pass into the application:
<file:outbound-channel-adapter id="files"
mode="APPEND"
charset="UTF-8"
directory="${outputDir}"
filename-generator-expression="'HelloWorld'"/>
Essentially, I'm trying to determine what I need to do to get the ${outputDir} substitution working.
As part of working through the problem I reduced the code down to a demo that I've uploaded to BitBucket:
integration.xml will just copy files from a file:inbound-channel-adapter directory to a file:outbound-channel-adapterdirectory
The Application class uses Spring Boot to load the configuration into a DemoIntegration instance and it's the fields in that instance that I'd like to substitute into integration.xml at runtime.
Unless I'm mistaken (when I get this to work) I should be able to override the inputDir and outputDir items in integration.xml.
Your integration.xml references ${inputDir}, which is not there.
Just to make it work with the existing config, add/change the application.properties file in your classpath with inputDir=/tmp/in and outputDir. This way it matches with your used vars in the config file.
If you want to stick with your naming, then change the XML to use ${demo.inputDir}. These are the names you are using in your existing application.properties.
And if you want to stick to your #ConfigurationProperties, then you can put #{demoConfigration.inputDir} in the XML to access the bean, where your config is stored. Note, that your code currently fails (at least for me) as you basically define the bean twice (once per #EnableConfigurationProperties and once by #ComponentScan+#Component on the config.