Hi John,

Thanks a lot for the information. I checked the variables and could not 
find anything defined twice.

In my workaround I updated the module code slightly and managed to fix the 
issue I face.

This is the original code
https://github.com/razorsedge/puppet-network/blob/master/manifests/if/static.pp

I changed the code by introducing parameter called interface. In the 
interface and I pass the value "eth0" etc and in title I pass a unique 
value.  

define network::if::static (
  $interface,
  $ensure,
  $ipaddress,
  $netmask,
  $gateway = '',
  $macaddress = '',
  $userctl = false,
  $mtu = '',
  $ethtool_opts = '',
  $peerdns = false,
  $dns1 = '',
  $dns2 = '',
  $domain = '',
)
..
..
  network_if_base { $interface:
    ensure       => $ensure,
    ipaddress    => $ipaddress,
    netmask      => $netmask,
    gateway      => $gateway,
    macaddress   => $macaddy,
    bootproto    => 'none',
    userctl      => $userctl,
    mtu          => $mtu,
    ethtool_opts => $ethtool_opts,
    peerdns      => $peerdns,
    dns1         => $dns1,
    dns2         => $dns2,
    domain       => $domain,
  }

Though I haven't dive deep in module code it seems having title variable 
repeated with value "eth0" when it runs for each server seems. 

Thanks,
Chaminda 


On Friday, January 17, 2014 1:58:51 AM UTC+10, jcbollinger wrote:
>
>
>
> On Wednesday, January 15, 2014 9:57:41 PM UTC-6, CD wrote:
>>
>> Hi friends,
>>
>> I have an issue where that I receive error Error 400 on SERVER: Cannot 
>> reassign variable name on node app1. When I run the agent on admin1 it 
>> works fine, but when I run the agent on app1 it give me the error.
>>
>> Having read few forum posts it seems this is most likely that the same 
>> resource is used. resource network::if::static is used with eth0 in the 
>> same class when it runs for admin1 and app1. I believe when it run on 
>> admin1 variables are used without any problem and when it run on app1 it 
>> find the variable has been used for admin1.
>>
>
>
> No.  Puppet is complaining about a *variable*, not a resource.  That is, 
> something of the general form
>
> $some_var = 'a value'
>
> Each variable may be assigned a value at most once.  There are two likely 
> scenarios for how this might be happening:
>
>    1. Most likely, you have a reassignment of the affected variable 
>    inside a conditional statement, such that it is processed for node app1 
> but 
>    not for node admin1.
>    2. Alternatively, you may have a global variable assignment at top 
>    scope in a manifest file that is not loaded for node admin1, but is loaded 
>    for node app1.  Such an assignment in principle applies to all nodes (and 
>    therefore is wrong for all nodes), but it won't be seen when node app1's 
>    catalog is compiled (which makes such statement placement a very bad idea 
>    in general, error notwithstanding).
>
> Example of (1):
>
> class site {
>   $is_app_node = false
>
>   if $hostname =~ /^app/ {
>     # WRONG:
>     $is_app_node = true
>   }
> }
>
>
> Example of (2):
> manifests/site.pp:
> -----------
> # Top-scope declaration ok here:
> $is_app_node = false
>
> node app1 {
>   include myapp
> }
>
> modules/myapp/manifests/init.pp:
> -----------
> # Top-scope declaration unwise here:
> $is_app_node = true
>
> class myapp {
>   # ...
> }
>
>
> It appears these kind of issues are addressed by creating virtual 
>> resources. However I cannot figure out how I can define virtual resources 
>> and combine that with create_resources. I need to use the create_resources 
>> because I was to pass the hieradata to the resource.
>>
>> *Any ideas how I can address this problem?*
>>
>> Details of the implementation given below:
>>
>> I have following hieradata which applied to each server:
>>
>> /etc/puppet/hieradata/admin1.json
>> {
>>    "networks":{
>>       "eth0":{
>>          "ipaddress":"192.168.1.1",
>>          "netmask":"255.255.255.0"
>>       }
>>    }
>> }
>>
>> /etc/puppet/hieradata/app1.json
>> {
>>    "networks":{
>>       "eth0":{
>>          "ipaddress":"192.168.1.2",
>>          "netmask":"255.255.255.0"
>>       }
>>    }
>> }
>>
>> I have a class call foundation and it has following files
>> /etc/puppet/modules/foundation/manifests/init.pp
>> class foundation {
>>     include foundation::network
>> }
>>
>> /etc/puppet/modules/foundation/manifests/network.pp
>> class foundation::network{
>>
>>     # Defaults for network configuration
>>     $nic_default = {
>>         'ensure' => 'up'
>>     }
>>
>>     # Extract Data from Hiera for the host in concern
>>     $nics   = hiera("networks",{})
>>
>>     # Configure networks based on the parameters
>>     create_resources(network::if::static, $nics, $nic_default)
>>
>> }
>>
>> Above class is included in base node and individual nodes has extended 
>> from the base node
>> /etc/puppet/manifests/nodes.pp
>> node base {
>>    include foundation
>> }
>>
>> node admin1 inherits base {
>> }
>>
>> node app1 inherits base {
>> }
>>
>>
>
> I don't see any issue with the code and data you presented.  Have you 
> checked the master's logs for more information?  I'm thinking it ought to 
> tell you the name of the affected variable.  If it doesn't already do so, 
> then perhaps turning on --debug output will induce it to do so.
>
>
> John
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/20835f3f-e6ce-449d-871c-21623f6d6fb4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to