diff --git a/library/run_cmds.py b/library/run_cmds.py index 18eaa0f..86c7767 100644 --- a/library/run_cmds.py +++ b/library/run_cmds.py @@ -63,7 +63,6 @@ "RedhatPackages": redhat_packages_command.RedhatPackagesRhoCmd, "VirtWhat": virt_what_command.VirtWhatRhoCmd, - "Date": date_command.DateRhoCmd, "SubmanFacts": subman_facts_command.SubmanFactsRhoCmd} diff --git a/rho_playbook.yml b/rho_playbook.yml index c727c9d..ea672a7 100644 --- a/rho_playbook.yml +++ b/rho_playbook.yml @@ -9,6 +9,7 @@ roles: - collect - uname + - date - name: write facts first to a variable and then to csv locally diff --git a/roles/date/tasks/main.yml b/roles/date/tasks/main.yml new file mode 100644 index 0000000..e2578ff --- /dev/null +++ b/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' diff --git a/roles/write/tasks/main.yml b/roles/write/tasks/main.yml index 6604697..23b9af9 100644 --- a/roles/write/tasks/main.yml +++ b/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