Hi guys.

I'm trying to use the "delegate_to", to only run a certain task to a group
in my inventory.

inventory file:
[zabbixprimary]
localhost ansible_port=2235 # zabbix primary

[zabbixslave]
localhost ansible_port=2236 # zabbix secondary

[zabbix:children]
zabbixprimary
zabbixslave

main.yml:
- name: Setup Zabbix and Grafana
hosts: zabbix
become: yes
become_user: root
gather_facts: False

task.yml:
- name: Enable Zabbix HA - primary
run_once: true
ansible.builtin.shell: sed -i 's/# HANodeName=/HANodeName={{
hostname_secondary }}/g' /etc/zabbix/zabbix_server.conf && sed -i 's/#
NodeAddress=localhost:10051/NodeAddress={{ hostname_primary }}:10051/g'
/etc/zabbix/zabbix_server.conf
when: not ansible_check_mode and zabbix_ha
delegate_to: zabbixprimary

- name: Enable Zabbix HA - secondary
run_once: true
ansible.builtin.shell: sed -i 's/# NodeAddress=localhost:10051/NodeAddress=
{{ hostname_secondary }}:10051/g' /etc/zabbix/zabbix_server.conf
when: not ansible_check_mode and zabbix_ha
delegate_to: zabbixslave

But I get an error:
fatal: [localhost -> zabbixprimary]: UNREACHABLE! => {"changed": false,
"msg": "Failed to connect to the host via ssh: ssh: Could not resolve
hostname zabbixprimary: nodename nor servname provided, or not known",
"unreachable": true}

Am i doing it right? I couldn't find much information online about how to
achieve this.

Thanks!
Lucas

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAE_gQfX4H1WOx3Hy%2BSY3j4zw89FEyMoxd-4ijSF0qOXLbpDFSg%40mail.gmail.com.

Reply via email to