Skip to content

Commit

Permalink
(node/hexrot) add conda install ts_m2gui
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarria committed Sep 27, 2023
1 parent 7c4650a commit 8de4446
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hieradata/role/hexrot.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
classes:
- "mate"
- "profile::core::anaconda"
- "profile::core::common"
- "profile::core::debugutils"
- "profile::core::docker"
- "profile::core::docker::prune"
- "profile::core::ni_packages"
- "profile::core::x2go"
- "profile::ts::hexrot"
- "profile::ts::nexusctio"
files:
/rubin:
Expand All @@ -18,6 +20,8 @@ files:
subscribe:
- "Package[runHexEui]"
- "Package[runRotEui]"
- "Package[runM2Cntlr]"

# / on hexrot.cp was formated with xfs fstype=0 (long, long, long ago) and is
# not compatible with overlayfs[2]
profile::core::docker::storage_driver: "devicemapper"
Expand All @@ -27,3 +31,12 @@ accounts::group_list:
ensure: "present"
gid: 70014
forcelocal: true
profile::core::anaconda::python_env_name: "py311"
profile::core::anaconda::python_env_version: "3.11.4"
profile::core::anaconda::conda_packages:
-
name: "pyside2"
channel: "conda-forge"
-
name: "ts-m2gui"
channel: "lsstts"
76 changes: 76 additions & 0 deletions site/profile/manifests/core/anaconda.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# @summary
# Installs anaconda
# @param python_env_name
# if exist, sets the name of the virtual environment
#
# @param python_env_version
# if exist, sets the version of python for the virtual environment
#
class profile::core::anaconda (
String $python_env_name,
String $python_env_version,
Tuple $conda_packages,
) {
case $facts['os']['family'] {
'RedHat': {
#package { 'wget':
# ensure => installed,
#}
exec { 'install_anaconda':
command => '/bin/wget https://repo.anaconda.com/archive/Anaconda3-2023.07-2-Linux-x86_64.sh -O /tmp/anaconda_installer.sh && /bin/bash /tmp/anaconda_installer.sh -b -p /opt/anaconda',
creates => '/opt/anaconda/bin/conda',
path => '/usr/bin:/bin:/opt/anaconda/bin',
require => Package['wget'],
}
}
default: {
notify { 'unsupported_os':
message => 'This Anaconda installation is only for RedHat family',
}
}
}
# Create a Conda environment with Python if parameters are set
if ($python_env_name and $python_env_version) {
exec { 'create_conda_env':
command => "/opt/anaconda/bin/conda create -y --name ${python_env_name} python=${python_env_version}",
creates => "/opt/anaconda/envs/${python_env_name}/",
require => Exec['install_anaconda'],
}
file { '/etc/profile.d/conda_source.sh':
ensure => file,
mode => '0644',
require => Exec['create_conda_env'],
# lint:ignore:strict_indent
content => @("SOURCE"),
#!/usr/bin/bash
source /opt/anaconda/bin/activate ${python_env_name}
| SOURCE
# lint:endignore
}
# Install libmamba inside the environment with conda
exec { 'install_libmamba_env':
command => "/opt/anaconda/bin/conda install -y -n ${python_env_name} conda-libmamba-solver",
creates => "/opt/anaconda/envs/${python_env_name}/lib/libmamba.so",
require => Exec['create_conda_env'],
path => ['/usr/bin', '/bin', '/opt/anaconda/bin'],
}
# Sets libmamba as dependencies solver
exec { 'set_libmamba':
command => 'conda config --set solver libmamba',
require => Exec['install_libmamba_env'],
unless => 'conda config --get solver | grep libmamba',
path => ['/usr/bin', '/bin', '/opt/anaconda/bin'],
}
}
#cycle and install conda stuff
if !empty($conda_packages) {
$conda_packages.each |$package_info| {
exec { "install_${package_info['name']}_via_conda":
command => "conda install -y -n ${python_env_name} -c ${package_info['channel']} ${package_info['name']}",
path => ['/usr/bin', '/bin', '/opt/anaconda/bin'],
require => Exec['set_libmamba'],
unless => "conda list -n ${python_env_name} | grep ${package_info['name']}",
}
}
}
}
38 changes: 38 additions & 0 deletions site/profile/manifests/ts/hexrot.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# @summary
# Sets up repos and symlinks for hexrot

class profile::ts::hexrot {

#include vcsrepo::manage::git

$user = 73006

vcsrepo { '/opt/ts_config_mttcs':
ensure => present,
provider => git,
source => 'https://github.com/lsst-ts/ts_config_mttcs.git',
keep_local_changes => true,
user => $user,
owner => $user,
group => $user,
require => Class[profile::core::anaconda],
}
file { '/etc/profile.d/hexrot_path.sh':
ensure => file,
mode => '0644',
require => Vcsrepo['/opt'],
# lint:ignore:strict_indent
content => @(ENV),
#!/usr/bin/bash
export QT_API="PySide2"
export PYTEST_QT_API="PySide2"
export TS_CONFIG_MTTCS="/opt/ts_config_mttcs"
| ENV
# lint:endignore
}
file { '/opt/anaconda/envs/py311/bin/python':
ensure => link,
target => '/rubin/mtm2/python/python',
require => '/opt/anaconda/envs/py311',
}
}

0 comments on commit 8de4446

Please sign in to comment.