[rudder-users] IPv4 on promise
Nicolas Charles
nicolas.charles at normation.com
Tue Sep 16 19:34:35 CEST 2014
On 14/09/2014 09:15, Maxime Longuet wrote:
> Hy,
>
> I've a problem with enforce content file. I want use sys.ipv4 cfengine variable in content.
>
> But we have a bug on VPS openvz, it doesn't work on cfengine 3.6 (issue has push to 3.7)
>
> Issue : https://github.com/cfengine/core/pull/1819/files
>
> Then i says, ok i'm push env variable with IP on my agent
>
> IP_MASTER='XXX.XXX.XXX.XXX'
>
> And when i'm search, i dont find how i can use env variable in my technique :(
>
>
> If anyone has suggestion ...
>
>
> Maxime
>
Hi Maxime,
Currently, there is no solution for having environnement variable
techniques. In next version of rudder, you'll be able tu use the
variable ${rudder.node.env.IP_MASTER} to use the environment variable
IP_MASTER. The data will be fetched from the inventories, and based on
the information available at the promise generation time.
I can offer you a solution at the current time, based on a Technique,
and a file to deploy.
Attached, you'll find 2 files: metadata.xml and environmentVariable.st,
that you can put on the Rudder policy server, in the folder
//var/rudder/configuration-repository/techniques/systemSettings/misc/////environmentVariable/1.0/
Add the folder in git, and commit, with the following commands, run in
//var/rudder/configuration-repository/techniques/systemSettings/misc/
/git add environmentVariable//
//git commit -m "Adding a prototype technique to expose environment
variable"/
In the Web Interface, you'll need to go to the Administration/Technique
page, click on "Reload technique now". The Technique "Expose environment
variable" should appear on the left tree; you'll need to drag and drop
it on the tree on the right to be able to use it
Then you'll need to create a Directive based on it, that you would apply
to all node, as well as a Directive based on "Enforce a file content",
to create the file
//var/rudder/cfengine-community/env/
with the content
/#! /bin/sh//
//env | sed 's/^/=/'/
And create it executable.
Once these two directives are applied everywhere, you'll be able to use
your environment variables with the syntax ${env.IP_MASTER}
Does it help ?
Regards,
Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rudder-project.org/pipermail/rudder-users/attachments/20140916/7d962023/attachment.html>
-------------- next part --------------
#! /bin/sh
env | sed 's/^/=/'
-------------- next part --------------
#####################################################################################
# Copyright 2014 Normation SAS
#####################################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#####################################################################################
# Execute module in /var/rudder/cfengine-community/modules
# Will expose all env variables in the env context
# Note: it has to be a bundle common to be sure to be always run
# Note bis: it must be in modules, as we can only execute modules there from a bundle common
# idealy, this would go in system technique, to avoid having a module
bundle common get_environment_variable {
classes:
"done" expression => usemodule("env", "");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: metadata.xml
Type: text/xml
Size: 1176 bytes
Desc: not available
URL: <http://www.rudder-project.org/pipermail/rudder-users/attachments/20140916/7d962023/attachment.xml>
More information about the rudder-users
mailing list