Import rest of modules.
This commit is contained in:
parent
02fa10f33c
commit
3f225ced9b
39 changed files with 2056 additions and 0 deletions
5
iscsi/files/targets.conf
Normal file
5
iscsi/files/targets.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
#
|
||||
# TGTD targets file
|
||||
#
|
||||
|
||||
include /etc/tgt/target.d/*.conf
|
98
iscsi/manifests/init.pp
Normal file
98
iscsi/manifests/init.pp
Normal file
|
@ -0,0 +1,98 @@
|
|||
|
||||
class iscsi::server {
|
||||
|
||||
package { "scsi-target-utils":
|
||||
ensure => installed,
|
||||
}
|
||||
|
||||
service { "tgtd":
|
||||
ensure => running,
|
||||
enable => true,
|
||||
require => Package["scsi-target-utils"],
|
||||
}
|
||||
|
||||
file { "/etc/tgt/targets.conf":
|
||||
ensure => present,
|
||||
source => [ "puppet:///files/iscsi/targets.conf.${fqdn}",
|
||||
"puppet:///files/iscsi/targets.conf",
|
||||
"puppet:///iscsi/targets.conf", ],
|
||||
mode => 0600,
|
||||
owner => root,
|
||||
group => root,
|
||||
require => Package["scsi-target-utils"],
|
||||
}
|
||||
|
||||
file { "/etc/tgt/target.d":
|
||||
ensure => directory,
|
||||
mode => 0700,
|
||||
owner => root,
|
||||
group => root,
|
||||
require => Package["scsi-target-utils"],
|
||||
}
|
||||
|
||||
exec { "iscsi-refresh":
|
||||
command => "tgt-admin -e",
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
onlyif => "tgt-admin -e -p | egrep '^tgtadm '",
|
||||
require => Service["tgtd"],
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
define iscsi::target($tid, $initiator = "ALL", $ensure = "present") {
|
||||
|
||||
include iscsi::server
|
||||
|
||||
$iqn = sprintf("iqn.2005-08.tgt:%s%s", $hostname, regsubst($name, "/", ".", "G"))
|
||||
|
||||
case $ensure {
|
||||
"present": {
|
||||
file { "/etc/tgt/target.d/${tid}.conf":
|
||||
ensure => present,
|
||||
content => template("iscsi/tid.conf.erb"),
|
||||
mode => 0600,
|
||||
owner => root,
|
||||
group => root,
|
||||
require => File["/etc/tgt/target.d"],
|
||||
before => Exec["iscsi-refresh"],
|
||||
}
|
||||
|
||||
}
|
||||
"absent": {
|
||||
file { "/etc/tgt/target.d/${tid}.conf":
|
||||
ensure => absent,
|
||||
before => Exec["iscsi-refresh"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class iscsi::initiator {
|
||||
|
||||
package { "iscsi-initiator-utils":
|
||||
ensure => installed,
|
||||
}
|
||||
|
||||
service { "iscsid":
|
||||
ensure => running,
|
||||
enable => true,
|
||||
require => Package["iscsi-initiator-utils"],
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
define iscsi::connect($portal) {
|
||||
|
||||
include iscsi::initiator
|
||||
|
||||
exec { "iscsi-connect-${name}":
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
command => "iscsiadm --mode discovery --type sendtargets --portal ${portal} && iscsiadm --mode node --targetname ${name} --portal ${portal} --login",
|
||||
onlyif => "! iscsiadm --mode session | egrep '${portal}:[0-9]*,[0-9]* ${name}'\$",
|
||||
require => Service["iscsid"],
|
||||
}
|
||||
|
||||
}
|
4
iscsi/templates/tid.conf.erb
Normal file
4
iscsi/templates/tid.conf.erb
Normal file
|
@ -0,0 +1,4 @@
|
|||
<target <%= iqn -%>>
|
||||
backing-store <%= name %>
|
||||
initiator-address <%= initiator %>
|
||||
</target>
|
Loading…
Add table
Add a link
Reference in a new issue