/** @deprecated since 0.6.0 (soon after introduced) use {@link #knifeConvergeRunList(String)} or {@link #knifeConvergeTask()} with fluent API */ @Deprecated public static KnifeTaskFactory<String> knifeConverge(final Function<? super Entity,String> runList, final boolean sudo, final String otherParameters, final boolean runTwice) { return new KnifeConvergeTaskFactory<String>("knife converge") .knifeRunList(runList) .knifeSudo(sudo) .knifeRunTwice(runTwice) .knifeAddParameters(otherParameters) .requiringZeroAndReturningStdout(); }
/** knife converge task configured for this run list on windows (winrm) */ public static KnifeConvergeTaskFactory<String> knifeConvergeRunListWindowsWinrm(String runList) { return knifeConvergeTask() .knifeRunList(runList) .knifeSudo(false) .knifeAddExtraBootstrapParameters("windows winrm") .knifePortUseKnifeDefault(); }
/** plain knife converge task - run list must be set, other arguments are optional */ public static KnifeConvergeTaskFactory<String> knifeConvergeTask() { return new KnifeConvergeTaskFactory<String>("knife converge") .requiringZeroAndReturningStdout(); } /** knife converge task configured for this run list (and sudo) */
protected void startWithKnifeAsync() { DynamicTasks.queue( ChefServerTasks.knifeConvergeTask() .knifeRunList(Strings.join(Preconditions.checkNotNull(entity().getConfig(ChefConfig.CHEF_RUN_LIST), "%s must be supplied for %s", ChefConfig.CHEF_RUN_LIST, entity()), ",")) .knifeAddAttributes(entity().getConfig(CHEF_LAUNCH_ATTRIBUTES)) .knifeRunTwice(entity().getConfig(CHEF_RUN_CONVERGE_TWICE)) ); }
/** knife converge task configured for this run list on windows (ssh) */ public static KnifeConvergeTaskFactory<String> knifeConvergeRunListWindowsSsh(String runList) { return knifeConvergeTask() .knifeRunList(runList) .knifeSudo(false) .knifeAddExtraBootstrapParameters("windows ssh"); }
protected Integer knifeWhichPort(HostAndPort hostAndPort) { if (port==null) { if (portOmittedToUseKnifeDefault==Boolean.TRUE) // user has explicitly said to use knife default, omitting port here return null; // default is to use the machine port return hostAndPort.getPort(); } if (port==-1) { // port was supplied by user, then portDefault (true or false) port = null; Integer whichPort = knifeWhichPort(hostAndPort); log.warn("knife port conflicting instructions for "+this+" at entity "+entity()+" on "+hostAndPort+"; using default ("+whichPort+")"); return whichPort; } if (portOmittedToUseKnifeDefault!=null) { // portDefault was specified (true or false), then overridden with a port log.warn("knife port conflicting instructions for "+this+" at entity "+entity()+" on "+hostAndPort+"; using supplied port "+port); } // port was supplied by user, use that return port; }
/** knife converge task configured for this run list (and sudo) */ public static KnifeConvergeTaskFactory<String> knifeConvergeRunList(String runList) { return knifeConvergeTask() .knifeRunList(runList) .knifeSudo(true); }
protected void startWithKnifeAsync() { Entities.warnOnIgnoringConfig(entity(), ChefConfig.CHEF_RUN_LIST); Entities.warnOnIgnoringConfig(entity(), ChefConfig.CHEF_LAUNCH_ATTRIBUTES); DynamicTasks.queue( ChefServerTasks .knifeConvergeRunList("postgresql::server") .knifeAddAttributes(Jsonya .at("postgresql", "config").add( "port", entity().getAttribute(PostgreSqlNode.POSTGRESQL_PORT), "listen_addresses", "*").getRootMap()) .knifeAddAttributes(Jsonya .at("postgresql", "pg_hba").list().map().add( "type", "host", "db", "all", "user", "all", "addr", "0.0.0.0/0", "method", "md5").getRootMap()) // no other arguments currenty supported; chef will pick a password for us ); } protected void postStartCustom() {
Integer whichPort = knifeWhichPort(hostAndPort); if (whichPort!=null) result.add("-p "+whichPort); result.add("-r "+wrapBash(runList.apply(entity())));