gpt4 book ai didi

linux - 在同一台服务器上安装多个 NFS 的 puppet

转载 作者:太空宇宙 更新时间:2023-11-04 09:17:55 25 4
gpt4 key购买 nike

我在同一台服务器上有几个 NFS 挂载点,但目录不同。例如:

    x.x.x.x:/stats   /data/stats
x.x.x.x:/scratch /data/scratch
x.x.x.x:/ops /data/ops

但是当我尝试运行 puppet 时,它会在我的 fstab 中添加以下内容。 (错误的挂载分配)

x.x.x.x:/scratch   /data/stats       nfs     defaults,nodev,nosharecache     0       0
x.x.x.x:/scratch /data/ops nfs defaults,nodev,nosharecache 0 0
x.x.x.x:/scratch /data/scratch nfs defaults,nodev,nosharecache 0 0

它在所有挂载的分区上使用最后一个挂载选项。所以我做了一些研究并发现了以下错误。

 https://tickets.puppetlabs.com/browse/DOCUMENT-242

然后添加了 nosharecache 选项,但仍然没有运气。这是我的 puppet 代码

class profile::mounts::stats {
# Hiera lookups
$location = hiera('profile::mounts::stats::location')
$location2 = hiera('profile::mounts::stats::location2')
tag 'new_mount'

file { '/data/stats':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
require => File['/data'],
tag => 'new_mount',
}

mount { '/data/stats':
ensure => mounted,
fstype => 'nfs',
device => $location,
options => 'defaults,nodev,nosharecache',
require => File['/data/stats'],
tag => 'new_mount'
}



file { '/data/ops':
ensure => directory,
owner => 'root',
group => 'mail',
mode => '0775',
require => File['/data'],
tag => 'new_mount',
}

mount { '/data/ops':
ensure => mounted,
fstype => 'nfs',
device => $location2,
options => 'defaults,nodev,nosharecache',
require => File['/data/ops'],
tag => 'new_mount',
}

file { '/data/scratch':
ensure => directory,
owner => 'root',
group => 'mail',
mode => '0775',
require => File['/data'],
tag => 'new_mount',
}

mount { '/data/scratch':
ensure => mounted,
fstype => 'nfs',
device => $location2,
options => 'defaults,nodev,nosharecache',
require => File['/data/scratch'],
tag => 'new_mount',
}

}

}

我的hieara查询如下

profile::mounts::stats::location: x.x.x.x:/stats
profile::mounts::stats::location2: x.x.x.x:/scratch

为什么会导致一些意外行为?

最佳答案

我编译了这段代码,发现了一些问题:

您没有包含 File['/data'] 资源,但我假设您在其他地方有它?

编译后我在目录中看到了这个:

$ cat myclass.json | jq '.resources | .[] | select(.type == "Mount") | [.title, .parameters]'
[
"/data/stats",
{
"ensure": "mounted",
"fstype": "nfs",
"device": "x.x.x.x:/stats",
"options": "defaults,nodev,nosharecache",
"require": "File[/data/stats]",
"tag": "new_mount"
}
]
[
"/data/ops",
{
"ensure": "mounted",
"fstype": "nfs",
"device": "x.x.x.x:/scratch",
"options": "defaults,nodev,nosharecache",
"require": "File[/data/ops]",
"tag": "new_mount"
}
]
[
"/data/scratch",
{
"ensure": "mounted",
"fstype": "nfs",
"device": "x.x.x.x:/scratch",
"options": "defaults,nodev,nosharecache",
"require": "File[/data/scratch]",
"tag": "new_mount"
}
]

因此,您同时将 /data/ops/data/scratch 安装在 $location2 上。这是疏忽吗?它与您所说的要实现的目标不符。

否则我无法重现你所说的你正在观察的内容。

除了 Puppet 之外,还有其他任何东西在编辑 fstab 文件吗?您是否在新盒子上尝试过此代码?

关于linux - 在同一台服务器上安装多个 NFS 的 puppet ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45046191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com