💻업무 내용
🔧사용한 기술
📜프로젝트 설명
배경 : SaltStack을 가지고 수동으로 여러 노드에 배포를 하게될때 SaltStack의 기본 Output을 가지고 변경사항을 확인하기가 쉽지않음
목적 : SaltStack의 Output 출력 결과를 간결하게 정리하는 script 작성
AS-IS (노드 단위의 출력 - 동일한 변경사항(task)이 각개별 노드 마다 중복되서 출력) - 기본 saltstack output
node2:
----------
ID: grafana-server
Function: file.managed
Name: /etc/grafana/provisioning/dashboards/dashboard.yml
Result: None
Comment: The file /etc/grafana/provisioning/dashboards/dashboard.yml is set to be changed
Note: No changes made, actual changes may
be different due to other states.
Started: 14:18:49.774240
Duration: 290.103 ms
Changes:
----------
newfile:
/etc/grafana/provisioning/dashboards/dashboard.yml
Summary for node2
------------
Succeeded: 1 (unchanged=1, changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 290.103 ms
node1:
----------
ID: grafana-server
Function: file.managed
Name: /etc/grafana/provisioning/dashboards/dashboard.yml
Result: None
Comment: The file /etc/grafana/provisioning/dashboards/dashboard.yml is set to be changed
Note: No changes made, actual changes may
be different due to other states.
Started: 14:18:50.005310
Duration: 196.772 ms
Changes:
----------
newfile:
/etc/grafana/provisioning/dashboards/dashboard.yml
Summary for node1
------------
Succeeded: 1 (unchanged=1, changed=1)
Failed: 0
------------
Total states run: 1
Total run time: 196.772 ms
node3:
...
node4:
...
TO-BE (작업 단위 - 동일한 변경사항인 노드를 묶어서 보여준다) - script를 이용해 아래와 같이 개선
------------
ID: grafana-server
Function: file.managed
Name: /etc/grafana/provisioning/dashboards/dashboard.yml
Targets: ['node1', 'node2', 'node3', 'node4']
TargetCnt: 4
changes-1
Result: None
Comment: The file /etc/grafana/provisioning/dashboards/dashboard.yml is set to be changed
Note: No changes made, actual changes may
be different due to other states.
Changes:
----------
newfile:
/etc/grafana/provisioning/dashboards/dashboard.yml
hostnames: ['node1', 'node2', 'node3', 'node4']
hostnamesCnt: 4
------------
ID: ...
👏 해결하고자한점/노력한점
Hash Table algorithm 아이디어 적용
file_|-grafana-server_|-/etc/grafana/provisioning/dashboards/dashboard.yml_|-managed
task에 대해서 node1, node2를 하나의 해시코드(키) 아래에 저장할 수 있음{
"node2": {
"file_|-grafana-server_|-/etc/grafana/provisioning/dashboards/dashboard.yml_|-managed": {
"changes": {
"newfile": "/etc/grafana/provisioning/dashboards/dashboard.yml"
},
"comment": "The file /etc/grafana/provisioning/dashboards/dashboard.yml is set to be changed\\nNote: No changes made, actual changes may\\nbe different due to other states.",
"name": "/etc/grafana/provisioning/dashboards/dashboard.yml",
"result": null,
//"__sls__": "common.file",
//"__run_num__": 0,
//"start_time": "14:20:11.975597",
//"duration": 188.36,
//"__id__": "grafana-server"
}
}
}
{
"node1": {
"file_|-grafana-server_|-/etc/grafana/provisioning/dashboards/dashboard.yml_|-managed": {
"changes": {
"newfile": "/etc/grafana/provisioning/dashboards/dashboard.yml"
},
"comment": "The file /etc/grafana/provisioning/dashboards/dashboard.yml is set to be changed\\nNote: No changes made, actual changes may\\nbe different due to other states.",
"name": "/etc/grafana/provisioning/dashboards/dashboard.yml",
"result": null,
//"__sls__": "common.file",
//"__run_num__": 0,
//"start_time": "14:20:11.931397",
//"duration": 267.603,
//"__id__": "grafana-server"
}
}
}
개선전 - 노드 단위의 출력의 경우 노드수(n)*작업수(m) 의 내용이 출력돼서 노드가 많아지게 되면 변경사항이 다른 특정 몇노드를 찾기가 매우 어려움
개선후 - 작업 단위의 출력의 경우 작업수(m)의 내용이 출력되고 변경사항이 다른 특정 노드를 찾기가 쉬움