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

Add quote_char parameter to the ini_subsetting resource type #95

Merged
merged 2 commits into from
May 16, 2014
Merged

Add quote_char parameter to the ini_subsetting resource type #95

merged 2 commits into from
May 16, 2014

Conversation

mruzicka
Copy link
Contributor

@mruzicka mruzicka commented May 7, 2014

The quote_char is used to quote the entire setting when it is modified as a result of changes to some subsettings.

For an example let's assume we have a setting of this form:

JAVA_ARGS=-Xmx256m

and we want to add the -Xms parameter to the setting, for that purpose we define a resource like this:

  ini_subsetting { '-Xms':
    ensure     => present,
    path       => '/some/config/file',
    section    => '',
    setting    => 'JAVA_ARGS',
    subsetting => '-Xms'
    value      => '256m',
  }

which results into the following setting:

JAVA_ARGS=-Xmx256m -Xms256m

But this is not what we intended - if this setting is read by the bash shell the -Xms256m parameter is interpreted as a command to be executed rather than a value to be assigned to the JAVA_ARGS variable.

To fix this problem the quote_char parameter was added to the ini_subsetting resource type, and we'll take advantage of it to fix the problem in the above example like so:

  ini_subsetting { '-Xms':
    ensure     => present,
    path       => '/some/config/file',
    section    => '',
    setting    => 'JAVA_ARGS',
    quote_char => '"',
    subsetting => '-Xms'
    value      => '256m',
  }

which will result into:

JAVA_ARGS="-Xmx256m -Xms256m"

which is what we intended.

The quote_char is used to quote the entire setting when it is modified
as a result of changes to some subsettings.

For an example let's assume we have a setting of this form:
  JAVA_ARGS=-Xmx256m
and we want to add the '-Xms' parameter to the setting, for that purpose
we define a resource like this:
  ini_subsetting { '-Xms':
    ensure     => present,
    path       => '/some/config/file',
    section    => '',
    setting    => 'JAVA_ARGS',
    subsetting => '-Xms'
    value      => '256m',
  }
which results into the following setting:
  JAVA_ARGS=-Xmx256m -Xms256m
But this is not what we intended - if this setting is read by the bash
shell the '-Xms256m' parameter is interpreted as a command to be
executed rather than a value to be assigned to the JAVA_ARGS variable.

To fix this problem the quote_char parameter was added to the
ini_subsetting resource type, and we'll take advantage of it to fix the
problem in the above example like so:
  ini_subsetting { '-Xms':
    ensure     => present,
    path       => '/some/config/file',
    section    => '',
    setting    => 'JAVA_ARGS',
    quote_char => '"',
    subsetting => '-Xms'
    value      => '256m',
  }
which will result into:
  JAVA_ARGS="-Xmx256m -Xms256m"
which is what we intended.
@@ -48,6 +48,18 @@
end
end

newparam(:quote_char) do
desc 'The character used to quote the entire value of the setting. ' +
%q{Vaild vaules are '', '"' and "'". Defaults to ''.}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of typoes at the start, Valid values

apenney pushed a commit that referenced this pull request May 16, 2014
…ter-for-subsetting

Add quote_char parameter to the ini_subsetting resource type
@apenney apenney merged commit d4a2b22 into puppetlabs:master May 16, 2014
cegeka-jenkins pushed a commit to cegeka/puppet-inifile that referenced this pull request Oct 23, 2017
…har-parameter-for-subsetting

Add quote_char parameter to the ini_subsetting resource type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants