This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
forked from candlepin/rho
-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.yml
107 lines (90 loc) · 3.65 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
- name: initialize cpu dictionary
set_fact:
cpu: "{{ cpu|default({}) }}"
- name: gather cpu.vendor_id fact
raw: cat /proc/cpuinfo | grep '^vendor_id\s*' | sed -n -e 's/^.*vendor_id\s*.\s*//p'
register: cpu_vendor_id
ignore_errors: yes
when: '"cpu.vendor_id" in facts_to_collect'
- name: add cpu.vendor_id to dictionary
set_fact:
cpu: "{{ cpu|default({}) | combine({ item: cpu_vendor_id['stdout_lines'][0] | default('error') }) }}"
with_items:
- 'cpu.vendor_id'
when: '"cpu.vendor_id" in facts_to_collect'
- name: gather cpu.model_name fact
raw: cat /proc/cpuinfo | grep '^model name\s*.' | sed -n -e 's/^.*model name\s*.\s*//p'
register: cpu_model_name
ignore_errors: yes
when: '"cpu.model_name" in facts_to_collect'
- name: add cpu.model_name to dictionary
set_fact:
cpu: "{{ cpu|default({}) | combine({ item: cpu_model_name['stdout_lines'][0] | default('error') }) }}"
with_items:
- 'cpu.model_name'
when: '"cpu.model_name" in facts_to_collect'
- name: gather cpu.bogomips fact
raw: cat /proc/cpuinfo | grep '^bogomips\s*.' | sed -n -e 's/^.*bogomips\s*.\s*//p'
register: cpu_bogomips
ignore_errors: yes
when: '"cpu.bogomips" in facts_to_collect'
- name: add cpu.bogomips to dictionary
set_fact:
cpu: "{{ cpu|default({}) | combine({ item: cpu_bogomips['stdout_lines'][0] | default('error') }) }}"
with_items:
- 'cpu.bogomips'
when: '"cpu.bogomips" in facts_to_collect'
- name: gather cpu.cpu_family fact
raw: cat /proc/cpuinfo | grep '^cpu family\s*.' | sed -n -e 's/^.*cpu family\s*.\s*//p'
register: cpu_cpu_family
ignore_errors: yes
when: '"cpu.cpu_family" in facts_to_collect'
- name: add cpu.cpu_family to dictionary
set_fact:
cpu: "{{ cpu|default({}) | combine({ item: cpu_cpu_family['stdout_lines'][0] | default('error') }) }}"
with_items:
- 'cpu.cpu_family'
when: '"cpu.cpu_family" in facts_to_collect'
- name: gather cpu.model_ver fact
raw: cat /proc/cpuinfo | grep '^model\s*.' | sed -n -e 's/^.*model\s*.\s*//p'
register: cpu_model_ver
ignore_errors: yes
when: '"cpu.model_ver" in facts_to_collect'
- name: add cpu.model_ver to dictionary
set_fact:
cpu: "{{ cpu|default({}) | combine({ item: cpu_model_ver['stdout_lines'][0] | default('error') }) }}"
with_items:
- 'cpu.model_ver'
when: '"cpu.model_ver" in facts_to_collect'
- name: gather cpu.count fact
raw: cat /proc/cpuinfo | grep '^processor\s*.' | wc -l
register: cpu_count
ignore_errors: yes
when: '"cpu.count" in facts_to_collect'
- name: add cpu.count to dictionary
set_fact:
cpu: "{{ cpu|default({}) | combine({ item: cpu_count['stdout_lines'][0] | default('error') }) }}"
with_items:
- 'cpu.count'
when: '"cpu.count" in facts_to_collect'
- name: gather cpu.socket_count fact
raw: /usr/sbin/dmidecode -t 4 | grep 'Socket Designation'| wc -l
register: cpu_socket_count_cmd
become: yes
ignore_errors: yes
when: 'have_dmidecode and "cpu.socket_count" in facts_to_collect'
- name: extract result value for cpu.socket_count
set_fact:
cpu_socket_count: "{{ cpu_socket_count_cmd['stdout'] | trim | default('error') if have_dmidecode else 'N/A (dmidecode not found)' }}"
when: '"cpu.socket_count" in facts_to_collect and "stdout" in cpu_socket_count_cmd'
- name: handle failure value for cpu.socket_count
set_fact:
cpu_socket_count: "{{ 'error' if have_dmidecode else 'N/A (dmidecode not found)' }}"
when: '"cpu.socket_count" in facts_to_collect and "stdout" not in cpu_socket_count_cmd'
- name: add cpu.socket_count to dictionary
set_fact:
cpu: "{{ cpu|default({}) | combine({ item: cpu_socket_count }) }}"
with_items:
- 'cpu.socket_count'
when: '"cpu.socket_count" in facts_to_collect'