-
Notifications
You must be signed in to change notification settings - Fork 19
Design cf-remote config #165
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
Open
victormlg
wants to merge
3
commits into
cfengine:master
Choose a base branch
from
victormlg:vm-config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,85 @@ | ||
| # Idempotent VM spawning config | ||
|
|
||
| ## Idempotency: | ||
| The user defines a desired state in the form of a config in yaml, and cf-remote makes it a reality. | ||
| If run against an existing environment, it detects changes and 'repairs' the current state using the configuration. | ||
|
|
||
| ## Example | ||
|
|
||
| ```yml | ||
| templates: | ||
| ubuntu-vm: | ||
| provider: | ||
| name: aws | ||
| aws: | ||
| image: ubuntu-24 | ||
|
|
||
| centos7: | ||
| provider: | ||
| name: vagrant | ||
| vagrant: | ||
| box: generic/centos7 | ||
|
|
||
| groups: | ||
| - myhub: | ||
| role: hub | ||
| count: 1 | ||
| spawn-config: ubuntu-vm | ||
| cfengine: 3.24.3 | ||
| scripts: [ ./script.sh ] | ||
|
|
||
| - myclient: | ||
| role: client | ||
| count: 3 | ||
| bootstrap: myhub | ||
| spawn-config: centos7 | ||
| cfengine: 3.24.3 | ||
|
|
||
| - other: | ||
| role: client | ||
| hosts: [ ubuntu@1.1.1.1 ] | ||
| bootstrap: myhub | ||
| cfengine: 3.24.3 | ||
| ``` | ||
|
|
||
| ### Spawning | ||
|
|
||
| ```bash | ||
| cf-remote up config.yaml | ||
| ``` | ||
|
|
||
| Example output. myclient is already spawned from a previous run. | ||
| ``` | ||
| Checking current state... | ||
| Checking 'myhub'... Changes detected. Enabling repair | ||
| Spawning: 'ubuntu-24' on 'aws' provider... OK | ||
| Installing: 'cfengine-nova-hub_3.27.0-1.ubuntu24_amd64.deb' on 'ubuntu@34.244.25.232'... OK | ||
| Running: './script.sh' on 'ubuntu@34.244.25.232'... OK | ||
| Checking 'myclient'... No Changes detected. OK | ||
| Checking 'other'... Changes detected. Enabling repair | ||
| Hosts: adding 'ubuntu@1.1.1.1' to 'other'... OK | ||
| Installing: 'cfengine-nova-client_3.27.0-1.ubuntu24_amd64.deb' on 'ubuntu@1.1.1.1'... OK | ||
| Bootstrapping: '1.1.1.1' -> '172.31.23.220'... OK | ||
| Details about the current state can be found in /home/user/.cfengine/cf-remote/cloud_state.json | ||
| ``` | ||
|
|
||
| ### Destroying | ||
|
|
||
| ```bash | ||
| cf-remote destroy config.yaml | ||
| ``` | ||
|
|
||
| # Algorithm | ||
|
|
||
| 1. Resolve templates in config | ||
| 2. Validate resolved config using `schema` library | ||
| 3. Load old state (cloud_state.json) | ||
| 4. Transform validated config (new state) into same format as old state | ||
| 5. Compute diffs between old state and new state. Return a list of tuple (path, before, after) | ||
| 6. Map diffs to Change object containing the type of change (ex: install), the status (ex: pending) and the dependencies (vm must be already spawned) | ||
| 7. schedule the list of change objects with topological sort or other algorithm and run each change using cf-remote's commands | ||
| 8. save new state to cloud_state.json | ||
|
|
||
| # Future features | ||
|
|
||
| - inlining (being able to split config in smaller subtrees) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.