Skip to content

Commit

Permalink
Move cni_plugins, crictl & etcd to subfolders in /opt/k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
olavst-spk committed Jun 3, 2024
1 parent 306dbaf commit c9e4f2e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 46 deletions.
17 changes: 2 additions & 15 deletions manifests/install/cni_plugins.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,16 @@

case $method {
'tarball', 'loose': {
file { '/opt/cni-plugins':
ensure => stdlib::ensure($ensure, 'directory'),
purge => true,
recurse => true,
force => true,
}

$_url = k8s::format_url($download_url_template, {
version => $version,
})
$_target = "/opt/cni-plugins/${version}";
$_tarball_target = '/opt/cni-plugins/archives';
$_target = "/opt/k8s/cni-${version}";
$_tarball_target = '/opt/k8s/archives';

file { $_target:
ensure => stdlib::ensure($ensure, 'directory'),
}

file { $_tarball_target:
ensure => stdlib::ensure($ensure, 'directory'),
purge => true,
recurse => true,
}

archive { 'cni-plugins':
ensure => $ensure,
path => "${_tarball_target}/cni-plugins-linux-${version}.tgz",
Expand Down
15 changes: 2 additions & 13 deletions manifests/install/crictl.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,16 @@

$config_require = Package[$pkg]
} else {
file { '/opt/cri-tools':
ensure => stdlib::ensure($ensure, 'directory'),
purge => true,
recurse => true,
force => true,
}

$_url = k8s::format_url($download_url_template, {
version => $version,
})
$_target = "/opt/cri-tools/${version}";
$_tarball_target = '/opt/cri-tools/archives';
$_target = "/opt/k8s/crictl-${version}";
$_tarball_target = '/opt/k8s/archives';

file { $_target:
ensure => stdlib::ensure($ensure, 'directory'),
}

file { $_tarball_target:
ensure => stdlib::ensure($ensure, 'directory'),
}

archive { 'crictl':
ensure => $ensure,
path => "${_tarball_target}/crictl-${version}-linux.tar.gz",
Expand Down
15 changes: 2 additions & 13 deletions manifests/server/etcd/setup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,15 @@
Optional[Integer[0, 65535]] $gid = undef,
) {
if $install == 'archive' {
file { '/opt/etcd':
ensure => stdlib::ensure($ensure, 'directory'),
purge => true,
recurse => true,
force => true,
}

$_url = k8s::format_url($archive_template, { version => $version, })
$_file = basename($_url)
$_target = "/opt/etcd/${version}";
$_tarball_target = '/opt/etcd/archives';
$_target = "/opt/k8s/etcd-${version}";
$_tarball_target = '/opt/k8s/archives';

file { $_target:
ensure => stdlib::ensure($ensure, 'directory'),
}

file { $_tarball_target:
ensure => stdlib::ensure($ensure, 'directory'),
}

archive { 'etcd':
ensure => $ensure,
path => "${_tarball_target}/${_file}",
Expand Down
10 changes: 5 additions & 5 deletions spec/classes/server/etcd/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ class { '::k8s::server::etcd':
it do
is_expected.to contain_archive('etcd').with(
ensure: 'present',
path: '/opt/etcd/archives/etcd-v3.6.0-linux-amd64.tar.gz',
path: '/opt/k8s/archives/etcd-v3.6.0-linux-amd64.tar.gz',
source: 'https://storage.googleapis.com/etcd/v3.6.0/etcd-v3.6.0-linux-amd64.tar.gz',
extract: true,
extract_command: 'tar xfz %s --strip-components=1',
extract_path: '/opt/etcd/3.6.0',
extract_path: '/opt/k8s/etcd-3.6.0',
cleanup: true,
creates: ['/opt/etcd/3.6.0/etcd', '/opt/etcd/3.6.0/etcdctl']
creates: ['/opt/k8s/etcd-3.6.0/etcd', '/opt/k8s/etcd-3.6.0/etcdctl']
)

is_expected.to contain_file('/usr/local/bin/etcd').with(
ensure: 'link',
mode: '0755',
replace: true,
target: '/opt/etcd/3.6.0/etcd'
target: '/opt/k8s/etcd-3.6.0/etcd'
).that_notifies('Service[etcd]')

is_expected.to contain_file('/usr/local/bin/etcdctl').with(
ensure: 'link',
mode: '0755',
replace: true,
target: '/opt/etcd/3.6.0/etcdctl'
target: '/opt/k8s/etcd-3.6.0/etcdctl'
)
end

Expand Down

0 comments on commit c9e4f2e

Please sign in to comment.