Defined Type: wildfly::host::server_config
- Defined in:
- manifests/host/server_config.pp
Overview
Manages a host server-config. This defined type should be used at a slave machine (considering domain mode). You can use this resource to remove default servers server-one and server-two (present at default host-slave.xml). If you removed the default server-groups in the domain controller (main-server-group and other-server-group) you’ll need to ensure that the resources are applied after the Wildfly installation and before the module starts to setup Wildfly to enable and run the service (or the host controller service will not run at all because the servers are associated to server-groups that doesn’t exist). For this case, use a overlay_class (wildfly::overlay_class param) or the following snippet:
wildfly::host::server_config { [‘server-one’, ‘server-two’]:
ensure => absent,
hostname => $hostname,
username => $username,
password => $password,
require => Class['wildfly::install'],
before => Class['wildfly::setup'],
}
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'manifests/host/server_config.pp', line 32
define wildfly::host::server_config (
Enum[present, absent] $ensure = present,
Integer $offset = 0,
Boolean $auto_start = true,
Stdlib::Unixpath $wildfly_dir = $wildfly::dirname,
Integer $controller_mgmt_port = 9990,
Boolean $start_server_after_created = true,
Optional[Wildfly::Config_file] $host_config = $wildfly::host_config,
Optional[String] $controller_address = $wildfly::properties['jboss.domain.master.address'],
Optional[String] $server_group = undef,
Optional[String] $hostname = undef,
Optional[String] $username = undef,
Optional[String] $password = undef,
) {
require wildfly::install
$server_name = $title
if $ensure == present {
if (!$server_group) {
fail('server_group is required')
}
}
$need_to_connect_to_domain_controller = ($ensure == present or $facts['wildfly_is_running'])
if $need_to_connect_to_domain_controller {
if (!$hostname) {
fail('hostname is required')
}
if (!$username) {
fail('username is required')
}
if (!$password) {
fail('password is required')
}
if (!$controller_address) {
fail('controller_address is required')
}
}
if $ensure == present {
debug("Will connect to domain controller to create server-config ${server_name}")
wildfly_resource { "/host=${hostname}/server-config=${server_name}":
state => {
'auto-start' => $auto_start,
'group' => $server_group,
'socket-binding-port-offset' => $offset,
},
username => $username,
password => $password,
host => $controller_address,
port => $controller_mgmt_port,
require => Service['wildfly'],
}
if $start_server_after_created {
debug("Will connect to domain controller to start server-config ${server_name}")
wildfly_cli { "/host=${hostname}/server-config=${server_name}:start(blocking=true)":
onlyif => "(result != STARTED) of /host=${hostname}/server-config=${server_name}:read-attribute(name=status)",
username => $username,
password => $password,
host => $controller_address,
port => $controller_mgmt_port,
subscribe => Wildfly_resource["/host=${hostname}/server-config=${server_name}"],
}
}
} elsif $ensure == absent {
debug("Wildfly is running? ${facts['wildfly_is_running']}")
if (!$wildfly_dir) {
fail('wildfly_dir is required')
}
if (!$host_config) {
fail('host_config is required')
}
if $facts['wildfly_is_running'] {
debug("Will connect to domain controller to remove server-config ${server_name}")
wildfly_cli { "/host=${hostname}/server-config=${server_name}:stop(blocking=true)":
skip_absent => true,
onlyif => "(result != STOPPED) of /host=${hostname}/server-config=${server_name}:read-attribute(name=status)",
username => $username,
password => $password,
host => $controller_address,
port => $controller_mgmt_port,
}
-> wildfly_resource { "/host=${hostname}/server-config=${server_name}":
ensure => absent,
username => $username,
password => $password,
host => $controller_address,
port => $controller_mgmt_port,
}
} else {
debug("Using augeas to remove server-config ${server_name}")
augeas { "manage-host-controller-server-${server_name}":
lens => 'Xml.lns',
incl => "${wildfly_dir}/domain/configuration/${host_config}",
changes => "rm host/servers/server[#attribute/name='${server_name}']",
onlyif => "match host/servers/server[#attribute/name='${server_name}'] size != 0",
}
}
}
}
|