如何在 AWS 上使用 puppet 运行 fdisk
How to run fdisk with puppet on AWS
我正在尝试使用 Packer 和 puppet-masterless builder 创建 AMI。我想将 20G ebs 卷挂载到 /test
。
基本上我想使用 puppet 自动执行以下命令。我试过了,但还没有成功。我是木偶新手,尝试使用 lvm 模块,但遇到了问题。有人可以建议正确的方法来实现以下吗?
fdisk /dev/xvdk
mkfs -t xfs /dev/xvdk1
mkdir -p /test
echo "/dev/xvdk1 /test xfs defaults 0 0" >> /etc/fstab
mount /test
试试这个:
mount /dev/xvdk1 /test
希望对您有所帮助
您应该只使用 Puppet 中的 mount
type。
既然你说你正在使用 lvm
模块,下面是你将如何完成你在 Puppet 中描述的内容。
# there is no Puppet intrinsic for this
exec { '/sbin/fdisk /dev/xvdk': unless => '/bin/lsblk /dev/xvdk' }
# create the /dev/xvdk1 filesystem
filesystem { '/dev/xvdk1':
ensure => present,
fs_type => xfs,
require => Exec['/sbin/fdisk /dev/xvdk1'], # after partition created
}
# create directory
file { '/test': ensure => directory }
# mount /test
mount { '/test':
ensure => mounted, # mount /test
device => '/dev/xvdk1', # next five lines fstab mount options
fstype => xfs,
options => defaults,
dump => 0,
pass => 0,
atboot => true, # add entry to fstab
require => File['/test'], # after dir created
subscribe => Filesystem['/dev/xvdk1'], # remount if/when filesystem changes
}
请注意,您在此过程中并未创建卷组或逻辑卷,您可能希望创建卷组或逻辑卷(尤其是逻辑卷)才能成功。但是,上述 Puppet 资源将完美执行您在问题中描述的命令。
我正在尝试使用 Packer 和 puppet-masterless builder 创建 AMI。我想将 20G ebs 卷挂载到 /test
。
基本上我想使用 puppet 自动执行以下命令。我试过了,但还没有成功。我是木偶新手,尝试使用 lvm 模块,但遇到了问题。有人可以建议正确的方法来实现以下吗?
fdisk /dev/xvdk
mkfs -t xfs /dev/xvdk1
mkdir -p /test
echo "/dev/xvdk1 /test xfs defaults 0 0" >> /etc/fstab
mount /test
试试这个:
mount /dev/xvdk1 /test
希望对您有所帮助
您应该只使用 Puppet 中的 mount
type。
既然你说你正在使用 lvm
模块,下面是你将如何完成你在 Puppet 中描述的内容。
# there is no Puppet intrinsic for this
exec { '/sbin/fdisk /dev/xvdk': unless => '/bin/lsblk /dev/xvdk' }
# create the /dev/xvdk1 filesystem
filesystem { '/dev/xvdk1':
ensure => present,
fs_type => xfs,
require => Exec['/sbin/fdisk /dev/xvdk1'], # after partition created
}
# create directory
file { '/test': ensure => directory }
# mount /test
mount { '/test':
ensure => mounted, # mount /test
device => '/dev/xvdk1', # next five lines fstab mount options
fstype => xfs,
options => defaults,
dump => 0,
pass => 0,
atboot => true, # add entry to fstab
require => File['/test'], # after dir created
subscribe => Filesystem['/dev/xvdk1'], # remount if/when filesystem changes
}
请注意,您在此过程中并未创建卷组或逻辑卷,您可能希望创建卷组或逻辑卷(尤其是逻辑卷)才能成功。但是,上述 Puppet 资源将完美执行您在问题中描述的命令。