0

/var/lib/phoronix-test-suite/test-results/

it has 3 subdirs:

2018-04-22-1850
2018-04-23-1850
2018-04-24-1850

and a tiny file in each: composite.xml

part of it's content:

  <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>

I want to replace <Identifier>pts/ramspeed-1.4.1</Identifier> with {{ ansible_host }} {{ dirname }}

let's say:

grep Identifier /var/lib/phoronix-test-suite/test-results/2018-04-24-1850/composite.xml
*<Identifier>hostname 2018-04-24-1850</Identifier>*

I have build some playbook, here is my "sample" config:

- 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 }}"

but it do not do what I want, maybe you could help?

1
  • What's the error message?
    – rndmh3ro
    Apr 27, 2018 at 9:21

1 Answer 1

0

I have used this:

---
- 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 }}'

I think this can be done using local facts for more tiny/neat/nice/cute look. but it is good for now.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .