Fix ansible block, always, when syntax
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
This commit is contained in:
parent
7b47277e3e
commit
98b7ea710b
|
@ -142,43 +142,42 @@
|
||||||
debug: "{{ puppet_debug|default(omit) }}"
|
debug: "{{ puppet_debug|default(omit) }}"
|
||||||
timeout: "{{ puppet_timeout|default(omit) }}"
|
timeout: "{{ puppet_timeout|default(omit) }}"
|
||||||
|
|
||||||
- always:
|
always:
|
||||||
|
- block:
|
||||||
|
- name: find logs
|
||||||
|
shell: "ls -tr /var/lib/puppet/reports/{{ ansible_fqdn }}/*_puppetdb.json"
|
||||||
|
register: files
|
||||||
|
failed_when: files.stdout_lines|default("") == ""
|
||||||
|
|
||||||
- name: find logs
|
- name: set log filename
|
||||||
shell: "ls -tr /var/lib/puppet/reports/{{ ansible_fqdn }}/*_puppetdb.json"
|
set_fact: puppet_logfile="{{ files.stdout_lines|sort|last }}"
|
||||||
register: files
|
when: "{{ files.stdout_lines|length > 0 }}"
|
||||||
failed_when: files.stdout_lines|default("") == ""
|
|
||||||
|
|
||||||
- name: set log filename
|
- name: create reports directory
|
||||||
set_fact: puppet_logfile="{{ files.stdout_lines|sort|last }}"
|
file:
|
||||||
when: "{{ files.stdout_lines|length > 0 }}"
|
path: '/var/lib/puppet/reports/{{ ansible_fqdn }}'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
state: directory
|
||||||
|
delegate_to: localhost
|
||||||
|
when: "{{ files.stdout_lines|length > 0 }}"
|
||||||
|
|
||||||
- name: create reports directory
|
- name: fetch file
|
||||||
file:
|
synchronize:
|
||||||
path: '/var/lib/puppet/reports/{{ ansible_fqdn }}'
|
mode: pull
|
||||||
owner: root
|
src: "{{ puppet_logfile }}"
|
||||||
group: root
|
dest: /var/lib/puppet/reports/{{ ansible_fqdn }}
|
||||||
mode: 0755
|
when: "{{ files.stdout_lines|length > 0 }}"
|
||||||
state: directory
|
|
||||||
delegate_to: localhost
|
|
||||||
when: "{{ files.stdout_lines|length > 0 }}"
|
|
||||||
|
|
||||||
- name: fetch file
|
- name: post facts
|
||||||
synchronize:
|
puppet_post_puppetdb:
|
||||||
mode: pull
|
puppetdb: "{{ puppetdb }}"
|
||||||
src: "{{ puppet_logfile }}"
|
hostvars: "{{ hostvars[inventory_hostname] }}"
|
||||||
dest: /var/lib/puppet/reports/{{ ansible_fqdn }}
|
logfile: "{{ puppet_logfile }}"
|
||||||
when: "{{ files.stdout_lines|length > 0 }}"
|
whoami: "{{ puppet_report_as }}"
|
||||||
|
delegate_to: localhost
|
||||||
- name: post facts
|
when: "{{ files.stdout_lines|length > 0 }}"
|
||||||
puppet_post_puppetdb:
|
when:
|
||||||
puppetdb: "{{ puppetdb }}"
|
- puppetdb is defined
|
||||||
hostvars: "{{ hostvars[inventory_hostname] }}"
|
- puppet_report_as is defined
|
||||||
logfile: "{{ puppet_logfile }}"
|
|
||||||
whoami: "{{ puppet_report_as }}"
|
|
||||||
delegate_to: localhost
|
|
||||||
when: "{{ files.stdout_lines|length > 0 }}"
|
|
||||||
|
|
||||||
when:
|
|
||||||
- puppetdb is defined
|
|
||||||
- puppet_report_as is defined
|
|
||||||
|
|
Loading…
Reference in New Issue