write a ansible playbook for search on zabbix server and find a server has not a zabbix…
- User
write a ansible playbook for search on zabbix server and find a server has not a zabbix agent and check the server redhat or ubuntu and install a zabbix agent and set 10.1.10.39 to zabbix config in line server and line serveractive and set a system.hostname in line HostnameItem
- Assistant
-
name: Install Zabbix Agent on servers missing it hosts: zabbix_server gather_facts: false tasks:
-
name: Search for servers missing Zabbix agent command: "zabbix_get -s localhost -k agent.ping | grep -Ev '1' | awk '{print 1}'" register: missing_agents changed_when: false
-
name: Install Zabbix agent on missing servers shell: "yum install zabbix-agent -y" when: inventory_hostname in missing_agents.stdout_lines and ansible_distribution == 'RedHat' become: true
-
name: Install Zabbix agent on missing servers shell: "apt install zabbix-agent -y" when: inventory_hostname in missing_agents.stdout_lines and ansible_distribution == 'Ubuntu' become: true
-
-
- User
write a ansible playbook for search on zabbix server and find a server has not a zabbix agent and check the server redhat or ubuntu and install a zabbix agent and set 10.1.10.39 to zabbix config in line server and line serveractive and set a system.hostname in line HostnameItem
- Assistant
-
name: Install Zabbix Agent on servers missing it hosts: zabbix_server gather_facts: false vars: zabbix_agent_ip: "10.1.10.39" zabbix_agent_config_path: "/etc/zabbix/zabbix_agentd.conf" zabbix_agent_service: "zabbix-agent"
tasks:
-
name: Search for servers missing Zabbix agent command: "zabbix_get -s localhost -k agent.ping | grep -Ev '1' | awk '{print 1}'" register: missing_agents changed_when: false
-
name: Install Zabbix agent on missing Red Hat servers yum: name: zabbix-agent state: present when: inventory_hostname in missing_agents.stdout_lines and ansible_distribution == 'RedHat' become: true
-
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.