Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move globus-timer-cli into dedicated class to avoid conflicts with globus-cli #30

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Currently this module supports Globus 4.x and 5.4.
| -------------- | ----------------------------- |
| 4.x | 3.x |
| 4.x & 5.3 | 4.x |
| 4.x & 5.4 | 5.x-6.x |
| 4.x & 5.4 | 5.x-7.x |


### Upgrading to module version 5.x
Expand Down Expand Up @@ -158,6 +158,14 @@ To install the Globus CLI to `/opt/globus-cli` and create symlink for executable
include globus::cli
```

### Globus Timer

To install the Globus Timer CLI to `/opt/globus-timer` and create symlink for executable at `/usr/bin/globus-timer`:

```puppet
include globus::timer
```

### Globus SDK

To install the Globus SDK to `/opt/globus-sdk`:
Expand Down Expand Up @@ -197,7 +205,3 @@ Tested using
* Debian 10
* Ubuntu 18.04
* Ubuntu 20.04

## Limitations

At this time `globus::cli` and `globus::sdk` are not supported on Ubuntu 20.04 due to limitations in the Python module
20 changes: 0 additions & 20 deletions manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
# Path to install Globus CLI virtualenv
# @param manage_python
# Boolean to set if Python is managed by this class
# @param timer_ensure
# Set globus-timer-cli ensure value
class globus::cli (
String[1] $ensure = 'present',
Stdlib::Absolutepath $install_path = '/opt/globus-cli',
Boolean $manage_python = true,
String[1] $timer_ensure = 'absent',
) {

if $manage_python {
Expand All @@ -41,21 +38,4 @@
target => "${install_path}/bin/globus",
require => Python::Pip['globus-cli'],
}

if $timer_ensure != 'absent' {
$timer_cli_ensure = 'link'
} else {
$timer_cli_ensure = 'absent'
}

python::pip { 'globus-timer-cli':
ensure => $timer_ensure,
pip_provider => $globus::python::pip_provider,
virtualenv => $install_path,
}
file { '/usr/bin/globus-timer':
ensure => $timer_cli_ensure,
target => "${install_path}/bin/globus-timer",
require => Python::Pip['globus-timer-cli'],
}
}
40 changes: 40 additions & 0 deletions manifests/timer.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# @summary Manage Globus Timer
#
# @example
# include ::globus::timer
#
# @param ensure
# The ensure parameter for PIP installed globus-timer-cli
# @param install_path
# Path to install Globus Timer CLI virtualenv
# @param manage_python
# Boolean to set if Python is managed by this class
class globus::timer (
String[1] $ensure = 'present',
Stdlib::Absolutepath $install_path = '/opt/globus-timer',
Boolean $manage_python = true,
) {

if $manage_python {
include globus::python
}

python::pyvenv { 'globus-timer':
ensure => 'present',
version => $globus::python::venv_python_version,
venv_dir => $install_path,
systempkgs => true,
before => Python::Pip['globus-timer-cli'],
}

python::pip { 'globus-timer-cli':
ensure => $ensure,
pip_provider => $globus::python::pip_provider,
virtualenv => $install_path,
}
file { '/usr/bin/globus-timer':
ensure => 'link',
target => "${install_path}/bin/globus-timer",
require => Python::Pip['globus-timer-cli'],
}
}
13 changes: 2 additions & 11 deletions spec/acceptance/globus_cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
describe 'globus::cli class:' do
context 'with default parameters' do
it 'runs successfully' do
# Python is too old on Debian 9 for globus-timer-cli
timer_ensure = if fact('os.name') == 'Debian' && fact('os.release.major') == '9'
'absent'
else
'present'
end
pp = "class { 'globus::cli': timer_ensure => '#{timer_ensure}' }"
pp = 'include globus::cli'

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe command('globus --version') do
its(:exit_status) { is_expected.to eq 0 }
end
describe command('globus-timer --version'), unless: (fact('os.name') == 'Debian' && fact('os.release.major') == '9') do
describe command('globus version') do
its(:exit_status) { is_expected.to eq 0 }
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/globus_sdk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
apply_manifest(pp, catch_changes: true)
end

describe command("/opt/globus-cli/bin/python -c 'import globus_sdk'") do
describe command("/opt/globus-sdk/bin/python -c 'import globus_sdk'") do
its(:exit_status) { is_expected.to eq 0 }
end
end
Expand Down
16 changes: 16 additions & 0 deletions spec/acceptance/globus_timer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper_acceptance'

describe 'globus::timer class:', unless: fact('os.name') == 'Debian' && fact('os.release.major') == '9' do
context 'with default parameters' do
it 'runs successfully' do
pp = 'include globus::timer'

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe command('globus-timer --version') do
its(:exit_status) { is_expected.to eq 0 }
end
end
end
34 changes: 0 additions & 34 deletions spec/classes/globus_cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,40 +41,6 @@
is_expected.to contain_file('/usr/bin/globus').with('ensure' => 'link',
'target' => '/opt/globus-cli/bin/globus')
end

it do
is_expected.to contain_python__pip('globus-timer-cli').with(
'ensure' => 'absent',
'pip_provider' => platforms[platform_os][:pip_provider],
'virtualenv' => '/opt/globus-cli',
)
end

it do
is_expected.to contain_file('/usr/bin/globus-timer').with(
'ensure' => 'absent',
'target' => '/opt/globus-cli/bin/globus-timer',
)
end

context 'when timer_ensure is present' do
let(:params) { { timer_ensure: 'present' } }

it do
is_expected.to contain_python__pip('globus-timer-cli').with(
'ensure' => 'present',
'pip_provider' => platforms[platform_os][:pip_provider],
'virtualenv' => '/opt/globus-cli',
)
end

it do
is_expected.to contain_file('/usr/bin/globus-timer').with(
'ensure' => 'link',
'target' => '/opt/globus-cli/bin/globus-timer',
)
end
end
end
end
end
48 changes: 48 additions & 0 deletions spec/classes/globus_timer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'spec_helper'

describe 'globus::timer' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
let(:platform_os) { "#{facts[:os]['family']}-#{facts[:os]['release']['major']}" }

it { is_expected.to compile.with_all_deps }

it { is_expected.to create_class('globus::timer') }

it do
is_expected.to contain_class('python').with(
version: platforms[platform_os][:python_version],
dev: 'present',
)
end

it do
is_expected.to contain_python__pyvenv('globus-timer').with(
'ensure' => 'present',
'version' => platforms[platform_os][:venv_python_version],
'venv_dir' => '/opt/globus-timer',
'systempkgs' => 'true',
)
end
it { is_expected.to contain_python__pyvenv('globus-timer').that_comes_before('Python::Pip[globus-timer-cli]') }

it do
is_expected.to contain_python__pip('globus-timer-cli').with(
'ensure' => 'present',
'pip_provider' => platforms[platform_os][:pip_provider],
'virtualenv' => '/opt/globus-timer',
)
end

it do
is_expected.to contain_file('/usr/bin/globus-timer').with(
'ensure' => 'link',
'target' => '/opt/globus-timer/bin/globus-timer',
)
end
end
end
end