From 13eb434fc34ba27589ccdfd2c5214b463e2adf8d Mon Sep 17 00:00:00 2001 From: fumingwei Date: Thu, 17 Jun 2021 10:33:38 +0800 Subject: [PATCH] =?UTF-8?q?7400=20adapt:=E4=BF=AE=E6=94=B9tsg-os-provision?= =?UTF-8?q?=20role=E7=94=A8=E6=9D=A5=E9=80=82=E9=85=8Dtsg=207400?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../provision_tsg7400_firewall.yml | 115 ++++++++++++++++++ .../provision_tsg7400_proxy.yml | 48 ++++++++ .../provision_tsg9140.yml | 113 +++++++++++++++++ .../files/tsg-os-provision/files/.gitkeep | 0 .../tsg-os-provision/provision.yml.sample | 20 ++- .../tsg-os-provision/tasks/provision.yml | 107 +--------------- ansible/roles/tsg-os-provision/tasks/main.yml | 21 ++++ 7 files changed, 319 insertions(+), 105 deletions(-) create mode 100644 ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg7400_firewall.yml create mode 100644 ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg7400_proxy.yml create mode 100644 ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg9140.yml create mode 100644 ansible/roles/tsg-os-provision/files/tsg-os-provision/files/.gitkeep diff --git a/ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg7400_firewall.yml b/ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg7400_firewall.yml new file mode 100644 index 00000000..5afa5e72 --- /dev/null +++ b/ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg7400_firewall.yml @@ -0,0 +1,115 @@ +--- +- hosts: provision + vars_files: + - '{{var_files_path}}' + tasks: + - name: "tsg-os-provision: Template the asymmetric_presence_layer.conf.j2" + template: + src: ../templates/asymmetric_presence_layer.conf.j2 + dest: /home/mesasoft/sapp_run/etc/asymmetric_presence_layer.conf + tags: sapp + + - name: "tsg-os-provision: Template the conflist.inf" + template: + src: ../templates/conflist.inf.j2 + dest: /home/mesasoft/sapp_run/plug/conflist.inf + tags: sapp + + - name: "tsg-os-provision: necessary_plug_list.conf" + template: + src: ../templates/necessary_plug_list.conf.j2 + dest: /home/mesasoft/sapp_run/etc/necessary_plug_list.conf + tags: sapp + + - name: "tsg-os-provision: vlan_flipping_map.conf" + template: + src: ../templates/vlan_flipping_map.conf.j2 + dest: /home/mesasoft/sapp_run/etc/vlan_flipping_map.conf + tags: sapp + + - name: "tsg-os-provision: template gdev.conf file" + template: + src: "../templates/gdev.conf.j2" + dest: /home/mesasoft/sapp_run/etc/gdev.conf + tags: sapp + + - name: "tsg-os-provision: template mrglobal.conf file" + template: + src: "../templates/mrglobal.conf.j2" + dest: /opt/mrzcpd/etc/mrglobal.conf + tags: mrzcpd + + - name: "tsg-os-provision: template certstore configure file" + template: + src: "../templates/cert_store.ini.j2" + dest: /opt/tsg/certstore/conf/cert_store.ini + tags: certstore + + - name: "tsg-os-provision: Template the tsgconf/main.conf" + template: + src: "../templates/main.conf.j2" + dest: /home/mesasoft/sapp_run/tsgconf/main.conf + tags: firewall + + - name: "tsg-os-provision: Template the tsgconf/maat.conf" + template: + src: "../templates/maat.conf.j2" + dest: /home/mesasoft/sapp_run/tsgconf/maat.conf + tags: firewall + + - name: "tsg-os-provision: Template the conf/capture_packet_plug.conf" + template: + src: "../templates/capture_packet_plug.conf.j2" + dest: /home/mesasoft/sapp_run/conf/capture_packet_plug.conf + tags: firewall + + - name: "tsg-os-provision: Template the sapp.toml" + template: + src: "../templates/sapp.toml.j2" + dest: /home/mesasoft/sapp_run/etc/sapp.toml + tags: sapp + + - name: "tsg-os-provision: Templates telegraf.conf" + template: + src: "../templates/telegraf_statistic.conf.j2" + dest: /etc/telegraf/telegraf_statistic.conf + tags: telegraf_statistic + + - name: "mkdir /opt/tsg/etc/" + file: + path: /opt/tsg/etc + state: directory + + - name: "tsg-os-provision: obtain sn from mxn and write sn to tsg_sn.json" + shell: /opt/tsg/tsg-os-provision/tsg7400_obtain_sn_from_mxn.sh + register: result_exec_obtain_sn_and_write_sn_in_file + + - name: "tsg-os-provision: check result_exec_obtain_sn_and_write_sn_in_file" + assert: + that: + - result_exec_obtain_keepalive_subnet.rc == 0 + - result_exec_obtain_keepalive_subnet.failed == False + fail_msg: "error:{{ result_exec_obtain_keepalive_subnet.stderr }},stdout:{{ result_exec_obtain_keepalive_subnet.stdout_lines }}" + success_msg: "Successded: obtain the sn from mxn and write sn into tsg_sn.json" + + - name: "tsg-os-provision: template the tsg_device_tag" + template: + src: "../templates/tsg_device_tag.json.j2" + dest: /opt/tsg/etc/tsg_device_tag.json + tags: tsg_device_tag + + - name: "Template the maat-redis.conf" + template: + src: "/opt/tsg/tsg-os-provision/templates/gdev.conf.j2" + dest: /etc/maat-redis.conf + tags: maat-redis + + + - name: 'tsg-os-provision: execute command - systemctl daemon-reload' + systemd: + daemon_reload: yes + + - name: "tsg-os-provision: snapshot the stage2 config files" + copy: + src: /data/tsg-os-provision/provision.yml + dest: /data/tsg-os-provision/provision.yml.snapshot diff --git a/ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg7400_proxy.yml b/ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg7400_proxy.yml new file mode 100644 index 00000000..d0a579d2 --- /dev/null +++ b/ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg7400_proxy.yml @@ -0,0 +1,48 @@ +--- +- hosts: provision + vars_files: + - '{{var_files_path}}' + tasks: + - name: "mkdir /opt/tsg/etc/" + file: + path: /opt/tsg/etc + state: directory + + - name: "tsg-os-provision: obtain sn from mxn and write sn to tsg_sn.json" + shell: /opt/tsg/tsg-os-provision/tsg7400_obtain_sn_from_mxn.sh + register: result_exec_obtain_sn_and_write_sn_in_file + + - name: "tsg-os-provision: check result_exec_obtain_sn_and_write_sn_in_file" + assert: + that: + - result_exec_obtain_keepalive_subnet.rc == 0 + - result_exec_obtain_keepalive_subnet.failed == False + fail_msg: "error:{{ result_exec_obtain_keepalive_subnet.stderr }},stdout:{{ result_exec_obtain_keepalive_subnet.stdout_lines }}" + success_msg: "Successded: obtain the sn from mxn and write sn into tsg_sn.json" + + - name: "tsg-os-provision: template the tsg_device_tag" + template: + src: "../templates/tsg_device_tag.json.j2" + dest: /opt/tsg/etc/tsg_device_tag.json + tags: tsg_device_tag + + - name: "tsg-os-provision: template the tfe.conf" + template: + src: "../templates/tfe.conf.j2" + dest: /opt/tsg/tfe/conf/tfe/tfe.conf + tags: tfe + + - name: "tsg-os-provision: template the pangu_pxy.conf" + template: + src: "../templates/pangu_pxy.conf.j2" + dest: /opt/tsg/tfe/conf/pangu/pangu_pxy.conf + tags: tfe + + - name: 'tsg-os-provision: execute command - systemctl daemon-reload' + systemd: + daemon_reload: yes + + - name: "tsg-os-provision: snapshot the stage2 config files" + copy: + src: /data/tsg-os-provision/provision.yml + dest: /data/tsg-os-provision/provision.yml.snapshot diff --git a/ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg9140.yml b/ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg9140.yml new file mode 100644 index 00000000..d264d4d1 --- /dev/null +++ b/ansible/roles/tsg-os-provision/files/provision_tasks_files/provision_tsg9140.yml @@ -0,0 +1,113 @@ +--- +- hosts: provision + vars_files: + - '{{var_files_path}}' + tasks: + - name: "tsg-os-provision: obtain result_exec_obtain_keepalive_subnet" + shell: ipmitool picmg addrinfo | grep "Hardware Address" | sed 's/^Hardware Address.*0x4\(.*\)/\1/' | awk '{print strtonum("0x"$1)+16'} + register: result_exec_obtain_keepalive_subnet + + - name: "tsg-os-provision: output results that executes command that gets the result_exec_obtain_keepalive_subnet" + debug: + msg: "{{ result_exec_obtain_keepalive_subnet }}" + + - name: "tsg-os-provision: check result_exec_obtain_keepalive_subnet" + assert: + that: + - result_exec_obtain_keepalive_subnet.rc == 0 + - result_exec_obtain_keepalive_subnet.failed == False + - result_exec_obtain_keepalive_subnet.stdout_lines | length == 1 + - result_exec_obtain_keepalive_subnet.stdout_lines[0] | int >= 16 + - result_exec_obtain_keepalive_subnet.stdout_lines[0] | int <= 31 + fail_msg: "error:{{ result_exec_obtain_keepalive_subnet.stderr }},stdout:{{ result_exec_obtain_keepalive_subnet.stdout_lines }}" + success_msg: "{{ result_exec_obtain_keepalive_subnet.stdout_lines[0] }}" + + - name: "tsg-os-provision: Set fact for field keepalive_subnet_ip" + set_fact: + keepalive_subnet_ip: "{{ result_exec_obtain_keepalive_subnet.stdout_lines[0] }}" + + - name: "tsg-os-provision: template gdev.conf file" + template: + src: "../templates/gdev.conf.j2" + dest: /home/mesasoft/sapp_run/etc/gdev.conf + tags: sapp + + - name: "tsg-os-provision: template mrglobal.conf file" + template: + src: "../templates/mrglobal.conf.j2" + dest: /opt/mrzcpd/etc/mrglobal.conf + tags: mrzcpd + + - name: "tsg-os-provision: template certstore configure file" + template: + src: "../templates/cert_store.ini.j2" + dest: /opt/tsg/certstore/conf/cert_store.ini + tags: certstore + + - name: "tsg-os-provision: Template the tsgconf/main.conf" + template: + src: "../templates/main.conf.j2" + dest: /home/mesasoft/sapp_run/tsgconf/main.conf + tags: firewall + + - name: "tsg-os-provision: Template the tsgconf/maat.conf" + template: + src: "../templates/maat.conf.j2" + dest: /home/mesasoft/sapp_run/tsgconf/maat.conf + tags: firewall + + - name: "tsg-os-provision: Template the conf/capture_packet_plug.conf" + template: + src: "../templates/capture_packet_plug.conf.j2" + dest: /home/mesasoft/sapp_run/conf/capture_packet_plug.conf + tags: firewall + + - name: "tsg-os-provision: Template the sapp.toml" + template: + src: "../templates/sapp.toml.j2" + dest: /home/mesasoft/sapp_run/etc/sapp.toml + tags: sapp + + - name: "tsg-os-provision: Templates telegraf.conf" + template: + src: "../templates/telegraf_statistic.conf.j2" + dest: /etc/telegraf/telegraf_statistic.conf + tags: telegraf_statistic + + - name: "tsg-os-provision: template the tfe.conf" + template: + src: "../templates/tfe.conf.j2" + dest: /opt/tsg/tfe/conf/tfe/tfe.conf + tags: tfe + + - name: "tsg-os-provision: template the pangu_pxy.conf" + template: + src: "../templates/pangu_pxy.conf.j2" + dest: /opt/tsg/tfe/conf/pangu/pangu_pxy.conf + tags: tfe + + - name: "mkdir /opt/tsg/etc/" + file: + path: /opt/tsg/etc + state: directory + + - name: "tsg-os-provision: template the tsg_device_tag" + template: + src: "../templates/tsg_device_tag.json.j2" + dest: /opt/tsg/etc/tsg_device_tag.json + tags: tsg_device_tag + + - name: "tsg-os-provision: template the tsg_sn" + template: + src: "../templates/tsg_sn.json.j2" + dest: /opt/tsg/etc/tsg_sn.json + tags: tsg_sn + + - name: 'tsg-os-provision: execute command - systemctl daemon-reload' + systemd: + daemon_reload: yes + + - name: "tsg-os-provision: snapshot the stage2 config files" + copy: + src: /data/tsg-os-provision/provision.yml + dest: /data/tsg-os-provision/provision.yml.snapshot diff --git a/ansible/roles/tsg-os-provision/files/tsg-os-provision/files/.gitkeep b/ansible/roles/tsg-os-provision/files/tsg-os-provision/files/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/ansible/roles/tsg-os-provision/files/tsg-os-provision/provision.yml.sample b/ansible/roles/tsg-os-provision/files/tsg-os-provision/provision.yml.sample index ead85fac..06372c44 100644 --- a/ansible/roles/tsg-os-provision/files/tsg-os-provision/provision.yml.sample +++ b/ansible/roles/tsg-os-provision/files/tsg-os-provision/provision.yml.sample @@ -34,4 +34,22 @@ pangu_pxy: address: "10.9.62.253" port: 9090 -tsg_sn: "CBT2201925000002" \ No newline at end of file +tsg_sn: "CBT2201925000002" + +# NPB_device value in [inline_device, tera] +NPB_device: inline_device + +access_vlan_id_list: + - 1000 + - 1001 + +keep_alive: 127.0.0.1 + + +inline_device_config: + keepalive_ip: 127.0.0.1 + eepalive_mask: 255.255.255.0 + +maat_redis_city_server: + address: "10.4.62.253" + port: 7002 \ No newline at end of file diff --git a/ansible/roles/tsg-os-provision/files/tsg-os-provision/tasks/provision.yml b/ansible/roles/tsg-os-provision/files/tsg-os-provision/tasks/provision.yml index 1566d47c..6f22073c 100644 --- a/ansible/roles/tsg-os-provision/files/tsg-os-provision/tasks/provision.yml +++ b/ansible/roles/tsg-os-provision/files/tsg-os-provision/tasks/provision.yml @@ -3,107 +3,6 @@ vars_files: - '{{var_files_path}}' tasks: - - name: "tsg-os-provision: obtain result_exec_obtain_keepalive_subnet" - shell: ipmitool picmg addrinfo | grep "Hardware Address" | sed 's/^Hardware Address.*0x4\(.*\)/\1/' | awk '{print strtonum("0x"$1)+16'} - register: result_exec_obtain_keepalive_subnet - - - name: "tsg-os-provision: output results that executes command that gets the result_exec_obtain_keepalive_subnet" - debug: - msg: "{{ result_exec_obtain_keepalive_subnet }}" - - - name: "tsg-os-provision: check result_exec_obtain_keepalive_subnet" - assert: - that: - - result_exec_obtain_keepalive_subnet.rc == 0 - - result_exec_obtain_keepalive_subnet.failed == False - - result_exec_obtain_keepalive_subnet.stdout_lines | length == 1 - - result_exec_obtain_keepalive_subnet.stdout_lines[0] | int >= 16 - - result_exec_obtain_keepalive_subnet.stdout_lines[0] | int <= 31 - fail_msg: "error:{{ result_exec_obtain_keepalive_subnet.stderr }},stdout:{{ result_exec_obtain_keepalive_subnet.stdout_lines }}" - success_msg: "{{ result_exec_obtain_keepalive_subnet.stdout_lines[0] }}" - - - name: "tsg-os-provision: Set fact for field keepalive_subnet_ip" - set_fact: - keepalive_subnet_ip: "{{ result_exec_obtain_keepalive_subnet.stdout_lines[0] }}" - - - name: "tsg-os-provision: template gdev.conf file" - template: - src: "../templates/gdev.conf.j2" - dest: /home/mesasoft/sapp_run/etc/gdev.conf - tags: sapp - - - name: "tsg-os-provision: template mrglobal.conf file" - template: - src: "../templates/mrglobal.conf.j2" - dest: /opt/mrzcpd/etc/mrglobal.conf - tags: mrzcpd - - - name: "tsg-os-provision: template certstore configure file" - template: - src: "../templates/cert_store.ini.j2" - dest: /opt/tsg/certstore/conf/cert_store.ini - tags: certstore - - - name: "tsg-os-provision: Template the tsgconf/main.conf" - template: - src: "../templates/main.conf.j2" - dest: /home/mesasoft/sapp_run/tsgconf/main.conf - tags: firewall - - - name: "tsg-os-provision: Template the tsgconf/maat.conf" - template: - src: "../templates/maat.conf.j2" - dest: /home/mesasoft/sapp_run/tsgconf/maat.conf - tags: firewall - - - name: "tsg-os-provision: Template the conf/capture_packet_plug.conf" - template: - src: "../templates/capture_packet_plug.conf.j2" - dest: /home/mesasoft/sapp_run/conf/capture_packet_plug.conf - tags: firewall - - - name: "tsg-os-provision: Template the sapp.toml" - template: - src: "../templates/sapp.toml.j2" - dest: /home/mesasoft/sapp_run/etc/sapp.toml - tags: sapp - - - name: "tsg-os-provision: Templates telegraf.conf" - template: - src: "../templates/telegraf_statistic.conf.j2" - dest: /etc/telegraf/telegraf_statistic.conf - tags: telegraf_statistic - - - name: "tsg-os-provision: template the tfe.conf" - template: - src: "../templates/tfe.conf.j2" - dest: /opt/tsg/tfe/conf/tfe/tfe.conf - tags: tfe - - - name: "tsg-os-provision: template the pangu_pxy.conf" - template: - src: "../templates/pangu_pxy.conf.j2" - dest: /opt/tsg/tfe/conf/pangu/pangu_pxy.conf - tags: tfe - - - name: "mkdir /opt/tsg/etc/" - file: - path: /opt/tsg/etc - state: directory - - - name: "tsg-os-provision: template the tsg_device_tag" - template: - src: "../templates/tsg_device_tag.json.j2" - dest: /opt/tsg/etc/tsg_device_tag.json - tags: tsg_device_tag - - - name: "tsg-os-provision: template the tsg_sn" - template: - src: "../templates/tsg_sn.json.j2" - dest: /opt/tsg/etc/tsg_sn.json - tags: tsg_sn - - - name: "tsg-os-provision: snapshot the stage2 config files" - copy: - src: /data/tsg-os-provision/provision.yml - dest: /data/tsg-os-provision/provision.yml.snapshot + - name: "tsg-os-provision: Nothing to do, exit error code" + fail: + msg: "Error: There are nothing to do,maybe some errors occurred during the os-building..." \ No newline at end of file diff --git a/ansible/roles/tsg-os-provision/tasks/main.yml b/ansible/roles/tsg-os-provision/tasks/main.yml index f6cc2e7a..0d596f29 100644 --- a/ansible/roles/tsg-os-provision/tasks/main.yml +++ b/ansible/roles/tsg-os-provision/tasks/main.yml @@ -4,6 +4,27 @@ dest: /opt/tsg/ mode: 0644 +- name: "tsg-os-provision: copy tasks file that excutes provision to dest - tsg9140" + copy: + src: "{{ role_path }}/files/provision_tasks_files/provision_tsg9140.yml" + dest: /opt/tsg/tsg-os-provision/tasks/provision.yml + mode: 0644 + when: PROFILE_ID == '9000-NPB-P01R01' + +- name: "tsg-os-provision: copy tasks file that excutes provision to dest - tsg7400 mcn0" + copy: + src: "{{ role_path }}/files/provision_tasks_files/provision_tsg7400_firewall.yml" + dest: /opt/tsg/tsg-os-provision/tasks/provision.yml + mode: 0644 + when: PROFILE_ID == '7400-MCN0-P01R01' + +- name: "tsg-os-provision: copy tasks file that excutes provision to dest - tsg7400 mcn1 mcn2 mcn3" + copy: + src: "{{ role_path }}/files/provision_tasks_files/provision_tsg7400_proxy.yml" + dest: /opt/tsg/tsg-os-provision/tasks/provision.yml + mode: 0644 + when: PROFILE_ID == '7400-MCN123-P01R01' + - name: "tsg-os-provision: copy tsg-os-provision-convertor.service file to dest" copy: src: "{{ role_path }}/files/tsg-os-provision-convertor.service"