Replies: 2 comments 3 replies
-
@t3mcvay Hello, thanks for opening a discussion and good question; I asssume your policy (on disk) is a fork of the MPF? We are working on some features to make this transition easier, but one thing to consider is that we want Git submodulesA submodule is one mechanism to achieve this. The "normal" way would be to put your dependency (the classic policy set) somewhere on a git server, can be GitHub private repo, on-prem instance of GitLab, or something else. You can then add that URL as a git submodule:
Since you mentioned not using something like GitHub, instead using local files, it is also possible to use local file paths, but due to security aspects, you will have to explicitly enable submodules via local filesystem paths;
Warning: I wouldn't generally recommend doing this - especially if it's your main work machine where you might git clone some projects and then run a Dockerfile from that project for example. That opens you up to the project referencing some local files via paths and then those being transferred to the docker container running potentially untrusted code. Other similar scenarios exist. For how to work with git submodules, I'd use the official documentation: https://git-scm.com/book/en/v2/Git-Tools-Submodules After you've added the submodule, the last part would be adding the module / editing the Copying in the files explicitlyThe other option would be to copy in the files, with something like rsync;
(Edit the rsync command with the right path and feel free to exclude more things). UpdatingWith this rsync setup, this is how you'd update from the local path:
For convenience, you can add these commands to an alias, or shell script, if you like. CFEngine Build project / Build stepsWhether you're using rsync or git submodules, you can edit the {
"name": "Example project",
"description": "Example description",
"type": "policy-set",
"git": true,
"build": [
{
"name": "./masterfiles/",
"description": "Our old masterfiles folder added as a module, synced using rsync",
"tags": ["local"],
"added_by": "cfbs add",
"steps": ["copy ./ ./"]
}
]
} Or, if your masterfiles repo requires running some script (like {
"name": "Example project",
"description": "Example description",
"type": "policy-set",
"git": true,
"build": [
{
"name": "./masterfiles/",
"description": "Our old masterfiles folder added as a module, synced using rsync",
"tags": ["local"],
"added_by": "cfbs add",
"steps": ["run ./prepare.sh -y", "copy ./ ./"]
}
]
} Note: Ensure the rsync command is copying what is needed for your script to run. What's next?We're adding new commands and features to make this nicer for you. Hopefully the workarounds above can work, and we'll release new commands in cfbs soon which will make this easier for you. When you have a working project, you can use the cfbs tooling and start adding modules from build.cfengine.com. We also recommend you start working towards splitting your classic masterfiles into 2, one part which you maintain (your custom policy files and modifications), and one part which we maintain (the original, versioned, MPF). |
Beta Was this translation helpful? Give feedback.
-
Hello @olehermanse Thanks for the quick reply. No, your initial assumption is incorrect. We have a long history with CFengine (way back to an early 2.X version). We've been carrying that initial custom policy along to now, and do not have any version of the MPF in our CM repo. That 'old' policy works OK with CFengine 3 (currently working with 3.10). But, we think it's time to at least see if incorporating some version of the MPF is feasible at this point. The current thought is to migrate (1-by-1) our existing policy into the equivalent custom policy (as I understand right now, which would fit under ./services/). Also -- if something like the submodules example you so kindly provided could be used we could not have a URL as many of our deployed systems are airgapped and we literally just use policy stored in a local repo to administer and setup hosts on a network. Also I should mention that we have developed (over the years) tools to assist in administering this (such as dynamic generation of things like sudoers, and other custom configurations per host depending upon their function), and that needs to continue as that allows us to write fairly generic policy which will work across a variety of network and security postures. |
Beta Was this translation helpful? Give feedback.
-
I'm starting to learn how to migrate existing CFengine policy to a cfbs managed set. Our policy repo is a local git repo on disk, and we have a use case/need to NOT make it accessible via something like github. Is it possible to have a local git repo on disk and then have 'cfbs add /path/to/local/policy' actually be able to recognize that /path/to/local/policy is actually a local repo?
Beta Was this translation helpful? Give feedback.
All reactions