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

cannot use with networking.hostFiles #302

Open
aca opened this issue Nov 30, 2024 · 3 comments
Open

cannot use with networking.hostFiles #302

aca opened this issue Nov 30, 2024 · 3 comments

Comments

@aca
Copy link

aca commented Nov 30, 2024

age.secrets."hosts" = { file = ./secrets/hosts.age; mode = "777"; };
networking.hostFiles = [config.age.secrets."hosts".path];

Hi,
I'm trying to use this with networking.hostFiles which creates /etc/hosts by concatenating files.
It says file is not found with agenix encrypted file. Seems like file is not decrypted while evaluating networking.hostFiles. Is there any workaround for this?

@aca aca changed the title cannot use as networking.hostFiles cannot use with networking.hostFiles Nov 30, 2024
@aca
Copy link
Author

aca commented Dec 5, 2024

This hack worked for me. But hope I could get some help to understand what's going on.

  system.activationScripts."homelabhosts" = ''
    cat /etc/hosts > /etc/hosts.bak
    rm /etc/hosts
    cat /etc/hosts.bak "${config.age.secrets."homelabhosts".path}" >> /etc/hosts
  '';

@bytehaufen
Copy link

I currently have the same problem. I tried your way, and all is correctly written to /etc/hosts, but the added hosts are fully ignored by the system. I think the evaluation of the hosts is not done from /etc/hosts`.

Is there a workaround for that?

@bytehaufen
Copy link

My fault, the user ssh has no rights for /etc/hosts. So i added chmod 644 /etc/hosts to the activation script.

I do not like this approach, it feels so dirty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants