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
Config.includes not picked up when client repacking #657
Comments
Hey Omar, I played with this a bit and everything works as expected for me. If I add the context for Platform:Darwin to my grr-server.yaml, I get the expected Config.includes in the resulting client installer. The tempfile is a red herring. We create the config that goes into the template by writing to a temp directory and reading it back. Before I look more into this, can you make sure that other changes are properly propagated to the client? You could for example change the Client.company_name and see if that changes anything? One other thing I noticed, you mentioned this issue end of December (sorry for the wait to pick up on it :)) but your client shows a deploy time (==time of repacking) of November 1st. Could it be that you are looking at some old client installer? |
I just reran repacking inside of a container:
This is the a snippet from
And then tried to install the resultant pkg:
|
Seems like the configuration file is not being changed by the client packing process?
|
I think we went away from versioned directories. The correct path should be something like /usr/local/lib/grr/grr.yaml |
|
I might be doing something wrong.
|
Can you try to unzip your grr_3.2.4.3_amd64_docker.pkg? Should have build.yaml and config.yaml. |
|
And deploy time is current? Can you try changing one of the other options that are definitely copied to that config and repack again? |
Deploy time is not current. I tried changing client name and company but no change is picked up. Does config updater not use the -p or --secondary_configs flags? Should I be repacking with a different command? |
hm maybe it doesn't use the secondary config? I put the changes into grr-server.yaml directly. However, regardless of what options the config updater uses, the deploy time will always be the current timestamp. I can't really see a case where the file timestamp is current but the deploy timestamp is not? What you can also do is use grr_client_build, for example like grr_client_build repack --template env/grr-response-templates/templates/grr_3.2.4.6_amd64.rpm.zip --output_dir /tmp/out |
I overlooked the full I modified Client.name: omar
Client.company_name: omars-company
Platform:Darwin:
Client.name: omar-darwin-test
Config.includes:
- "/etc/%(Client.name).labels.yaml"
- build.yaml And then ran $GRR_VENV/bin/grr_config_updater \
--secondary_configs /etc/grr/server.local.yaml \
-p Logging.verbose=True \
-p Client.executable_signing_public_key="$CLIENT_EXECUTABLE_SIGNING_PUBLIC_KEY" \
-p CA.certificate="$CA_CERTIFICATE" \
-p Client.server_urls="http://$CLIENT_PACKING_FRONTEND_HOST:$FRONTEND_SERVER_PORT/" \
repack_clients Which produces
So clearly
So you can see the zipped So I then installed the
|
Since your client name has changed, you need to adjust the path to the yaml too. I'll try to do the same steps and see what happens. |
Which path? |
Wherever it says grr in "/usr/local/lib/grr/grr_3.2.4.3_amd64/grr.yaml" it will now be omar-darwin-test or omar. |
This is from my mac after installing the latest .pkg. Checking the
Checking for any other config files
Contents of config file
|
I managed to reproduce with the commands you sent now. It works for me with a secondary config containing: Target:Darwin: but wouldn't using Platform:Darwin: as the context. Does that work for you? I think there is a conflict between the options, grr-server.yaml already has Target:Darwin: and then the config system can't determine which one to use since they have same depth. I'll fix this tomorrow by making build.yaml the default and removing that entry from the grr-server.yaml. |
I tried rebuilding with But when installling the Are you able to see your changes after installing? |
Ok I understand now what's going on, this is all quite complicated :/ The grr.yaml is not supposed to change, it just copies this template from the installer and uses it as a base config. All your custom options come in /usr/local/lib/grr/grr_3.2.4.6_amd64/installer_config.yaml and then get written to the writeback file immediately - /etc/grr.local.yaml. This, however probably doesn't work in your case either because the installer is a bit stricter than the client when opening configs and raises since it doesn't find the file you point it at. In case the installer fails, it will write a file /var/log/grr_installer.txt, you might see the corresponding backtrace in there. To solve this, we could of course make the installer a bit more lenient when parsing the config but that might cause bugs later on. Is all you want to set custom Client.labels based on a file? What you can do then is: $ cat /etc/labels.txt config: IN [2]: config.CONFIG["Client.labels"] |
I would like each client machine that is using this GRR client installer to be able to specify its own labels via a file at install/deploy time. That way each machine can segregate itself, and I don't have to anticipate, and repack clients with custom labels for every deploy. I tried setting:
But this is being interpolated at repacking time, requiring the frontend to have this file exist, and is being evaluated as "Client.labels: Null" for the final client configuration at Can I tell it not to interpolate this value during repacking and just save it as is? |
I then tried: Client Context:
Target:Darwin:
Client.labels: "%(/etc/grr-labels.txt|file)", and Client Context:
Platform:Darwin:
Client.labels: "%(/etc/grr-labels.txt|file)", and then having a After both repacking attempts, I unzipped the .pkg, and check the I then installed the .pkg, and checked the |
I tried with
This doesn't appear to be the case with version 3.2.4.3 of grr.
I checked this and you're right. When I run the installer without having a file
So before I run installation, I create Client.labels:
- omar-label I then reran the installer, and then
So far so good. Lets see what Config.includes:
- /etc/%(Client.name).labels.yaml
Client.labels: null
... Yay! The includes made it in, but for some reason I then manually edited
So I double check I think at this point it's become a configuration context problem again. Any ideas? We're so close! |
Ok I found an somewhat unrelated issue that would overwrite your labels. We have a few options that we always want to persist to the grr.local.yaml:
The bug is that we assume that those options are always set in the main config (or not at all). In your case, it would take the unset main config and overwrite the custom config with it - hence the null in Yaml which is a Python None. 76dfefd fixes this bug, if you could try with a template after that commit, it should work now. I also added an optionalfile config filter that will not raise if it can't find the file given. This is slightly dangerous since it will hide some errors but it should make this labeling process a bit easier. |
Thanks, I'll try and install from source in a container. I would really appreciate a docker release including this if it's not too much hassle! 🙏 |
It looks like the travis osx build has been failing. Does this matter? |
Hm the error looks unrelated, some homebrew issue. We'll have a look what's going on there. |
I just pulled down the latest container and tried to do a client repack with grr_config_updater. It seems like requirements weren't updated?
|
Workaround provided here |
Your fixes worked! I can see my labels in Thanks for looking into this! |
I’m trying to let clients add labels via files. This is part of the config for my frontends that are doing the client repacking:
But when installing the mac .pkg, the
Config.includes
is never picked up:The repacking is using the right contexts and is picking up
Config.includes
, but I have no idea where/tmp/tmpZFFwpY/grr.yaml
is coming from. Maybe it comes from the pre-baked OSX template?The text was updated successfully, but these errors were encountered: