Skip to content

hostname task fails if FQDN provided in inventory/params #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
johnduarte opened this issue Aug 6, 2019 · 0 comments · Fixed by #27
Closed

hostname task fails if FQDN provided in inventory/params #22

johnduarte opened this issue Aug 6, 2019 · 0 comments · Fixed by #27

Comments

@johnduarte
Copy link
Contributor

Given that a FQDN is provided in the inventory and the params.json file for a role, the pe_xl::hostname task will throw an error because the hostname returned does not include the domain.

nodes.yaml snippet

...
    nodes:
      - l44n1csrf0zp9s4.delivery.puppetlabs.net
...

params.json snippet

{
...
  "master_host": "l44n1csrf0zp9s4.delivery.puppetlabs.net",
...
}

Plan fails with

...
{"node":"l44n1csrf0zp9s4.delivery.puppetlabs.net","target":"l44n1csrf0zp9s4.delivery.puppetlabs.net","action":"task","object":"pe_xl::hostname","status":"success","result":{"hostname":"l44n1csrf0zp9s4"}}
Command returned successfully
...
{
  "kind": "bolt/plan-failure",
  "msg": "Hostname / DNS name mismatch: target l44n1csrf0zp9s4.delivery.puppetlabs.net reports 'l44n1csrf0zp9s4'",
  "details": {
  }
}

I presume that the hostname task should be producing the fqdn instead of just the base hostname.

Possible update

diff --git a/tasks/hostname.sh b/tasks/hostname.sh
index bdabaf7..f64a4d8 100755
--- a/tasks/hostname.sh
+++ b/tasks/hostname.sh
@@ -1,6 +1,6 @@
 #!/bin/bash

-hostname=$(/usr/bin/hostnamectl --transient)
+hostname=$(/usr/bin/hostname -f)

 # Output a JSON result for ease of Task usage in Puppet Task Plans
 echo '{ "hostname": "'$hostname'" }'
dylanratcliffe pushed a commit to dylanratcliffe/reidmv-pe_xl that referenced this issue Oct 30, 2019
Using `hostnamectl --transient` doesn't *always* return the FQDN, which is what the plans are usually expecting. `hostname -f` is a more reliable way of doing this.

Fixes puppetlabs#22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant