Skip to content

Commit cb79628

Browse files
committed
(role/tma) add tma profile and test
1 parent b354dc4 commit cb79628

File tree

5 files changed

+517
-0
lines changed

5 files changed

+517
-0
lines changed

hieradata/role/tma.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
classes:
3+
- "profile::core::debugutils"
4+
- "profile::core::docker"
5+
- "profile::ts::tma"
6+
7+
packages:
8+
- "git"
9+
- "git-lfs"
10+
- "perl-File-Copy"
11+
- "unzip"
12+
13+
profile::ts::tma::tma_db_repo: "[email protected]:lsst-ts/ts_tma_mariadb-docker.git"
14+
profile::ts::tma::tma_db_path: "/opt/tma/mariadb-docker"
15+
profile::ts::tma::opman_path: "/opt/tma/operation-manager"
16+
profile::ts::tma::pxi_0_ip: "10.0.0.10"
17+
profile::ts::tma::pxi_1_ip: "10.0.0.11"
18+
19+
profile::ts::tma::labview_rpm_url: "https://repo-nexus.lsst.org/nexus/repository/ts_yum/releases/ni-labview-2024-pro-24.3.2.49152-0%2Bf0-rhel9.noarch.rpm"
20+
profile::ts::tma::vipm_url: "https://repo-nexus.lsst.org/nexus/repository/tma_artifacts/labview/vipm-22.1.2354-linux.zip"
21+
profile::ts::tma::vipm_root: "/usr/local/JKI/VIPM"
22+
profile::ts::tma::vipc_path: "/usr/local/JKI/VIPM/LSST_tma_dependencies.vipc"
23+
profile::ts::tma::vipc_url: "https://github.com/lsst-ts/ts_tma_vipm_dependency/raw/develop/LSST_tma_dependencies.vipc"
24+
25+
profile::ts::tma::enable_graphical: true

