Skip to content

Commit

Permalink
Configure and enable core uploader (#1522)
Browse files Browse the repository at this point in the history
* If core-storage secret key is available, add to /etc/sonic/core_analyzer.rc.json and enable & start core_uploader service
If https_proxy is provided, update /etc/sonic/core_analyzer.rc.json.

* Check the entire dict path before de-referencing.

* Improved regex per comments.

* Fixed syntax error.

* Add a sample file for newly introduced ansible facts.wq

* Removed a redundant empty line.

Co-authored-by: Ubuntu <remanava@remanava-kube-1.hblknyhzkmnujibhxvn3dmavjb.xx.internal.cloudapp.net>
  • Loading branch information
2 people authored and yxieca committed Apr 8, 2020
1 parent a1cc3a5 commit e3d1946
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ansible/config_sonic_basedon_testbed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,49 @@
become: true
when: stat_result.stat.exists is defined and stat_result.stat.exists

- name: Init account key and proxy
set_fact:
core_key: ""
core_proxy: ""

- name: read account key
set_fact:
core_key: "{{ corefile_uploader['azure_sonic_core_storage']['account_key'] }}"
when: corefile_uploader['azure_sonic_core_storage']['account_key'] is defined

- name: read https proxy
set_fact:
core_proxy: "{{ corefile_uploader['env']['https_proxy'] }}"
when: corefile_uploader['env']['https_proxy'] is defined

- name: Put secret in core_analyzer.rc.json
lineinfile:
name: /etc/sonic/core_analyzer.rc.json
regexp: '(^.*)account_key'
line: '\1account_key": "{{ core_key }}",'
backrefs: yes
become: true
when: core_key != ""

- name: Put https-proxy in core_analyzer.rc.json
lineinfile:
name: /etc/sonic/core_analyzer.rc.json
regexp: '(^.*)https_proxy'
line: '\1https_proxy": "{{ core_proxy }}"'
backrefs: yes
become: true
when: core_proxy != ""

- name: enable core uploader service
become: true
command: systemctl enable core_uploader.service
when: core_key != ""

- name: start core uploader service
become: true
command: systemctl start core_uploader.service
when: core_key != ""

- name: Replace snmp community string
lineinfile:
name: /etc/sonic/snmp.yml
Expand Down
7 changes: 7 additions & 0 deletions ansible/group_vars/all/corefile_uploader.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Configure core file storage secret key and https-proxy as required
#
#corefile_uploader:
# azure_sonic_core_storage:
# account_key: "Your Secret"
# env:
# https_proxy: "http://10.10.10.10:8000"

0 comments on commit e3d1946

Please sign in to comment.