summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2018-09-12 13:07:01 -0700
committerClark Boylan <clark.boylan@gmail.com>2018-09-12 13:08:28 -0700
commit98b7ea710bd499ecbc2a7ccbb670d434f9168897 (patch)
treef2d94f5b53601159c978c425f02401ce81e8b004
parent7b47277e3e7fba995b88079dfbb7e9c6af2a5081 (diff)
Fix ansible block, always, when syntaxHEADmaster
Newer ansible (2.7) is far more picky about always blocks being a part of block blocks. This means you cannot have a set of when conditions apply to a standalone always block. Fix our use of this by putting our always block in the run puppet block then move the always tasks into a block of their own with a condition set. Change-Id: I50988b6b312e4d00b73ca4454e0420913d4ae181
Notes
Notes (review): Code-Review+2: James E. Blair <corvus@inaugust.com> Code-Review+2: Monty Taylor <mordred@inaugust.com> Workflow+1: Monty Taylor <mordred@inaugust.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 12 Sep 2018 21:07:58 +0000 Reviewed-on: https://review.openstack.org/602149 Project: openstack-infra/ansible-role-puppet Branch: refs/heads/master
-rw-r--r--tasks/main.yaml79
1 files changed, 39 insertions, 40 deletions
diff --git a/tasks/main.yaml b/tasks/main.yaml
index 3f33757..cb00cd6 100644
--- a/tasks/main.yaml
+++ b/tasks/main.yaml
@@ -142,43 +142,42 @@
142 debug: "{{ puppet_debug|default(omit) }}" 142 debug: "{{ puppet_debug|default(omit) }}"
143 timeout: "{{ puppet_timeout|default(omit) }}" 143 timeout: "{{ puppet_timeout|default(omit) }}"
144 144
145- always: 145 always:
146 146 - block:
147 - name: find logs 147 - name: find logs
148 shell: "ls -tr /var/lib/puppet/reports/{{ ansible_fqdn }}/*_puppetdb.json" 148 shell: "ls -tr /var/lib/puppet/reports/{{ ansible_fqdn }}/*_puppetdb.json"
149 register: files 149 register: files
150 failed_when: files.stdout_lines|default("") == "" 150 failed_when: files.stdout_lines|default("") == ""
151 151
152 - name: set log filename 152 - name: set log filename
153 set_fact: puppet_logfile="{{ files.stdout_lines|sort|last }}" 153 set_fact: puppet_logfile="{{ files.stdout_lines|sort|last }}"
154 when: "{{ files.stdout_lines|length > 0 }}" 154 when: "{{ files.stdout_lines|length > 0 }}"
155 155
156 - name: create reports directory 156 - name: create reports directory
157 file: 157 file:
158 path: '/var/lib/puppet/reports/{{ ansible_fqdn }}' 158 path: '/var/lib/puppet/reports/{{ ansible_fqdn }}'
159 owner: root 159 owner: root
160 group: root 160 group: root
161 mode: 0755 161 mode: 0755
162 state: directory 162 state: directory
163 delegate_to: localhost 163 delegate_to: localhost
164 when: "{{ files.stdout_lines|length > 0 }}" 164 when: "{{ files.stdout_lines|length > 0 }}"
165 165
166 - name: fetch file 166 - name: fetch file
167 synchronize: 167 synchronize:
168 mode: pull 168 mode: pull
169 src: "{{ puppet_logfile }}" 169 src: "{{ puppet_logfile }}"
170 dest: /var/lib/puppet/reports/{{ ansible_fqdn }} 170 dest: /var/lib/puppet/reports/{{ ansible_fqdn }}
171 when: "{{ files.stdout_lines|length > 0 }}" 171 when: "{{ files.stdout_lines|length > 0 }}"
172 172
173 - name: post facts 173 - name: post facts
174 puppet_post_puppetdb: 174 puppet_post_puppetdb:
175 puppetdb: "{{ puppetdb }}" 175 puppetdb: "{{ puppetdb }}"
176 hostvars: "{{ hostvars[inventory_hostname] }}" 176 hostvars: "{{ hostvars[inventory_hostname] }}"
177 logfile: "{{ puppet_logfile }}" 177 logfile: "{{ puppet_logfile }}"
178 whoami: "{{ puppet_report_as }}" 178 whoami: "{{ puppet_report_as }}"
179 delegate_to: localhost 179 delegate_to: localhost
180 when: "{{ files.stdout_lines|length > 0 }}" 180 when: "{{ files.stdout_lines|length > 0 }}"
181 181 when:
182 when: 182 - puppetdb is defined
183 - puppetdb is defined 183 - puppet_report_as is defined
184 - puppet_report_as is defined