Как изменить каждый clientIP в ansible? - PullRequest
0 голосов
/ 26 декабря 2018

Я все еще изучаю Ansible ... Хотите заменить IP-адрес в Ansible по IP-адресу клиента

hosts:

[servers]
192.168.0.1
192.168.0.18
192.168.0.19
192.168.0.23
192.168.0.129
192.168.0.130
192.168.0.149

server.yml

---
- name: Create update alive crontab
hosts: servers
become: true
tasks:
- name: a crontab job
  cron:
      minute="0"
      job="http://xx.xx.xx.xx/alive.php?ip=clientIP"

Как изменить каждый clientIP в server.yml?

1 Ответ

0 голосов
/ 26 декабря 2018

Вы ищете переменную ansible_host

job = "http://xx.xx.xx.xx/alive.php?ip={{ ansible_host}}"

См. Пример:

# ansible -m debug -a 'msg="{{ ansible_host }}"' localhost
localhost | SUCCESS => {
    "msg": "127.0.0.1"
}
...