Debian 10 Playbook error

I am trying to set up a new Debian 10 build server, and the first step is gaining the ability to ssh into the device from outside my local network. For whatever reason, this is proving to be difficult and I haven’t the slightest clue why. When I try to ssh into my server with user@hostname, I get the error:

ssh: Could not resolve hostname {hostname}: Name or service not known

When I try to ssh into my server with user@IPADDRESS it’s successful

ping {hostname} : ping: {hostname}: Name or service not known
ping {IP}: successful

nslookup {hostname}:

;; Got SERVFAIL reply from x.x.x.x, trying next server
Server: x.x.x.x.
Address: x.x.x.x.#53

** server can’t find {hostname}: SERVFAIL

nslookup {IP}: successful

Ansible Playbook:

  • hosts: buildservers
    remote_user: root
    roles:
  • buildservers

I’m trying to run ansible role on multiple servers, but i get an error:

fatal: [hostname]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: ssh: Could not resolve hostname hostname: Name or service not known”, “unreachable”: true}

ansible-playbook -vvvv

ansible-playbook 2.8.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/home/kjames/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.5 (default, Apr 9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
Using /etc/ansible/ansible.cfg as config file

setting up inventory plugins
host_list declined parsing /home/kjames/ds9/buildservers-qa as it did not pass it’s verify_file() method
script declined parsing /home/kjames/ds9/buildservers-qa as it did not pass it’s verify_file() method
auto declined parsing /home/kjames/ds9/buildservers-qa as it did not pass it’s verify_file() method
Not replacing invalid character(s) “set([u’-'])” in group name (RHEL7E-ARM)
[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still be user
configurable on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

Not replacing invalid character(s) “set([u’-'])” in group name (RHEL7E-ARM)
Parsed /home/kjames/ds9/buildservers-qa inventory source with ini plugin
statically imported: /home/kjames/ds9/roles/buildservers/tasks/regular-packages.yaml
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: new-buildserver.yaml *******************************************************************************************************************************************
Positional arguments: new-buildserver.yaml
ask_pass: True
check: True
become_method: sudo
inventory: (u’/home/kjames/ds9/buildservers-qa’,)
forks: 5
tags: (u’all’,)
verbosity: 4
connection: smart
timeout: 10
1 plays in new-buildserver.yaml

PLAY [buildservers] ******************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************
task path: /home/kjames/ds9/new-buildserver.yaml:13
ESTABLISH SSH CONNECTION FOR USER: root
SSH: EXEC sshpass -d10 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o ‘User=“root”’ -o ConnectTimeout=10 -o ControlPath=/home/kjames/.ansible/cp/2a56e2da62 hostname ‘/bin/sh -c ‘"’“‘echo ~root && sleep 0’”’"‘’
(255, ‘’, ‘OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: Control socket “/home/kjames/.ansible/cp/2a56e2da62” does not exist\r\ndebug2: resolving “hostname” port 22\r\nssh: Could not resolve hostname hostname: Name or service not known\r\n’)

Hey Keith,

Hi Matt,

name server

If you query the name server:

dig @nameserver name.example.com

what do you get?

Name resolution is somewhat out of the scope of ansible.

-m

; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.1 <<>> @16.81.52.163 hwbldeb10ex6401.sde.rdlabs.hpecorp.net
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 27051
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;hwbldeb10ex6401.sde.rdlabs.hpecorp.net. IN A

;; AUTHORITY SECTION:
sde.rdlabs.hpecorp.net. 3600 IN SOA hdc3.sde.rdlabs.hpecorp.net. ess-morpheus-admin.groups.int.hpe.com. 801754 900 600 86400 3600

;; Query time: 2 msec
;; SERVER: 16.81.52.163#53(16.81.52.163)
;; WHEN: Wed Jul 17 18:41:58 UTC 2019
;; MSG SIZE rcvd: 167

Are you sure the A/AAAA records are present in the zone?

Did the zone get an updated serial?

Can you try querying the authoritative server directly for your zone?

-m

Issue resolved! The hostname was incorrect. Changed hostname and rebooted.