Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added agent command and help to bootstrap #104

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cf_remote/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,3 +886,21 @@ def deploy(hubs, masterfiles):
os.system("rm -rf %s" % tarball)
os.system("tar -czf %s -C %s masterfiles" % (tarball, above))
return deploy_tarball(hubs, tarball)

def agent(hosts, bootstrap=None) :

command = "cf-agent"
if bootstrap :
command += " --bootstrap {}".format(bootstrap)

for host in hosts:
data = get_info(host)

if not data["agent_version"] :
user_error("CFEngine not installed on {}".format(host))

output = run_command(host, command, sudo=True)
if output :
print(output)

return 0
10 changes: 10 additions & 0 deletions cf_remote/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ def _get_arg_parser():
type=str,
nargs="?",
)
sp = subp.add_parser("agent", help="Run cf-agent")
sp.add_argument(
"--hosts", "-H", help="Which hosts to run cf-agent from", type=str, required=True
)
sp.add_argument("--bootstrap", "-B", help="Which hub to bootstrap to", type=str)

return ap

Expand All @@ -281,6 +286,9 @@ def run_command_with_args(command, args):
else:
trust_keys = None

if not args.bootstrap :
log.warning("You did not specify --bootstrap in the install command, so CFEngine has been installed, but not started.\nTo fix this, run:\ncf-remote agent --hosts HOSTS --bootstrap BOOTSTRAP")

return commands.install(
args.hub,
args.clients,
Expand Down Expand Up @@ -367,6 +375,8 @@ def run_command_with_args(command, args):
return commands.destroy(group_name)
elif command == "deploy":
return commands.deploy(args.hub, args.masterfiles)
elif command == "agent":
return commands.agent(args.hosts, args.bootstrap)
else:
user_error("Unknown command: '{}'".format(command))

Expand Down
Loading