On Wed, 15 Dec 2021 16:30:40 +1300
Lucas Possamai <
drum....@gmail.com> wrote:
> On Wed, 15 Dec 2021 at 16:03, Lucas Possamai <
drum....@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