Unfortunately the ansible_fqdn keeps the initial value when I start running the plabook even if later on I manually gather facts again. The correct value is displayed if I run the same playbook again after the first run. It seems to me that for some reason the manual facts gathering (setup:) is not working :
- name: update the hostname
hostname: name="{{ inventory_hostname }}"
- name: boot persist the hostname
lineinfile: dest=/etc/sysconfig/network
regexp=^HOSTNAME=
line=HOSTNAME={{ inventory_hostname }}
state=present
- name: add the hostname to the hosts file
lineinfile: dest=/etc/hosts
regexp="^127\.0\.0\.1(.*)"
line="127.0.0.1{{'\t'}}{{ inventory_hostname }} localhost.localdomain localhost"
state=present
backrefs=yes
- name: Print ansible_fqdn
debug: msg="ansible_fqdn is {{ ansible_fqdn }}"
"""
Any ideas ??
Regards,
N.