Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Covert date.* fact gathering to raw tasks. Closes #96.
Browse files Browse the repository at this point in the history
  • Loading branch information
chambridge committed Jul 27, 2017
1 parent 373e18c commit c473b29
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
1 change: 0 additions & 1 deletion library/run_cmds.py
Expand Up @@ -63,7 +63,6 @@
"RedhatPackages":
redhat_packages_command.RedhatPackagesRhoCmd,
"VirtWhat": virt_what_command.VirtWhatRhoCmd,
"Date": date_command.DateRhoCmd,
"SubmanFacts": subman_facts_command.SubmanFactsRhoCmd}


Expand Down
1 change: 1 addition & 0 deletions rho_playbook.yml
Expand Up @@ -9,6 +9,7 @@
roles:
- collect
- uname
- date


- name: write facts first to a variable and then to csv locally
Expand Down
61 changes: 61 additions & 0 deletions roles/date/tasks/main.yml
@@ -0,0 +1,61 @@
---

- name: gather date.date fact
raw: date
register: date_date
ignore_errors: yes
when: '"Date_date.date" in facts_to_collect'

- name: add date.date to dictionary
set_fact:
date: "{{ date|default({}) | combine({ item: date_date['stdout_lines'][0] }) }}"
with_items:
- 'date.date'

- name: gather date.anaconda_log fact
raw: ls --full-time /root/anaconda-ks.cfg | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'
register: date_anaconda_log
ignore_errors: yes
when: '"Date_date.anaconda_log" in facts_to_collect'

- name: add date.anaconda_log to dictionary
set_fact:
date: "{{ date|default({}) | combine({ item: date_anaconda_log['stdout_lines'][0] }) }}"
with_items:
- 'date.anaconda_log'

- name: gather date.machine_id fact
raw: ls --full-time /etc/machine-id | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'
register: date_machine_id
ignore_errors: yes
when: '"Date_date.machine_id" in facts_to_collect'

- name: add date.machine_id to dictionary
set_fact:
date: "{{ date|default({}) | combine({ item: date_machine_id['stdout_lines'][0] }) }}"
with_items:
- 'date.machine_id'

- name: gather date.filesystem_create fact
raw: fs_date=$(tune2fs -l $(mount | egrep '/ type' | grep -o '/dev.* on' | sed -e 's/\on//g') | grep 'Filesystem created' | sed 's/Filesystem created:\s*//g'); if [[ $fs_date ]]; then date +'%F' -d \"$fs_date\"; else echo "" ; fi
register: date_filesystem_create
ignore_errors: yes
when: '"Date_date.filesystem_create" in facts_to_collect'

- name: add date.filesystem_create to dictionary
set_fact:
date: "{{ date|default({}) | combine({ item: date_filesystem_create['stdout_lines'][0] }) }}"
with_items:
- 'date.filesystem_create'

- name: gather date.yum_history fact
raw: yum history | tail -n 4 | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'
register: date_yum_history
ignore_errors: yes
when: '"Date_date.yum_history" in facts_to_collect'

- name: add date.yum_history to dictionary
set_fact:
date: "{{ date|default({}) | combine({ item: date_yum_history['stdout_lines'][0] }) }}"
with_items:
- 'date.yum_history'
2 changes: 1 addition & 1 deletion roles/write/tasks/main.yml
@@ -1,7 +1,7 @@
---

- name: store facts from all hosts in a variable
set_fact: host_fact={{hostvars[item]["res"] | combine(hostvars[item]["uname"]) }}
set_fact: host_fact={{hostvars[item]["res"] | combine(hostvars[item]["uname"]) | combine(hostvars[item]["date"]) }}
with_items: "{{groups.alpha}}"
register: host_facts

Expand Down

0 comments on commit c473b29

Please sign in to comment.