summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/incidental_xml/tasks/test-add-children-insertafter.yml
blob: 2d42e2d54e060a903a8523edeaa8bbbd0444659d (plain)
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
---
  - name: Setup test fixture
    copy:
      src: fixtures/ansible-xml-beers.xml
      dest: /tmp/ansible-xml-beers.xml


  - name: Add child element
    xml:
      path: /tmp/ansible-xml-beers.xml
      xpath: '/business/beers/beer[text()="St. Bernardus Abbot 12"]'
      insertafter: yes
      add_children:
      - beer: Old Rasputin
      - beer: Old Motor Oil
      - beer: Old Curmudgeon
      pretty_print: yes
    register: add_children_insertafter

  - name: Compare to expected result
    copy:
      src: results/test-add-children-insertafter.xml
      dest: /tmp/ansible-xml-beers.xml
    check_mode: yes
    diff: yes
    register: comparison

  - name: Test expected result
    assert:
      that:
      - add_children_insertafter.changed == true
      - comparison.changed == false  # identical