Veja a minha definição de "renomear" para ideias. Ele assume o Debian e pode funcionar no Ubuntu também.
define rename() {
# We only need puppet so we can restart it. In practice, there's
# little point in renaming a machine through puppet without a
# running puppet service
include puppet::conf
# We only need apt because puppet management of its package
include apt
host { "$hostname": ensure => absent }
host { "$fqdn": ensure => absent }
$alias = regsubst($name, '^([^.]*).*$', '')
host { "$name":
ensure => present,
ip => $ipaddress,
alias => $alias ? {
"$hostname" => undef,
default => $alias
},
before => Exec['hostname.sh'],
}
file { '/etc/mailname':
ensure => present,
owner => 'root',
group => 'root',
mode => 644,
content => "${name}\n",
}
file { '/etc/hostname':
ensure => present,
owner => 'root',
group => 'root',
mode => 644,
content => "${name}\n",
notify => Exec['hostname.sh'],
}
exec { 'hostname.sh':
command => '/etc/init.d/hostname.sh start',
refreshonly => true,
notify => Service['puppet'],
}
}
define rename::domain() {
rename { "${hostname}.${name}": }
common::line { 'remove_old_domain':
ensure => absent,
file => '/etc/resolv.conf',
line => "domain $domain",
}
common::line { 'add_new_domain':
ensure => present,
file => '/etc/resolv.conf',
line => "domain $name",
}
}