-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore-ansible-facts.yml
More file actions
23 lines (23 loc) · 864 Bytes
/
store-ansible-facts.yml
File metadata and controls
23 lines (23 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
---
# Stores ansible_facts to a file by way of a j2 template
- hosts: all
gather_facts: true
become: true
tasks:
- name: Create a consistent timestamp for all files
set_fact:
datestamp: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}-{{ ansible_date_time.hour }}{{ ansible_date_time.minute }}{{ ansible_date_time.second}}"
cacheable: yes
run_once: true
- name: Collect optional package_facts
package_facts:
- name: Collect optional service_facts
service_facts:
#- name: Collect optional listen_ports_facts (not included with many Ansible versions)
# listen_ports_facts:
- name: Store ansible facts in local files
template:
src: store-ansible-facts.j2
dest: "ansible_facts-{{ inventory_hostname }}-{{ datestamp }}.json"
delegate_to: localhost
become: false