On Wed, 15 Dec 2021 16:30:40 +1300
Lucas Possamai <drum.lu...@gmail.com> wrote:

> On Wed, 15 Dec 2021 at 16:03, Lucas Possamai <drum.lu...@gmail.com> wrote:
> >>
> >> inventory file:
> >> [zabbixprimary]
> >> localhost ansible_port=2235 # zabbix primary
> >>
> >> [zabbixslave]
> >> localhost ansible_port=2236 # zabbix secondary
> >>
> >> [zabbix:children]
> >> zabbixprimary
> >> zabbixslave
> >>
> >> - name: Enable Zabbix HA - primary
> >>   ansible.builtin.shell: sed -i 's/# HANodeName=/HANodeName={{
> >>   ...
> >>   delegate_to: zabbixprimary
> >>
> >> 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}

It's not possible to delegate a task to a group. Delegate to a host
instead. Change the inventory. For example

  shell> cat hosts
  zabbixprimary ansible_host=localhost ansible_port=2235
  zabbixslave ansible_host=localhost ansible_port=2236

  [zabbix]
  zabbixprimary
  zabbixslave

You should be able to delegate to the hosts. For example

  - hosts: zabbix
    tasks:
      - shell: echo OK
        delegate_to: zabbixprimary
        run_once: true
      - shell: echo OK
        delegate_to: zabbixslave
        run_once: true

should work as expected

  TASK [shell] *********************************************
  changed: [zabbixprimary -> zabbixprimary]

  TASK [shell] *********************************************
  changed: [zabbixprimary -> zabbixslave]

-- 
Vladimir Botka

-- 
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/20211215064402.3cb39d73%40gmail.com.

Attachment: pgpYCY4b1FcHm.pgp
Description: OpenPGP digital signature

Reply via email to