From f23f6d6d9843a5c30ffbd119c1860b87d0b7bed3 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 1 Dec 2015 10:15:20 -0600 Subject: [PATCH] Clear up some issues with fqdm vs. hostname When we're using openstack inventory, inventory_hostname is the uuid of the openstack server, whereas ansible_fqdn is the actual fqdn of the host. So for things where it's important that the variable resolve to the hostname (like looking up puppet reports on disk, we need to use nsible_fqdn). For things like looking up hostvars in the hostvars dict, we nede to continue using inventory_hostname. Further, when we _delegate_to_ like we do for the post-to-puppetdb step, ansible_fqdn is the name of the host delegated to - so it's not needed to pass in the whoami value. Change-Id: I420112668a016988ddb397e798f6ba983291d2f8 --- tasks/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 4f78bc5..903b59e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -25,7 +25,7 @@ when: copy_hieradata is defined and copy_hieradata - name: make file list puppet_get_hiera_file_list: - fqdn: "{{ inventory_hostname }}" + fqdn: "{{ ansible_fqdn }}" groups: "{{ hostvars[inventory_hostname].group_names }}" when: copy_hieradata is defined and copy_hieradata delegate_to: localhost @@ -54,7 +54,7 @@ facts: "{{ facts|default(omit) }}" facter_basename: "{{ facter_basename|default(omit) }}" - name: find logs - shell: "ls -tr /var/lib/puppet/reports/{{ inventory_hostname }}/*_puppetdb.json" + shell: "ls -tr /var/lib/puppet/reports/{{ ansible_fqdn }}/*_puppetdb.json" register: files when: puppetdb is defined - name: set log filename @@ -64,14 +64,14 @@ synchronize: mode: pull src: "{{ puppet_logfile }}" - dest: /var/lib/puppet/reports/{{ inventory_hostname }} + dest: /var/lib/puppet/reports/{{ ansible_fqdn }} when: puppetdb is defined - name: post facts puppet_post_puppetdb: puppetdb: "{{ puppetdb }}" hostvars: "{{ hostvars[inventory_hostname] }}" logfile: "{{ puppet_logfile }}" - whoami: "{{ whoami }}" + whoami: "{{ ansible_fqdn }}" delegate_to: localhost connection: local when: puppetdb is defined