Thank you it's working now. Thank you Gopal Dhapa
On Mon, May 6, 2019, 1:14 AM <[email protected]> wrote: > To see the hostname or use it in your playbook, you use the > ansible_hostname or ansible_fqdn variables. > > As Jonathan Cha'gara Lozada De La Matta mentioned, the hostname module > can set it, but many applications still (incorrectly) rely on it also being > in the /etc/hosts file. Here's what I've done in my playbooks: > > - name: Setup hostname on system as {{ network_hostname }}.{{ > network_dnsdomain }} > hostname: > name: "{{ network_hostname }}.{{ network_dnsdomain }}" > > > - name: Add hostname to local /etc/hosts file > lineinfile: > dest: /etc/hosts > state: present > regexp: "^{{ network_ipaddr }}" > line: "{{ network_ipaddr }} {{ network_hostname }}.{{ > network_dnsdomain }} {{ network_hostname }}" > > In this case, I set network_* variables before calling this - my systems > occasionally confuse Ansible and the ansible_hostname/ansible_fqdn are > incorrect. > > On Sunday, May 5, 2019 at 8:31:37 AM UTC-5, Gopal Dhapa wrote: >> >> Hello Team, >> >> How to see centos server host name using ansible. >> >> Please suggest >> >> Thanks in advance. >> >> Thank you >> Gopal Dhapa >> > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/b0e98f8b-6c15-4090-b40e-d10116757241%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/b0e98f8b-6c15-4090-b40e-d10116757241%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAFuBnhgee51SaOyC9FO9stKDgoL_b1hSDOc1cK3qwVyge7QcjQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
