-
Notifications
You must be signed in to change notification settings - Fork 10
ENT-14320: Wrapped most of the remaining cf-remote/cfbs commands into CFEngine-cli #209
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
Merged
+398
−33
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
beb5b49
Added `cfengine show` to list your saved hosts
SimonThalvorsen f1b142b
Added support to specify hub for automatic deploy&run after `cfengine…
SimonThalvorsen 70c0ddc
Added `cfengine moduleinfo` to show module-information/status of a cf…
SimonThalvorsen a07a6fa
Added `cfengine connect` to open a SSH-session to a saved host
SimonThalvorsen d600fd9
Added `cfengine input` to set input for specified module
SimonThalvorsen ea32085
Fixed help-descriptor for `cfengine run`
SimonThalvorsen e99f80b
Added `cfengine add/remove/search/update` to add/remove/search for mo…
SimonThalvorsen fbb5aba
Changed selection strategy as to not resolve all hosts if --host HOST…
SimonThalvorsen 6635f6c
Added CHEATSHEET.md
SimonThalvorsen eaf82d6
Added localhost/local known targets for build/deploy
SimonThalvorsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # CFEngine CLI cheatsheet | ||
|
|
||
| Quick reference for `cfengine COMMANDS` | ||
| For the full command list, run `cfengine help` or `cfengine COMMAND --help`. | ||
|
|
||
| ## Managing hosts | ||
|
|
||
| ```bash | ||
| # Save one or more hosts under a group name, for reuse in other commands | ||
| cfengine save --hosts 192.168.56.90 --role hub --name myhub | ||
|
|
||
| # List all saved host-groups | ||
| cfengine show | ||
|
|
||
| # Show details about a specific saved host (or group) | ||
| cfengine show --host myhub | ||
|
|
||
| # Open an interactive SSH session to a saved host | ||
| cfengine connect --hosts myhub | ||
| ``` | ||
|
|
||
| ## Managing cfbs modules | ||
|
|
||
| These are thin wrappers around the equivalent `cfbs` subcommands, usable from anywhere inside a cfbs project. | ||
|
|
||
| ```bash | ||
| # Search the build-index for a module | ||
| cfengine search promise-type-git | ||
|
|
||
| # Add module(s) to the current cfbs project | ||
| cfengine add promise-type-git | ||
|
|
||
| # Set/update input.json for a module that takes input | ||
| cfengine input promise-type-git | ||
|
|
||
| # Remove module(s) from the current cfbs project | ||
| cfengine remove promise-type-git | ||
|
|
||
| # Update the current cfbs project (or specific modules) | ||
| cfengine update | ||
| cfengine update promise-type-git | ||
|
|
||
| # Show status of the current cfbs project | ||
| cfengine moduleinfo | ||
|
|
||
| # Show info about specific module(s) (does not require being inside a project) | ||
| cfengine moduleinfo promise-type-git | ||
| ``` | ||
|
|
||
| ## Building and deploying policy sets | ||
|
|
||
| ```bash | ||
| # Build the policy set from a cfbs project (equivalent to `cfbs build`) | ||
| cfengine build | ||
|
|
||
| # build -> deploy -> run on the given hub without extra prompts | ||
| cfengine build --hub myhub --non-interactive | ||
|
|
||
| # Deploy an already-built policy set to a hub | ||
| cfengine deploy --hub myhub | ||
| ``` | ||
|
|
||
| ## Running the CFEngine agent | ||
|
|
||
| ```bash | ||
| # Default: cf-agent -KIf update.cf && cf-agent -KIf | ||
| # If there is a local installation, this will be used | ||
| cfengine run | ||
|
|
||
| # Run a specific policy file (resolved locally, or uploaded if not found remotely) | ||
| cfengine run /tmp/some_policy.cf | ||
|
|
||
| # Run against a specific saved host, instead of being prompted | ||
| cfengine run --host myhub | ||
|
|
||
| # Chain multiple commands, executed in sequence | ||
| cfengine run /tmp/some_policy.cf /tmp/other_policy.cf | ||
| ``` | ||
|
|
||
| ## Initializing new projects | ||
|
|
||
| ```bash | ||
| # Build project on top of the default masterfiles (default, same as `cfbs init`) | ||
| cfengine init --policy-set | ||
|
|
||
| # Initialize an example build project for working on a custom promise type (python) | ||
| cfengine init --promise-type | ||
|
|
||
| # Initialize an exapmlte module project for build.cfengine.com (or internal use) | ||
| cfengine init --policy-module | ||
|
|
||
| # Initialize an example policy module that takes input data | ||
| cfengine init --policy-module --with-input | ||
|
|
||
| # Skip interactive prompts | ||
| cfengine init --promise-module --non-interactive | ||
| ``` | ||
|
|
||
| ## Formatting and linting | ||
|
|
||
| ```bash | ||
| cfengine format | ||
| cfengine lint | ||
| cfengine lint main.cf | ||
| ``` | ||
|
|
||
| ## Reporting | ||
|
|
||
| ```bash | ||
| # Refresh reporting data on all known hubs/clients (capped at 25 hosts), optional flag to run agent first. | ||
| cfengine report [--run-agent] | ||
|
|
||
| # Only refresh a specific hub (and its clients, capped at 25), running the agent first | ||
| cfengine report --hub myhub --run-agent | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| See [README.md](./README.md) for installation and general usage, and [HACKING.md](./HACKING.md) for | ||
| contributing/development info. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the whole point with CFEngine CLI that it should not be used in scripts? I feel options like
--non-interactivekind of works against that. Do we already have these options for other sub commands?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for most commands, only init and for build/deploy. I added them as niceties when testing a module, that way I could just do
cfengine build --host HOST --non-interactiveand wait for output rather than pressing enter every 5 seconds.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider
for arguments that are only for our tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant testing as in using. They way it would work without is that you would build, prompt if you want to deploy, then prompt if you want to run. But when working on a module/policy-set you would probably want to just fast-forward this and read the output after the full pipeline.