summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/src/test/integration/oc_configmap.yml
blob: 6a452ccece0e42c1320f281ddc5ac06c80bbd3b7 (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
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
#!/usr/bin/ansible-playbook --module-path=../../../library/
## ./oc_configmap.yml -M ../../../library -e "cli_master_test=$OPENSHIFT_MASTER
---
- hosts: "{{ cli_master_test }}"
  gather_facts: no
  user: root
  vars:
    filename: /tmp/test_configmap_from_file

  post_tasks:
  - name: Setup a file with known contents
    copy:
      content: This is a file
      dest: "{{ filename }}"

  - name: create a test project
    oc_project:
      name: test
      description: for tests only

  ###### create test ###########
  - name: create a configmap
    oc_configmap:
      state: present
      name: configmaptest
      namespace: test
      from_file:
        config: "{{ filename }}"
      from_literal:
        foo: bar

  - name: fetch the created configmap
    oc_configmap:
      name: configmaptest
      state: list
      namespace: test
    register: cmout

  - debug: var=cmout

  - name: assert configmaptest exists
    assert:
      that:
      - cmout.results.results[0].metadata.name == 'configmaptest'
      - cmout.results.results[0].data.foo == 'bar'
  ###### end create test ###########

  ###### update test ###########
  - name: create a configmap
    oc_configmap:
      state: present
      name: configmaptest
      namespace: test
      from_file:
        config: "{{ filename }}"
      from_literal:
        foo: notbar
        deployment_type: openshift-enterprise

  - name: fetch the updated configmap
    oc_configmap:
      name: configmaptest
      state: list
      namespace: test
    register: cmout

  - debug: var=cmout

  - name: assert configmaptest exists
    assert:
      that:
      - cmout.results.results[0].metadata.name == 'configmaptest'
      - cmout.results.results[0].data.deployment_type == 'openshift-enterprise'
      - cmout.results.results[0].data.foo == 'notbar'
  ###### end update test ###########

  ###### delete test ###########
  - name: delete a configmap
    oc_configmap:
      state: absent
      name: configmaptest
      namespace: test

  - name: fetch the updated configmap
    oc_configmap:
      name: configmaptest
      state: list
      namespace: test
    register: cmout

  - debug: var=cmout

  - name: assert configmaptest exists
    assert:
      that: "'\"configmaptest\" not found' in cmout.results.stderr"