Monty Taylor c25e5aa543 Perform filepath checking in python
Checking for all of the paths in ansible leads to a TON of skipped lines
in the ansible log. That's not good for anybody, and we're already
processing the paths in python - let's do a quick filter to check for
which ones exist before returning them.

Change-Id: Iddf3c56c802598329a18c374cf667a6f165f78ca
2016-01-14 15:39:25 -05:00

97 lines
2.3 KiB
YAML

---
- block:
- name: ensure hiera datadir
file:
state: directory
path: "{{ hieradata }}/{{ hieraenvironment }}"
owner: root
group: root
mode: 0700
- name: ensure hiera datadir - fqdn
file:
state: directory
path: "{{ hieradata }}/{{ hieraenvironment }}/fqdn"
owner: root
group: root
mode: 0700
- name: ensure hiera datadir - group
file:
state: directory
path: "{{ hieradata }}/{{ hieraenvironment }}/group"
owner: root
group: root
mode: 0700
- name: make file list
puppet_get_hiera_file_list:
fqdn: "{{ ansible_fqdn }}"
groups: "{{ hostvars[inventory_hostname].group_names }}"
location: "{{ hieradata }}/{{ hieraenvironment }}"
delegate_to: localhost
register: hiera_file_paths
- name: copy hiera files
copy:
src: "{{ item }}"
dest: "{{ item }}"
mode: 0600
with_items: hiera_file_paths.paths
- name: ensure hieradata manifest link is present
file:
src: "{{ hieradata }}"
dest: "{{ manifest_base }}/hieradata"
state: link
when: copy_hieradata
- block:
- name: copy puppet modules
synchronize:
src: "{{ manifest_base }}/{{ hieraenvironment }}"
dest: "{{ manifest_base }}"
- name: copy system puppet modules
synchronize:
src: /etc/puppet/modules
dest: /etc/puppet
when:
- copy_puppet
- manifest_base is defined
- name: run puppet
puppet:
puppetmaster: "{{ puppetmaster|default(omit) }}"
manifest: "{{ manifest|default(omit) }}"
show_diff: "{{ show_diff|default(false) }}"
facts: "{{ facts|default(omit) }}"
facter_basename: "{{ facter_basename|default(omit) }}"
- block:
- name: find logs
shell: "ls -tr /var/lib/puppet/reports/{{ ansible_fqdn }}/*_puppetdb.json"
register: files
- name: set log filename
set_fact: puppet_logfile="{{ files.stdout_lines|sort|last }}"
- name: fetch file
synchronize:
mode: pull
src: "{{ puppet_logfile }}"
dest: /var/lib/puppet/reports/{{ ansible_fqdn }}
- name: post facts
puppet_post_puppetdb:
puppetdb: "{{ puppetdb }}"
hostvars: "{{ hostvars[inventory_hostname] }}"
logfile: "{{ puppet_logfile }}"
whoami: "{{ ansible_fqdn }}"
delegate_to: localhost
connection: local
when: puppetdb is defined