From 75839c4b13b681f7a226156327f7422616f4ad17 Mon Sep 17 00:00:00 2001 From: Jibin Bao Date: Sat, 18 Oct 2025 09:34:12 +0800 Subject: [PATCH] Align the deploy script for smartswitch dark mode (#20415) * Align the deploy script with community for smartswitch dark mode * fix issue deploy_mg issue We don't need to handle the parameters for the Ansible playbook individually; they can be passed to Ansible as a whole using $@. --- ansible/config_sonic_basedon_testbed.yml | 12 +++++++++--- ansible/library/generate_golden_config_db.py | 7 +++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index 1055299f80e..c9a17a04d70 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -61,6 +61,11 @@ set_fact: topo: "{{ testbed_facts['topo'] }}" + - name: set default light mode + set_fact: + is_light_mode: false + when: topo in ["t1-smartswitch-ha","t1-28-lag","smartswitch-t1", "t1-48-lag"] and is_light_mode is not defined + - name: set ptf image name set_fact: ptf_image: "{{ testbed_facts['ptf_image_name'] }}" @@ -624,7 +629,7 @@ dest=/tmp/smartswitch.json become: true # t1-28-lag is smartswitch topo only - when: topo in ["t1-smartswitch-ha","t1-28-lag","smartswitch-t1", "t1-48-lag"] + when: topo in ["t1-smartswitch-ha","t1-28-lag","smartswitch-t1", "t1-48-lag"] and is_light_mode|bool == true - name: Create dns config template: src=templates/dns_config.j2 @@ -636,6 +641,7 @@ topo_name: "{{ topo }}" port_index_map: "{{ port_index_map | default({}) }}" hwsku: "{{ hwsku }}" + is_light_mode: "{{ is_light_mode | default(true) }}" become: true - name: Copy macsec profile json to dut @@ -803,7 +809,7 @@ dest=/tmp/dpu_extra.json become: true # t1-28-lag is smartswitch topo only - when: topo in ["t1-smartswitch-ha","t1-28-lag","smartswitch-t1", "t1-48-lag"] + when: topo in ["t1-smartswitch-ha","t1-28-lag","smartswitch-t1", "t1-48-lag"] and is_light_mode|bool == true - name: Load DPU config in smartswitch load_extra_dpu_config: @@ -812,7 +818,7 @@ host_passwords: "{{ sonic_default_passwords }}" become: true # t1-28-lag is smartswitch topo only - when: topo in ["t1-smartswitch-ha","t1-28-lag","smartswitch-t1", "t1-48-lag"] + when: topo in ["t1-smartswitch-ha","t1-28-lag","smartswitch-t1", "t1-48-lag"] and is_light_mode|bool == true - name: Configure TACACS become: true diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index 86dbd2bd1af..f422657cbb7 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -57,13 +57,15 @@ def __init__(self): port_index_map=dict(require=False, type='dict', default=None), macsec_profile=dict(require=False, type='str', default=None), num_asics=dict(require=False, type='int', default=1), - hwsku=dict(require=False, type='str', default=None)), + hwsku=dict(require=False, type='str', default=None), + is_light_mode=dict(require=False, type='bool', default=False)), supports_check_mode=True) self.topo_name = self.module.params['topo_name'] self.port_index_map = self.module.params['port_index_map'] self.macsec_profile = self.module.params['macsec_profile'] self.num_asics = self.module.params['num_asics'] self.hwsku = self.module.params['hwsku'] + self.is_light_mode = self.module.params['is_light_mode'] def generate_mgfx_golden_config_db(self): rc, out, err = self.module.run_command("sonic-cfggen -H -m -j /etc/sonic/init_cfg.json --print-data") @@ -406,7 +408,8 @@ def generate(self): config = self.generate_mgfx_golden_config_db() module_msg = module_msg + " for mgfx" self.module.run_command("sudo rm -f {}".format(TEMP_DHCP_SERVER_CONFIG_PATH)) - elif self.topo_name in ["t1-smartswitch-ha", "t1-28-lag", "smartswitch-t1", "t1-48-lag"]: + elif self.topo_name in ["t1-smartswitch-ha", "t1-28-lag", "smartswitch-t1", "t1-48-lag"] \ + and self.is_light_mode: config = self.generate_smartswitch_golden_config_db() module_msg = module_msg + " for smartswitch" self.module.run_command("sudo rm -f {}".format(TEMP_SMARTSWITCH_CONFIG_PATH))