Conditional File Include

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Conditional File Include

Norman Elton
We keep our DHCP configuration in a git repository. In the case of
failover pairs, they share a repository. This works great, since the
vast majority of the configuration is identical.

Of course, the failover configuration is different between the two
servers. To solve this, my dhcpd.conf file does an include on
"dhcp-failover.conf", which doesn't actually exist in the repository.
Instead, it's a symlink to either "dhcp-failover-01.conf" or
"dhcp-failover-02.conf". This works, but I have to manually create the
symlink when we check out the repository.

Not the end of the world, but it would be much smoother to say:

include "dhcp-failover-${HOSTNAME}"

So that the dhcpd.conf file automatically points to the correct
failover config file.

Is there any way to include a variable in an included path name? Or
conditionally include a file?

Thanks!

Norman Elton
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Conditional File Include

Bob Harold

On Mon, Aug 7, 2017 at 8:34 AM, Norman Elton <[hidden email]> wrote:
We keep our DHCP configuration in a git repository. In the case of
failover pairs, they share a repository. This works great, since the
vast majority of the configuration is identical.

Of course, the failover configuration is different between the two
servers. To solve this, my dhcpd.conf file does an include on
"dhcp-failover.conf", which doesn't actually exist in the repository.
Instead, it's a symlink to either "dhcp-failover-01.conf" or
"dhcp-failover-02.conf". This works, but I have to manually create the
symlink when we check out the repository.

Not the end of the world, but it would be much smoother to say:

include "dhcp-failover-${HOSTNAME}"

So that the dhcpd.conf file automatically points to the correct
failover config file.

Is there any way to include a variable in an included path name? Or
conditionally include a file?

Thanks!

Norman Elton

git has a ".gitignore" file where you can list files and directories to be ignored.  Try listing the symlink file in .gitignore.

Otherwise, I would just put the symlink somewhere outside the directories controlled by git.

-- 
Bob Harold
 

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Conditional File Include

Norman Elton
Bob,

Sorry, I'm actually .gitignoring the symlink already. I was hoping to
figure out a way to avoid needing the symlink to begin with. It's not
a huge deal, just a little kludgey. My fear is that someone restoring
the server after some sort of catastrophe might not be checking my
readme file, and struggling to get the server back online.

Thanks!

Norman

On Mon, Aug 7, 2017 at 9:36 AM, Bob Harold <[hidden email]> wrote:

>
> On Mon, Aug 7, 2017 at 8:34 AM, Norman Elton <[hidden email]> wrote:
>>
>> We keep our DHCP configuration in a git repository. In the case of
>> failover pairs, they share a repository. This works great, since the
>> vast majority of the configuration is identical.
>>
>> Of course, the failover configuration is different between the two
>> servers. To solve this, my dhcpd.conf file does an include on
>> "dhcp-failover.conf", which doesn't actually exist in the repository.
>> Instead, it's a symlink to either "dhcp-failover-01.conf" or
>> "dhcp-failover-02.conf". This works, but I have to manually create the
>> symlink when we check out the repository.
>>
>> Not the end of the world, but it would be much smoother to say:
>>
>> include "dhcp-failover-${HOSTNAME}"
>>
>> So that the dhcpd.conf file automatically points to the correct
>> failover config file.
>>
>> Is there any way to include a variable in an included path name? Or
>> conditionally include a file?
>>
>> Thanks!
>>
>> Norman Elton
>
>
> git has a ".gitignore" file where you can list files and directories to be
> ignored.  Try listing the symlink file in .gitignore.
>
> Otherwise, I would just put the symlink somewhere outside the directories
> controlled by git.
>
> --
> Bob Harold
>
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Conditional File Include

Matthew Kassawara
Norman,

Did you consider using some sort of configuration management or dynamic templating tool (such as consul-template) to change configuration directives on the fly depending on the role (primary/secondary) of the particular DHCP server?

Matt

On Mon, Aug 7, 2017 at 7:53 AM, Norman Elton <[hidden email]> wrote:
Bob,

Sorry, I'm actually .gitignoring the symlink already. I was hoping to
figure out a way to avoid needing the symlink to begin with. It's not
a huge deal, just a little kludgey. My fear is that someone restoring
the server after some sort of catastrophe might not be checking my
readme file, and struggling to get the server back online.

Thanks!

Norman

