Page MenuHomeDevCentral

Configure CARP on routers
ClosedPublic

Authored by yousra on Mon, Mar 2, 15:52.
Tags
None
Referenced Files
F24884750: D3986.id10372.diff
Sun, Mar 15, 20:18
F24876871: D3986.id10416.diff
Sun, Mar 15, 06:37
F24875595: D3986.id10416.diff
Sun, Mar 15, 05:12
Unknown Object (File)
Sat, Mar 14, 19:14
Unknown Object (File)
Sat, Mar 14, 18:18
Unknown Object (File)
Sat, Mar 14, 18:10
Unknown Object (File)
Sat, Mar 14, 13:13
Unknown Object (File)
Sat, Mar 14, 12:05
Subscribers
None

Details

Summary

Add router CARP configuration using Jinja template and Salt state to deploy with Salt the CARP configuration.

Ref T2264

Test Plan

Apply state on router-002 and router-003 and verify CARP alias is configured.

Diff Detail

Repository
rOPS Nasqueron Operations
Lint
Lint Skipped
Unit
No Test Coverage
Branch
role-router
Build Status
Buildable 6433
Build 6717: arc lint + arc unit

Event Timeline

yousra requested review of this revision.Mon, Mar 2, 15:52
yousra created this revision.

Using a separate file like /etc/rc.conf.d/netif/carp keeps the CARP configuration isolated,
avoids modifying the main /etc/rc.conf, and makes the setup cleaner and safer.
It improves maintainability, reduces the risk of conflicts, and ensures a more modular infrastructure design.

dereckson edited the test plan for this revision. (Show Details)
dereckson retitled this revision from Add CARP configuration in role/router/carp/carp.sls to Add CARP configuration.
dereckson retitled this revision from Add CARP configuration to Configure CARP on routers.

Configuration logic. Looks good to me.

Style: tiny bits of styling comments to help to maintain the configuration.

roles/router/carp/carp.jinja
6 ↗(On Diff #10340)
  • Move this file to a subdirectory
  • Perhaps we can use "carp.rc" as filename, so we know it's to configure rc? .jinja extension is only useful to avoid linters on .sh .py etc. to analyse jinja templates as shell script or Python script. For configuration file, that's a problem we don't have
  • Add here the path to that file

Example of header:

# Source file: roles/router/carp/files/carp.rc

(so source_path won't be useful, as (1) currently, we can focus on FreeBSD-only for CARP implementation (2) other OS would have received another configuration file as source, so it would have received the source from that file)

9 ↗(On Diff #10340)

You can merge the two blocks.

23 ↗(On Diff #10340)

ops/secrets/ is addded automatically by credentials.get_password (that's the prefix shared by all the secrets provisioned through Salt).

29 ↗(On Diff #10340)

Extra blank line, you can use pre-commit (make in your repository) to catch them.

roles/router/carp/carp.sls
8

One extra line

Added some changes :

  • no "ops/secrets/" because it is the prefixe for secrets that salt knows
  • no extrat blank line
  • Source file: roles/router/carp/files/carp.rc
  • carp.jinja ==> carp.rc into a new subfolder /files

Changed the source path in carp.sls into : source: salt://roles/router/carp/files/carp.rc

Fix : we need to use context to call the function get_carp_entries on carp.sls
in place of calling this function on the template carp.rc

OK, nice work, ready.

We now need to indicate to Salt how to find carp unit if we do salt router-002 state.apply roles/router or salt router-002 state.highstate.

To include router role in the highstate
Declare the two new nodes in top.sls, and add router role there.

To fix router role logic

Include logic is currently:
(1) For roles/router, it reads roles/router/init.sls -> OK
(2) In roles/router/init.sls, it includes carp -> it will try to go in carp/init.sls

If you rename roles/router/carp/carp.sls to roles/router/carp/init.sls that works.

(If you needed a more complex logic, you could have created roles/router/carp/init.sls and do an include there, but for one file, init is enough.)

vmx0 is not always releated to the network intranought, so I add entry["interface_name"] = interface_name
in output of get_carp_entries(), so then in carp.rc the prefixe is based on that.

Add routers on top.sls to be able to do a command like sudo salt 'router-002' state.apply roles/router

We must then fix role routeur logic by renaming roles/router/carp/carp.sls to roles/router/carp/init.sls that works.

Include logic is currently:
(1) For roles/router, it reads roles/router/init.sls -> OK
(2) In roles/router/init.sls, it includes carp -> it will try to go in carp/init.sls

The alphabetical order in top.sls must be respected.

This revision is now accepted and ready to land.Thu, Mar 12, 12:43
This revision was automatically updated to reflect the committed changes.