/ var / lib / phoronix-test-suite / результаты тестов /
он имеет 3 подкаталога:
2018-04-22-1850 2018-04-23-1850 2018-04-24-1850
и крошечный файл в каждом: композитный.xml
часть его содержания:
<Result> <Identifier>pts/ramspeed-1.4.1</Identifier> <Title>RAMspeed SMP</Title> <AppVersion>3.5.0</AppVersion> <Arguments>ADD -b 3</Arguments> <Description>Type: Add - Benchmark: Integer</Description> <Scale>MB/s</Scale> <Proportion>HIB</Proportion> <DisplayFormat>BAR_GRAPH</DisplayFormat> <Data> <Entry> <Identifier>4096 MB RAM - Intel Core</Identifier> <Value>19292.13</Value> <RawString></RawString> <JSON>{"compiler-options":{"compiler-type":"CC","compiler":"gcc","compiler-options":"-O3 -march=native"}}</JSON> </Entry> </Data> </Result>
Я хочу заменить <Identifier> pts / ramspeed-1.4.1 </Identifier> с {{ansible_host}} {{dirname}}
скажем:
grep Identifier /var/lib/phoronix-test-suite/test-results/2018-04-24-1850/composite.xml *<Identifier>hostname 2018-04-24-1850</Identifier>*
Я собрал пьесу, вот мой "образец" конфигурации:
- name: Set the /PhoronixTestSuite/System/Identifier={{ ansible_host }} xml: path: /var/lib/phoronix-test-suite/test-results/*/composite.xml xpath: /PhoronixTestSuite/System/Identifier value: "{{ ansible_host }}" - name: Set the /PhoronixTestSuite/Result/Data/Entry/Identifier={{ ansible_host }} xml: path: /var/lib/phoronix-test-suite/test-results/*/composite.xml xpath: /PhoronixTestSuite/Result/Data/Entry/Identifier value: "{{ ansible_host }}"
но это не то, что я хочу, может ты мог бы помочь?
Я использовал это:
--- - name: Find /var/lib/phoronix-test-suite/test-results/ all directories find: paths: /var/lib/phoronix-test-suite/test-results recurse: no file_type: directory #patterns:'20*' register: dir_list #- debug: var=dir_list - name: /var/lib/phoronix-test-suite/test-results/*/composite.xml in PhoronixTestSuite/System/Identifier xml: path: '{{ item.path }}/composite.xml' xpath: /PhoronixTestSuite/System/Identifier value: '{{ ansible_hostname }} {{ item.path|basename }}' loop: '{{ dir_list.files }}' - name: /var/lib/phoronix-test-suite/test-results/*/composite.xml in PhoronixTestSuite/Result/Data/Entry/Identifier xml: path: '{{ item.path }}/composite.xml' xpath: /PhoronixTestSuite/Result/Data/Entry/Identifier value: '{{ ansible_hostname }} {{ item.path|basename }}' loop: '{{ dir_list.files }}' - name: phoronix-test-suite merge-results {{ dir_list.files | map(attribute="path") | map('basename') | join(' ') }} command: phoronix-test-suite merge-results {{ dir_list.files | map(attribute="path") | map('basename') | join(' ') }} - name: Find /var/lib/phoronix-test-suite/test-results/ all directories find: paths: /var/lib/phoronix-test-suite/test-results recurse: no file_type: directory patterns: 'merge*' #use_regex: yes register: dir_list - name: phoronix-test-suite result-file-to-pdf merge-* command: phoronix-test-suite result-file-to-pdf {{ item.path|basename }} loop: '{{ dir_list.files }}'
Я думаю, что это можно сделать, используя местные факты, для более крошечного / аккуратного / красивого / милого вида. но пока это хорошо.