site/profile/manifests/ts/tma.pp

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# @summary
2+
# TMA multi-user workstation: XFCE, Docker services, LabVIEW, VIPM
3+
#
4+
# @param tma_db_repo TMA MariaDB repository
5+
# @param tma_db_path Path for TMA DB (shared service)
6+
# @param github_token GitHub Personal Access Token for private repos (optional)
7+
# @param pxi_0_ip PXI 0 IP address
8+
# @param pxi_1_ip PXI 1 IP address
9+
# @param opman_path Operation Manager path (shared service)
10+
# @param labview_rpm_url Full URL to NI LabVIEW RPM
11+
# @param compose_cmd Docker compose command (docker-compose or docker compose)
12+
# @param ghcr_username GitHub Container Registry username
13+
# @param ghcr_token GitHub Container Registry token (Sensitive)
14+
# @param vipm_url VIPM ZIP download URL
15+
# @param vipc_url VIPC dependencies URL
16+
# @param vipm_root VIPM root installation path
17+
# @param vipc_path VIPC file destination path
18+
# @param enable_graphical Enable graphical mode (XFCE + GDM)
19+
# @param tma_group LDAP group name for TMA users (must exist in FreeIPA)
20+
class profile::ts::tma (
21+
String[1] $tma_db_repo,
22+
Stdlib::Absolutepath $tma_db_path,
23+
Optional[Sensitive[String[1]]] $github_token = undef,
24+
String[1] $pxi_0_ip,
25+
String[1] $pxi_1_ip,
26+
Stdlib::Absolutepath $opman_path = '/opt/tma/operation-manager',
27+
String[1] $labview_rpm_url = 'https://repo-nexus.lsst.org/nexus/repository/ts_yum/releases/ni-labview-2024-pro-24.3.2.49152-0%2Bf0-rhel9.noarch.rpm',
28+
String[1] $compose_cmd = 'docker-compose',
29+
Optional[String[1]] $ghcr_username = undef,
30+
Optional[Sensitive[String[1]]] $ghcr_token = undef,
31+
Optional[String[1]] $vipm_url = undef,
32+
String[1] $vipc_url = 'https://github.com/lsst-ts/ts_tma_vipm_dependency/raw/develop/LSST_tma_dependencies.vipc',
33+
Stdlib::Absolutepath $vipm_root = '/usr/local/JKI/VIPM',
34+
Stdlib::Absolutepath $vipc_path = '/usr/local/JKI/VIPM/LSST_tma_dependencies.vipc',
35+
Boolean $enable_graphical = true,
36+
String[1] $tma_group = 'tma',
37+
) {
38+
if $enable_graphical {
39+
package { ['@base-x', '@xfce-desktop']:
40+
ensure => installed,
41+
}
42+
exec { 'set-graphical-target':
43+
command => '/bin/systemctl set-default graphical.target',
44+
unless => '/bin/systemctl get-default | grep -q graphical.target',
45+
onlyif => '/bin/systemctl is-active sssd',
46+
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
47+
require => Class['ipa::client'],
48+
}
49+
50+
file { '/etc/gdm/custom.conf':
51+
ensure => file,
52+
owner => 'root',
53+
group => 'root',
54+
mode => '0644',
55+
content => epp('profile/ts/tma/gdm-custom.conf.epp'),
56+
notify => Service['gdm'],
57+
}
58+
59+
service { 'gdm':
60+
ensure => running,
61+
enable => true,
62+
require => Exec['set-graphical-target'],
63+
}
64+
}
65+
66+
if $ghcr_username != undef and $ghcr_token != undef {
67+
exec { 'docker-login-ghcr':
68+
command => "bash -lc 'printf %s ${ghcr_token.unwrap} | docker login ghcr.io -u ${ghcr_username} --password-stdin'",
69+
unless => "bash -lc 'docker info 2>/dev/null | grep -q ghcr.io'",
70+
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
71+
}
72+
}
73+
74+
file { '/opt/tma':
75+
ensure => directory,
76+
owner => 'root',
77+
group => $tma_group,
78+
mode => '0775',
79+
}
80+
81+
if $github_token != undef {
82+
file { $tma_db_path:
83+
ensure => directory,
84+
owner => 'root',
85+
group => $tma_group,
86+
mode => '2775',
87+
require => File['/opt/tma'],
88+
}
89+
90+
$tma_db_source = regsubst($tma_db_repo, '^git@github\.com:', "https://${github_token.unwrap}@github.com/")
91+
92+
vcsrepo { $tma_db_path:
93+
ensure => present,
94+
provider => git,
95+
source => $tma_db_source,
96+
require => File[$tma_db_path],
97+
}
98+
99+
file { "${tma_db_path}/backup":
100+
ensure => directory,
101+
owner => 'root',
102+
group => $tma_group,
103+
mode => '2775',
104+
}
105+
106+
exec { 'tma-db-up':
107+
command => "${compose_cmd} up -d",
108+
cwd => $tma_db_path,
109+
refreshonly => true,
110+
subscribe => Vcsrepo[$tma_db_path],
111+
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin', '/usr/local/bin'],
112+
}
113+
114+
cron { 'tma-db-createbackup':
115+
ensure => present,
116+
command => "${tma_db_path}/createbackup.pl",
117+
minute => '5',
118+
hour => '12',
119+
user => 'root',
120+
}
121+
122+
cron { 'tma-db-python-backup':
123+
ensure => present,
124+
command => "docker run --rm -v ${tma_db_path}/python:/script -v ${tma_db_path}/backup:/backup python:3.7 python /script/main.py",
125+
minute => '5',
126+
hour => '13',
127+
user => 'root',
128+
}
129+
} else {
130+
notify { 'tma-db-skip':
131+
message => 'TMA DB skip: no GitHub token',
132+
}
133+
}
134+
135+
file { $opman_path:
136+
ensure => directory,
137+
owner => 'root',
138+
group => $tma_group,
139+
mode => '2775',
140+
require => File['/opt/tma'],
141+
}
142+
143+
$compose_content = @("COMPOSE")
144+
version: '3'
145+
services:
146+
mt-mount-manager:
147+
image: ghcr.io/lsst-ts/ts_tma_operation-manager_mt-mount-operation-manager:latest
148+
container_name: mt-mount-manager
149+
ports:
150+
- "60005:60005"
151+
- "40005:40005"
152+
- "30005:30005"
153+
volumes:
154+
- /var/log/mtmount_operation_manager/:/var/log/mtmount_operation_manager
155+
environment:
156+
- PXI_0_IP=${pxi_0_ip}
157+
- PXI_1_IP=${pxi_1_ip}
158+
restart: unless-stopped
159+
| COMPOSE
160+
161+
file { "${opman_path}/docker-compose.yml":
162+
ensure => file,
163+
owner => 'root',
164+
group => $tma_group,
165+
mode => '0664',
166+
content => $compose_content,
167+
notify => Exec['opman-up'],
168+
}
169+
170+
exec { 'opman-up':
171+
command => "${compose_cmd} up -d",
172+
cwd => $opman_path,
173+
refreshonly => true,
174+
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin', '/usr/local/bin'],
175+
}
176+
177+
package { 'ni-labview-2024-el9-pro':
178+
ensure => installed,
179+
provider => 'rpm',
180+
source => $labview_rpm_url,
181+
}
182+
183+
exec { 'ensure-labview-repo':
184+
command => "/bin/bash -c 'rpm -e --nodeps ni-labview-2024-el9-pro 2>/dev/null; rpm -ivh ${labview_rpm_url}; dnf makecache'",
185+
unless => '/bin/test -f /etc/yum.repos.d/ni-labview-2024-el9-pro.repo',
186+
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
187+
before => Package['ni-labview-2024-pro'],
188+
}
189+
190+
package { 'ni-labview-2024-pro':
191+
ensure => '24.3.2.49152-0+f0',
192+
require => Package['ni-labview-2024-el9-pro'],
193+
}
194+
195+
file { '/usr/local/JKI':
196+
ensure => directory,
197+
owner => 0,
198+
group => 0,
199+
mode => '0755',
200+
}
201+
202+
file { '/etc/JKI':
203+
ensure => directory,
204+
owner => 0,
205+
group => 0,
206+
mode => '0755',
207+
}
208+
209+
file { $vipm_root:
210+
ensure => directory,
211+
owner => 0,
212+
group => 0,
213+
mode => '0755',
214+
require => File['/usr/local/JKI'],
215+
}
216+
217+
if $vipm_url != undef {
218+
exec { 'vipm-download':
219+
command => "curl -fsSL -o /tmp/vipm.zip ${vipm_url}",
220+
unless => "test -x ${vipm_root}/vipm",
221+
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
222+
require => File[$vipm_root],
223+
}
224+
225+
exec { 'vipm-unzip':
226+
command => "unzip -o /tmp/vipm.zip -d ${vipm_root} && rm -f /tmp/vipm.zip",
227+
unless => "test -x ${vipm_root}/vipm",
228+
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
229+
require => Exec['vipm-download'],
230+
}
231+
}
232+
233+
if $github_token != undef {
234+
exec { 'vipc-fetch':
235+
command => "bash -lc 'curl -fsSL -H \"Authorization: token ${github_token.unwrap}\" -o ${vipc_path} ${vipc_url}'",
236+
creates => $vipc_path,
237+
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
238+
require => File[$vipm_root],
239+
}
240+
} else {
241+
notify { 'vipc-skip':
242+
message => 'VIPC skip: no GitHub token',
243+
}
244+
}
245+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[daemon]
2+
WaylandEnable=false
3+
DefaultSession=xfce.desktop
4+
5+
[security]
6+
7+
[xdmcp]
8+
9+
[chooser]
10+
11+
[debug]
12+

0 commit comments

Comments
 (0)