On Mon, Aug 7, 2017 at 9:36 AM, Bob Harold <[hidden email]> wrote:
>
> On Mon, Aug 7, 2017 at 8:34 AM, Norman Elton <[hidden email]> wrote:
>>
>> We keep our DHCP configuration in a git repository. In the case of
>> failover pairs, they share a repository. This works great, since the
>> vast majority of the configuration is identical.
>>
>> Of course, the failover configuration is different between the two
>> servers. To solve this, my dhcpd.conf file does an include on
>> "dhcp-failover.conf", which doesn't actually exist in the repository.
>> Instead, it's a symlink to either "dhcp-failover-01.conf" or
>> "dhcp-failover-02.conf". This works, but I have to manually create the
>> symlink when we check out the repository.
>>
>> Not the end of the world, but it would be much smoother to say:
>>
>> include "dhcp-failover-${HOSTNAME}"
>>
>> So that the dhcpd.conf file automatically points to the correct
>> failover config file.
>>
>> Is there any way to include a variable in an included path name? Or
>> conditionally include a file?
>>
>> Thanks!
>>
>> Norman Elton
>
>
> git has a ".gitignore" file where you can list files and directories to be
> ignored.  Try listing the symlink file in .gitignore.
>
> Otherwise, I would just put the symlink somewhere outside the directories
> controlled by git.
>
> --
> Bob Harold
>
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Conditional File Include

Eugene Grosbein
In reply to this post by Norman Elton
07.08.2017 19:34, Norman Elton wrote:

> We keep our DHCP configuration in a git repository. In the case of
> failover pairs, they share a repository. This works great, since the
> vast majority of the configuration is identical.
>
> Of course, the failover configuration is different between the two
> servers. To solve this, my dhcpd.conf file does an include on
> "dhcp-failover.conf", which doesn't actually exist in the repository.
> Instead, it's a symlink to either "dhcp-failover-01.conf" or
> "dhcp-failover-02.conf". This works, but I have to manually create the
> symlink when we check out the repository.

Why do you include different contents to main dhcpd.conf?

Just put all identical configuration to single included file
and include it to two distinct dhcpd.conf's each having own "failover peer"
statements and, perhaps, something other like "subnet".

And make your DHCP servers use such distinct dhcpd.conf's
Nothing makes you always use "dhcpd.conf", you may use any name
and just run the daemon with corresponding "-cf config-file" flag.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Conditional File Include

Simon Hobson
Eugene Grosbein <[hidden email]> wrote:

> Just put all identical configuration to single included file
> and include it to two distinct dhcpd.conf's each having own "failover peer"
> statements and, perhaps, something other like "subnet".

I suspect the reason is that it moves some of the config outside of the management process. While it works, it means that the config is now split in 3 places - while the aim was to keep it in one place (with tracking of changes etc).

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Conditional File Include

Eugene Grosbein
08.08.2017 3:23, Simon Hobson wrote:

> Eugene Grosbein <[hidden email]> wrote:
>
>> Just put all identical configuration to single included file
>> and include it to two distinct dhcpd.conf's each having own "failover peer"
>> statements and, perhaps, something other like "subnet".
>
> I suspect the reason is that it moves some of the config outside of the management process.

I don't see how that would occur.

> While it works, it means that the config is now split in 3 places -
> while the aim was to keep it in one place (with tracking of changes etc).

One cannot keep failover configs in one place without some kind of preprocessing.

And every part of config is still kept in one of 3 single places,
either in common part or in one of individual parts.

It just works.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Conditional File Include

Norman Elton
Yes, the goal is to keep all the configuration centralized. And a
templating mechanism would work, but adds a bit of complexity that
we've, so far, managed to avoid. Perhaps it's inevitable.

>> Just put all identical configuration to single included file
>> and include it to two distinct dhcpd.conf's each having own "failover peer"
>> statements and, perhaps, something other like "subnet".

Each system only has one /etc/dhcpd.conf, which is where I'd like to
include a host-specific file that defines the failover configuration.
But that single top-level file would need to be stored in the
repository.

Perhaps the /etc/init.d/dhcpd startup script could be modified to
point to a host-specific main config file
(/etc/dhcpd-<hostname>.conf). That's an option. Again, it's a
balancing act of introducing complexity in one place to avoid
complexity in another.

Thanks all for the ideas,

Norman





On Tue, Aug 8, 2017 at 3:56 AM, Eugene Grosbein <[hidden email]> wrote:

> 08.08.2017 3:23, Simon Hobson wrote:
>
>> Eugene Grosbein <[hidden email]> wrote:
>>
>>> Just put all identical configuration to single included file
>>> and include it to two distinct dhcpd.conf's each having own "failover peer"
>>> statements and, perhaps, something other like "subnet".
>>
>> I suspect the reason is that it moves some of the config outside of the management process.
>
> I don't see how that would occur.
>
>> While it works, it means that the config is now split in 3 places -
>> while the aim was to keep it in one place (with tracking of changes etc).
>
> One cannot keep failover configs in one place without some kind of preprocessing.
>
> And every part of config is still kept in one of 3 single places,
> either in common part or in one of individual parts.
>
> It just works.
>
> _______________________________________________
> dhcp-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/dhcp-users
_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users