Skip to content

Commit

Permalink
Fixes #12106: Implement general parameters for policy server policy c…
Browse files Browse the repository at this point in the history
…opy for nodes
  • Loading branch information
ncharles committed Feb 16, 2018
1 parent e5158ef commit 6790104
Show file tree
Hide file tree
Showing 13 changed files with 298 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ class SystemVariableSpecServiceImpl extends SystemVariableSpecService {
"CONFIGURATION_REPOSITORY_FOLDER" , "The path to the configuration repository folder"
, constraint = Constraint(mayBeEmpty=true)
)
, SystemVariableSpec(
"RELAY_SYNC_METHOD" , "Synchronization method for relay; can be classic, rsync or manual "
, multivalued = false
)
, SystemVariableSpec(
"RELAY_SYNC_PROMISES" , "Synchronize promises on relay with Rsync in rsync mode"
, constraint = Constraint(typeName = BooleanVType, default=Some("true"))
)
, SystemVariableSpec(
"RELAY_SYNC_SHAREDFILES" , "Synchronize sharedfiles on relay with Rsync in rsync mode"
, constraint = Constraint(typeName = BooleanVType, default=Some("true"))
)

//
// The following variables contain information about all the node *directly*
// managed by a policy server (i.e: we don't have children of relays here)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ object SyslogTCP extends SyslogProtocol {

object SyslogUDP extends SyslogProtocol {
val value = "UDP"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ import com.normation.inventory.domain._
import net.liftweb.common._
import com.normation.cfclerk.services.SystemVariableSpecService
import com.normation.rudder.repository.FullNodeGroupCategory
import com.normation.rudder.domain.policies.GroupTarget
import com.normation.rudder.domain.policies.RuleTarget
import com.normation.rudder.repository.FullNodeGroupCategory
import com.normation.rudder.services.servers.PolicyServerManagementService
import com.normation.rudder.services.servers.RelaySynchronizationMethod
import com.normation.rudder.reports.ComplianceMode
import com.normation.rudder.reports.ChangesOnly
import com.normation.rudder.reports.AgentRunInterval
import com.normation.rudder.reports.SyslogProtocol
import com.normation.rudder.domain.licenses.NovaLicense
import com.normation.rudder.repository.FullNodeGroupCategory
import com.normation.rudder.domain.policies.GroupTarget
import com.normation.rudder.domain.policies.RuleTarget


trait SystemVariableService {
def getGlobalSystemVariables(globalAgentRun: AgentRunInterval): Box[Map[String, Variable]]
Expand Down Expand Up @@ -98,6 +100,11 @@ class SystemVariableServiceImpl(
//denybadclocks and skipIdentify are runtime properties
, getDenyBadClocks: () => Box[Boolean]
, getSkipIdentify : () => Box[Boolean]
// relay synchronisation method
, getSyncMethod : () => Box[RelaySynchronizationMethod]
, getSyncPromises : () => Box[Boolean]
, getSyncSharedFiles : () => Box[Boolean]

// TTLs are runtime properties too
, getModifiedFilesTtl : () => Box[Int]
, getCfengineOutputsTtl : () => Box[Int]
Expand Down Expand Up @@ -144,6 +151,10 @@ class SystemVariableServiceImpl(
val cfengineOutputsTtl = getProp("CFENGINE_OUTPUTS_TTL", getCfengineOutputsTtl)
val reportProtocol = getProp("RUDDER_SYSLOG_PROTOCOL", () => getSyslogProtocol().map(_.value))

val relaySyncMethod = getProp("RELAY_SYNC_METHOD", () => getSyncMethod().map(_.value))
val relaySyncPromises = getProp("RELAY_SYNC_PROMISES", getSyncPromises)
val relaySyncSharedFiles = getProp("RELAY_SYNC_SHAREDFILES", getSyncSharedFiles)

val sendMetricsValue = if (getSendMetrics().getOrElse(None).getOrElse(false)) {
"yes"
} else {
Expand Down Expand Up @@ -171,6 +182,9 @@ class SystemVariableServiceImpl(
configurationRepositoryFolder ::
denyBadClocks ::
skipIdentify ::
relaySyncMethod ::
relaySyncPromises ::
relaySyncSharedFiles ::
varAgentRunInterval ::
varAgentRunSchedule ::
varAgentRunSplayTime ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,19 @@ class PolicyServerManagementServiceImpl(
}
}
}

sealed trait RelaySynchronizationMethod {
def value : String
}

object ClassicSynchronization extends RelaySynchronizationMethod {
val value = "classic"
}

object RsyncSynchronization extends RelaySynchronizationMethod {
val value = "rsync"
}

object DisabledSynchronization extends RelaySynchronizationMethod {
val value = "disable"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"DENYBADCLOCKS":"true",
"MODIFIED_FILES_TTL":"30",
"NODEROLE":" classes: \n \"policy_server\" expression => \"any\";",
"RELAY_SYNC_METHOD":"classic",
"RELAY_SYNC_PROMISES":"false",
"RELAY_SYNC_SHAREDFILES":"false",
"RUDDER_DIRECTIVES_INPUTS":"\"Create_file/1.0/rudder_reporting.cf\",\n\"Create_file/1.0/Create_file.cf\",\n\"packageManagement/1.0/packageManagement.cf\",",
"RUDDER_DIRECTIVES_SEQUENCE":"\"50-rule-technique-ncf/Create a file\" usebundle => set_dry_run_mode(\"false\");\n\"50-rule-technique-ncf/Create a file\" usebundle => current_technique_report_info(\"Create_file\");\n\"50-rule-technique-ncf/Create a file\" usebundle => Create_file;\n\"50-rule-technique-ncf/Create a file\" usebundle => Create_file_rudder_reporting;\n\"60-rule-technique-std-lib/Package management.\" usebundle => set_dry_run_mode(\"false\");\n\"60-rule-technique-std-lib/Package management.\" usebundle => package_management;\n\"remove_dry_run_mode\" usebundle => set_dry_run_mode(\"false\");",
"RUDDER_HEARTBEAT_INTERVAL":"4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"DENYBADCLOCKS":"true",
"MODIFIED_FILES_TTL":"30",
"NODEROLE":" classes: \n \"policy_server\" expression => \"any\";",
"RELAY_SYNC_METHOD":"classic",
"RELAY_SYNC_PROMISES":"false",
"RELAY_SYNC_SHAREDFILES":"false",
"RUDDER_DIRECTIVES_INPUTS":"\"genericVariableDefinition/2.0/genericVariableDefinition.cf\",",
"RUDDER_DIRECTIVES_SEQUENCE":"\"10. Global configuration for all nodes/00. Generic Variable Def #2\" usebundle => set_dry_run_mode(\"false\");\n\"10. Global configuration for all nodes/00. Generic Variable Def #2\" usebundle => generic_variable_def_report;\n\"remove_dry_run_mode\" usebundle => set_dry_run_mode(\"false\");",
"RUDDER_HEARTBEAT_INTERVAL":"4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"DENYBADCLOCKS":"true",
"MODIFIED_FILES_TTL":"30",
"NODEROLE":" classes: \n \"policy_server\" expression => \"any\";\n \"root_server\" expression => \"any\";\n \"rudder-ldap\" expression => \"any\";\n \"rudder-inventory-ldap\" expression => \"any\";\n \"rudder-reports\" expression => \"any\";\n \"rudder-webapp\" expression => \"any\";\n \"rudder-jetty\" expression => \"any\";\n \"rudder-server-root\" expression => \"any\";\n \"rudder-inventory-endpoint\" expression => \"any\";\n \"rudder-db\" expression => \"any\";",
"RELAY_SYNC_METHOD":"classic",
"RELAY_SYNC_PROMISES":"false",
"RELAY_SYNC_SHAREDFILES":"false",
"RUDDER_DIRECTIVES_INPUTS":"",
"RUDDER_DIRECTIVES_SEQUENCE":"",
"RUDDER_HEARTBEAT_INTERVAL":"4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"DENYBADCLOCKS":"true",
"MODIFIED_FILES_TTL":"30",
"NODEROLE":" classes: \n \"policy_server\" expression => \"any\";\n \"root_server\" expression => \"any\";\n \"rudder-ldap\" expression => \"any\";\n \"rudder-inventory-ldap\" expression => \"any\";\n \"rudder-reports\" expression => \"any\";\n \"rudder-webapp\" expression => \"any\";\n \"rudder-jetty\" expression => \"any\";\n \"rudder-server-root\" expression => \"any\";\n \"rudder-inventory-endpoint\" expression => \"any\";\n \"rudder-db\" expression => \"any\";",
"RELAY_SYNC_METHOD":"classic",
"RELAY_SYNC_PROMISES":"false",
"RELAY_SYNC_SHAREDFILES":"false",
"RUDDER_DIRECTIVES_INPUTS":"\"clockConfiguration/3.0/clockConfiguration.cf\",\n\"rpmPackageInstallation/7.0/rpmPackageInstallation.cf\",",
"RUDDER_DIRECTIVES_SEQUENCE":"\"10. Global configuration for all nodes/10. Clock Configuration\" usebundle => set_dry_run_mode(\"false\");\n\"10. Global configuration for all nodes/10. Clock Configuration\" usebundle => check_clock_configuration;\n\"50. Deploy PLOP STACK/20. Install PLOP STACK main rpm\" usebundle => set_dry_run_mode(\"true\");\n\"50. Deploy PLOP STACK/20. Install PLOP STACK main rpm\" usebundle => check_rpm_package_installation;\n\"remove_dry_run_mode\" usebundle => set_dry_run_mode(\"false\");",
"RUDDER_HEARTBEAT_INTERVAL":"4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ import com.normation.BoxSpecMatcher
import com.normation.rudder.services.policies.NodeConfigData
import com.normation.rudder.domain.nodes.NodeInfo
import com.normation.rudder.services.policies.NodeConfigData.{root, node1, rootNodeConfig}
import com.normation.cfclerk.domain.Technique
import com.normation.cfclerk.domain.Variable
import com.normation.cfclerk.domain.TrackerVariable
import com.normation.inventory.domain.AgentType
import com.normation.rudder.services.servers.ClassicSynchronization

/**
* Details of tests executed in each instances of
Expand Down Expand Up @@ -188,6 +193,10 @@ object TestSystemData {
//denybadclocks and skipIdentify are runtime properties
, getDenyBadClocks = () => Full(true)
, getSkipIdentify = () => Full(false)
// relay synchronisation method
, getSyncMethod = () => Full(ClassicSynchronization)
, getSyncPromises = () => Full(false)
, getSyncSharedFiles = () => Full(false)
// TTLs are runtime properties too
, getModifiedFilesTtl = () => Full(30)
, getCfengineOutputsTtl = () => Full(7)
Expand Down
3 changes: 3 additions & 0 deletions rudder-web/src/main/scala/bootstrap/liftweb/AppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,9 @@ object RudderConfig extends Loggable {
, RUDDER_SERVER_ROLES
, configService.cfengine_server_denybadclocks _
, configService.cfengine_server_skipidentify _
, configService.relay_server_sync_method
, configService.relay_server_syncpromises
, configService.relay_server_syncsharedfiles
, configService.cfengine_modified_files_ttl _
, configService.cfengine_outputs_ttl _
, configService.rudder_store_all_centralized_logs_in_file _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import com.normation.rudder.domain.policies.PolicyMode
import com.normation.rudder.domain.policies.PolicyMode._
import com.normation.rudder.domain.policies.GlobalPolicyMode
import com.normation.rudder.domain.policies.PolicyModeOverrides

import com.normation.rudder.services.servers.{RelaySynchronizationMethod, ClassicSynchronization, RsyncSynchronization, DisabledSynchronization}
/**
* A service that Read mutable (runtime) configuration properties
*
Expand Down Expand Up @@ -98,6 +98,13 @@ trait ReadConfigService {
def cfengine_server_denybadclocks(): Box[Boolean]
def cfengine_server_skipidentify(): Box[Boolean]

/**
* Relay synchronization configuration
*/
def relay_server_sync_method() : Box[RelaySynchronizationMethod]
def relay_server_syncpromises() : Box[Boolean]
def relay_server_syncsharedfiles() : Box[Boolean]

/**
* Agent execution interval and start run
*/
Expand Down Expand Up @@ -197,6 +204,14 @@ trait UpdateConfigService {
def set_cfengine_server_denybadclocks(value: Boolean): Box[Unit]
def set_cfengine_server_skipidentify(value: Boolean): Box[Unit]

/**
* Set Relay-Server synchronization method
*/
def set_relay_server_sync_method(value: RelaySynchronizationMethod): Box[Unit]
def set_relay_server_syncpromises(value: Boolean) : Box[Unit]
def set_relay_server_syncsharedfiles(value: Boolean) : Box[Unit]


/**
* Agent frequency and start run
*/
Expand Down Expand Up @@ -294,6 +309,9 @@ class LDAPBasedConfigService(configFile: Config, repos: ConfigRepository, workfl
rudder.workflow.self.deployment=true
cfengine.server.denybadclocks=true
cfengine.server.skipidentify=false
relay.sync.method=classic
relay.sync.promises=true
relay.sync.sharedfiles=true
agent.run.interval=5
agent.run.splaytime=4
agent.run.start.hour=0
Expand Down Expand Up @@ -356,6 +374,11 @@ class LDAPBasedConfigService(configFile: Config, repos: ConfigRepository, workfl
SyslogTCP
case _ => SyslogUDP
}
private[this] implicit def toRelaySynchronisationMethod(p: RudderWebProperty): RelaySynchronizationMethod = p.value match {
case ClassicSynchronization.value => ClassicSynchronization
case RsyncSynchronization.value => RsyncSynchronization
case DisabledSynchronization.value => DisabledSynchronization
}
private[this] implicit def toString(p: RudderWebProperty): String = p.value

private[this] implicit def toUnit(p: Box[RudderWebProperty]) : Box[Unit] = p.map( _ => ())
Expand Down Expand Up @@ -403,6 +426,14 @@ class LDAPBasedConfigService(configFile: Config, repos: ConfigRepository, workfl
def cfengine_server_skipidentify(): Box[Boolean] = get("cfengine_server_skipidentify")
def set_cfengine_server_skipidentify(value: Boolean): Box[Unit] = save("cfengine_server_skipidentify", value)

// Relay synchronization configuration
def relay_server_sync_method() : Box[RelaySynchronizationMethod] = get("relay.sync.method")
def set_relay_server_sync_method(value: RelaySynchronizationMethod): Box[Unit] = save("relay.sync.method", value.value)
def relay_server_syncpromises() : Box[Boolean] = get("relay.sync.promises")
def set_relay_server_syncpromises(value : Boolean): Box[Unit] = save("relay.sync.promises", value)
def relay_server_syncsharedfiles() : Box[Boolean] = get("relay.sync.sharedfiles")
def set_relay_server_syncsharedfiles(value: Boolean) : Box[Unit] = save("relay.sync.sharedfiles", value)

def agent_run_interval(): Box[Int] = get("agent_run_interval")
def set_agent_run_interval(value: Int, actor: EventActor, reason: Option[String]): Box[Unit] = {
val info = ModifyGlobalPropertyInfo(ModifyAgentRunIntervalEventType,actor,reason)
Expand Down
Loading

0 comments on commit 6790104

Please sign in to comment.