On Fri, Jan 11, 2013 at 6:14 PM, jcbollinger <john.bollin...@stjude.org>wrote:

>
>
> On Friday, January 11, 2013 4:45:49 AM UTC-6, Vladimir Rutsky wrote:
>
>> Can you suggest solution to my problem?
>>
>>
>
> Generally speaking, the Puppet way of approaching such problems is to have
> all the relevant resources draw on the same data, instead of some resources
> getting it indirectly from others.  The data may reside in an external
> source and be accessed via a Puppet function, they may reside in one or
> more class variables, or they may be received in the form of definition
> parameters (or class parameters, though I advise against that).
>
>
>
>> I want to create multiple Python virtual environments in different
>> directories and use files from them in other resources (like Django
>> installation and some other Python programs) in such way, that single
>> Python virtual environment can be used in multiple other resources.
>>
>
>
> Are you suggesting that some nodes will have multiple distinct Python
> environments, or just that Python environments of different nodes will
> differ?  It makes a big difference to which solution(s) I might recommend.
>

Nodes can have multiple distinct Python environments. For example I want
test my python programs with multiple versions of libraries:

Linux host:
  virtualenv1 with LibA version 1.0, LibB version 2.0 - test programC,
programD
  virtualenv2 with LibA version 0.1, LibB version 0.2 - test programC,
programD

Windows host:
  virtualenv1 with LibA version 1.0, LibB version 2.0 - test programC,
programD
  virtualenv2 with LibA version 0.1, LibB version 0.2 - test programC,
programD

So on each host I want to create two virtual environments, something like
this:

node 'windows-testing-host', 'linux-testing-host' {
  # Setup python with dependencies. Suppose "python" executable is added in
global path on Windows and Linux, so no problems with finding it.
  class {'python': }

  # Setup virtualenv1
  python::virtualenv::env { 'virtualenv1': }

  # Setup virtualenv2
  python::virtualenv::env { 'virtualenv2': }

  # easy_install LibA v1.0, LibB v2.0 in virtualenv1 - needs path to
bin/easy_install or Scripts/easy_install.exe
  ...
  # easy_install LibA v1.0, LibB v2.0 in virtualenv2 - needs path to
bin/easy_install or Scripts/easy_install.exe
  ...

  # Install and test programC, programD in virtual environments
}


I'm new to Puppet and as temporary solution I done something like this:

node 'windows-testing-host' {
  class {'python': }

  $virtualenv1_dir = 'C:/virtualenv1'

  python::virtualenv::env { 'virtualenv1':
    directory => $virtualenv1_dir,
  }

  libA { 'virtualenv1 libA':
    virtualenv_dir => $virtualenv1_dir,
    version => '1.0',
  }

  libB { 'virtualenv1 libB':
    virtualenv_dir => $virtualenv1_dir,
    version => '0.1',
  }

  programC { 'virtualenv1 programC':
    virtualenv_dir => $virtualenv1_dir,
  }

  programD { 'virtualenv1 programD':
    virtualenv_dir => $virtualenv1_dir,
  }

  $virtualenv2_dir = 'C:/virtualenv2'

  python::virtualenv::env { 'virtualenv1':
    directory => $virtualenv2_dir,
  }

  libA { 'virtualenv2 libA':
    virtualenv_dir => $virtualenv2_dir,
    version => '2.0',
  }

  libB { 'virtualenv2 libB':
    virtualenv_dir => $virtualenv2_dir,
    version => '0.2',
  }

  programC { 'virtualenv2 programC':
    virtualenv_dir => $virtualenv2_dir,
  }

  programD { 'virtualenv2 programD':
    virtualenv_dir => $virtualenv2_dir,
  }
}

node 'linux-testing-host' {
  class {'python': }

  $virtualenv1_dir = '/opt/virtualenv1'

  python::virtualenv::env { 'virtualenv1':
    directory => $virtualenv1_dir,
  }

  libA { 'virtualenv1 libA':
    virtualenv_dir => $virtualenv1_dir,
    version => '1.0',
  }

  libB { 'virtualenv1 libB':
    virtualenv_dir => $virtualenv1_dir,
    version => '0.1',
  }

  programC { 'virtualenv1 programC':
    virtualenv_dir => $virtualenv1_dir,
  }

  programD { 'virtualenv1 programD':
    virtualenv_dir => $virtualenv1_dir,
  }

  $virtualenv2_dir = '/opt/virtualenv2'

  python::virtualenv::env { 'virtualenv2':
    directory => $virtualenv2_dir,
  }

  libA { 'virtualenv2 libA':
    virtualenv_dir => $virtualenv2_dir,
    version => '2.0',
  }

  libB { 'virtualenv2 libB':
    virtualenv_dir => $virtualenv2_dir,
    version => '0.2',
  }

  programC { 'virtualenv2 programC':
    virtualenv_dir => $virtualenv2_dir,
  }

  programD { 'virtualenv2 programD':
    virtualenv_dir => $virtualenv2_dir,
  }
}

And in libA, libB, programC, programC I check OS fact and select correct
easy_install binary.


>
>
> John
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/LE6iFr5dq2sJ.
>
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>


--

Vladimir Rutsky

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to