Ansible Script 추가
This commit is contained in:
56
ansible/01_old/roles/zabbix-agent/tasks/Windows_conf.yml
Normal file
56
ansible/01_old/roles/zabbix-agent/tasks/Windows_conf.yml
Normal file
@@ -0,0 +1,56 @@
|
||||
---
|
||||
- name: "Set default ip address for zabbix_agent_ip"
|
||||
ansible.builtin.set_fact:
|
||||
zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_ip_addresses'] | ansible.utils.ipv4 | first }}"
|
||||
when:
|
||||
- zabbix_agent_ip is not defined
|
||||
- "'ansible_ip_addresses' in hostvars[inventory_hostname]"
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: "Windows | Configure zabbix-agent"
|
||||
ansible.windows.win_template:
|
||||
src: "{{ zabbix_win_config_name }}.j2"
|
||||
dest: "{{ zabbix_win_install_dir_conf }}\\{{ zabbix_win_config_name }}"
|
||||
notify: restart win zabbix agent
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: "Windows | Set service startup mode to auto, ensure it is started and set auto-recovery"
|
||||
ansible.windows.win_service:
|
||||
name: "{{ zabbix_win_svc_name }}"
|
||||
start_mode: auto
|
||||
state: started
|
||||
failure_actions:
|
||||
- type: restart
|
||||
delay_ms: 5000
|
||||
- type: restart
|
||||
delay_ms: 10000
|
||||
- type: restart
|
||||
delay_ms: 20000
|
||||
failure_reset_period_sec: 86400
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: "Windows | Check firewall service"
|
||||
ansible.windows.win_service_info:
|
||||
name: MpsSvc
|
||||
register: firewall_info
|
||||
when: zabbix_win_firewall_management
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: "Windows | Firewall rule"
|
||||
community.windows.win_firewall_rule:
|
||||
name: "{{ zabbix_win_svc_name }}"
|
||||
localport: "{{ zabbix_agent_listenport }}"
|
||||
action: allow
|
||||
direction: in
|
||||
protocol: tcp
|
||||
state: present
|
||||
enabled: true
|
||||
when:
|
||||
- zabbix_win_firewall_management
|
||||
- firewall_info.services[0].state == 'started' or firewall_info.services[0].start_mode == 'auto'
|
||||
tags:
|
||||
- config
|
||||
Reference in New Issue
Block a user