Page MenuHomeDevCentral

Add debug scripts for Vault, OVH, and VIP assignment
Needs ReviewPublic

Authored by yousra on Tue, Mar 31, 21:25.
Tags
None
Referenced Files
F25869684: D4034.id10543.diff
Sat, Apr 18, 19:04
F25792763: D4034.diff
Sat, Apr 18, 08:10
Unknown Object (File)
Thu, Apr 16, 05:33
Unknown Object (File)
Wed, Apr 15, 09:55
Unknown Object (File)
Tue, Apr 14, 11:29
Unknown Object (File)
Tue, Apr 14, 11:22
Unknown Object (File)
Tue, Apr 14, 09:15
Unknown Object (File)
Tue, Apr 14, 08:23

Details

Summary

Add some useful debug scripts for Vault access, OVH credentials access and client setup, and VIP assignment checks

  • debug_connection_vault.py
  • debug_vault_ovh_credentials.py
  • debug_check_vip_ovh.py
Test Plan

On /usr/local/libexec/carp :

  • sudo python3 debug_connection_vault.py : to verify Vault connection
  • sudo python3 debug_vault_ovh_credentials.py : to verify that we can access to OVH credentials and create ovh client
  • sudo python3 debug_check_vip_ovh.py : to check which router MAC currently holds the VIP on OVH

Diff Detail

Repository
rOPS Nasqueron Operations
Lint
Lint Skipped
Unit
No Test Coverage
Branch
arcpatch-D4034
Build Status
Buildable 6640
Build 6926: arc lint + arc unit

Event Timeline

yousra requested review of this revision.Tue, Mar 31, 21:25
yousra created this revision.
roles/router/carp/files/debug_check_vip_ovh.py
23

Should be provisioned by Salt.

We've two strategies for that.

(1) older strategy was to templatize Python scripts, ie treat this as Jinja templates

(2) newer strategy is usually to provision a YAML template with Salt, and keep this as a pure Python script reading that YAML

I've checked, PyYAML is installed on router role, so second strategy works:

dereckson in 🌐 router-002 in ~ 
❯ python3
Python 3.11.14 (main, Feb  7 2026, 01:06:44) [Clang 19.1.7 (https://github.com/llvm/llvm-project.git llvmorg-19.1.7-0-gcd7080 on freebsd15
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>>
roles/router/carp/init.sls
44

Don't put .py prefix

Put everything in {{ dirs.bin }}/ directly. That's the convention on UNIX machines.

Minor changes to the script names in init.sls

yousra edited the test plan for this revision. (Show Details)
yousra edited the test plan for this revision. (Show Details)

Many changes:

  • Improved scripts structure by separating configuration, helper functions, main function and entry point.
  • Set correct permissions (not 0 in front and string (like '0644') for Salt (more like 644), only on Ansible) for the debug scripts.
  • Executable files do not require extensions on Unix systems, as execution is determined by the shebang.
  • Using a YAML file (method PyYAML) to get the value of VAULT_CONFIG (created on D4033)
dereckson requested changes to this revision.Sat, Apr 18, 16:41
dereckson added inline comments.
roles/router/carp/files/debug_check_vip_ovh
1 ↗(On Diff #10569)
32 ↗(On Diff #10569)

Apply black to format Python

Also, it could be easier to maintain if we DIRECTLY use the config dictionary in the code: that way, we know where in the configuration file that variable is set.

51 ↗(On Diff #10569)

secret could be in config too

roles/router/carp/init.sls
43
  • Python files should have a .py extension in the repository (but not on the server), so they can be properly linted
  • if we've 3 scripts to deploy we can use a for loop
{% for script in ["debug_check_vip_ovh", ...] %}
/usr/local/libexec/carp/{{ script }}:
  file.managed:
    - source: salt://roles/router/carp/files/{{ script }}.py
    - makedirs: True
    - mode: 755
This revision now requires changes to proceed.Sat, Apr 18, 16:41

So to clarify for executable scripts files:

  • in Salt, we put the extension: .sh, .php, .py, .tcl, etc.
  • on the server, we provision without the extension
  • use /usr/bin/env python3 shebang
  • use config dictionary directly instead of intermediate variables
  • rename scripts to .py in repository
  • refactor init.sls to use a loop for script deployment