Best Practices for Bulk Deployment of DataKit¶
Environment Information¶
Name | Environment |
---|---|
Centos | 7.6 |
Ansible | 2.10.4 |
Host IP | 10.200.14.56; 10.200.14.57; 10.200.14.63 |
Note: Only supports Linux hosts
Deploy Ansible¶
Install Ansible¶
Log in to the server 10.200.14.56 and execute the installation command
Configure Ansible¶
Edit the Ansible hosts file
Add the list of hosts and user/password
[all]
10.200.14.56 ansible_ssh_user=root ansible_ssh_pass=xxx
10.200.14.57 ansible_ssh_user=root ansible_ssh_pass=xxx
10.200.14.63 ansible_ssh_user=root ansible_ssh_pass=xxx
Disable Connection Prompt¶
Verify Configuration¶
10.200.14.57 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" } 10.200.14.56 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" } 10.200.14.63 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" } |
---|
Bulk Deployment¶
Configure PlayBook¶
Get Command¶
Click on the [Integration] module, top right corner [Quickly Get DataKit Installation Command], choose the appropriate [Datakit Installation Command] based on your operating system and system type.
Create YAML File¶
Enter the Ansible directory
Create a new file
Add the following content (copy the previous [Datakit Installation Command])
- hosts: all
remote_user: root
tasks:
- name: judge datakit is exits
shell: ls /usr/local/datakit/conf.d
ignore_errors: True
register: result
- name: install datakit
shell: [Datakit Installation Command]
when: result.rc != 0
Execute YAML File¶
*** Requires server access to the public network ***
PLAY [all] ************************************************************************ ************************************************************************ ************************************************************************ ******************************************* TASK [Gathering Facts] ************************************************************************ ************************************************************************ ************************************************************************ ******************************* ok: [10.200.14.57] ok: [10.200.14.56] ok: [10.200.14.63] PLAY RECAP ************************************************************************ ************************************************************************ ************************************************************************ ******************************************* 10.200.14.56 : ok=2 changed=1 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0 10.200.14.57 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=1 10.200.14.63 : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=1 |
---|
Verify Information¶
Click on the [Infrastructure] module, [Hosts] to view the list of all hosts that have installed DataKit along with basic information.
Bulk Upgrade¶
Create YAML File¶
Enter the Ansible directory
Create a new file
Add the following content
- hosts: all
remote_user: root
tasks:
- name: judge datakit is exits
shell: ls /usr/local/datakit/conf.d
ignore_errors: True
register: result
- name: install datakit
shell: sudo -- sh -c "curl https://static.guance.com/datakit/installer-linux-amd64 -o dk-installer && chmod +x ./dk-installer && ./dk-installer -upgrade && rm -rf ./dk installer"
when: result.rc == 0
Execute YAML File¶
Verify Information¶
Click on the [Infrastructure] module, use quick filter conditions to select the latest [DataKit Version]
Bulk Synchronization¶
Create YAML File¶
Enter the Ansible directory
Create a new file
Add the following content
- hosts: all
remote_user: root
tasks:
- name: judge datakit is exit
shell: ls /usr/local/datakit/conf.d
ignore_errors: True
register: result
- name: judge /usr/bin/rsync is exits
shell: ls /usr/bin/rsync
ignore_errors: True
register: result
- name: install rsync
shell: yum -y install rsync
when: result.rc != 0
- name: Synchronize passing in extra rsync options
synchronize:
src: /usr/local/datakit/conf.d/
dest: /usr/local/datakit/conf.d/
rsync_opts:
- "--exclude=datakit.conf"
checksum: true
register: res
- debug: var=res.stdout_lines
- debug: var=res.changed
- name: reload datakit
shell: systemctl restart datakit
when: res.changed == true
Execute YAML File¶
Verify Information¶
All hosts will apply the same DataKit configuration (conf.d directory). If encountering customized server configurations, you can use the DataKit whitelist feature.