|
|
|
@ -18,7 +18,7 @@
|
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
- name: record the output directory
|
|
|
|
|
set_fact: output_file={{output_dir}}/foo.ini
|
|
|
|
|
set_fact: output_file={{ remote_tmp_dir }}/foo.ini
|
|
|
|
|
|
|
|
|
|
- name: add "fav=lemonade" is in section "[drinks]" in specified file
|
|
|
|
|
ini_file:
|
|
|
|
@ -34,13 +34,18 @@
|
|
|
|
|
- result1.changed == True
|
|
|
|
|
- result1.msg == 'section and option added'
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: set expected content and get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
expected1: |-
|
|
|
|
|
expected1: |
|
|
|
|
|
|
|
|
|
|
[drinks]
|
|
|
|
|
fav = lemonade
|
|
|
|
|
content1: "{{ lookup('file', output_file) }}"
|
|
|
|
|
content1: "{{ output_content.content | b64decode }}"
|
|
|
|
|
|
|
|
|
|
- name: Verify content of ini file is as expected
|
|
|
|
|
assert:
|
|
|
|
@ -69,14 +74,19 @@
|
|
|
|
|
value: coke
|
|
|
|
|
register: result3
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: set expected content and get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
expected3: |-
|
|
|
|
|
expected3: |
|
|
|
|
|
|
|
|
|
|
[drinks]
|
|
|
|
|
fav = lemonade
|
|
|
|
|
beverage = coke
|
|
|
|
|
content3: "{{ lookup('file', output_file) }}"
|
|
|
|
|
content3: "{{ output_content.content | b64decode }}"
|
|
|
|
|
|
|
|
|
|
- name: assert 'changed' is true and content is OK
|
|
|
|
|
assert:
|
|
|
|
@ -93,9 +103,14 @@
|
|
|
|
|
state: absent
|
|
|
|
|
register: result4
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: get ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
content4: "{{ lookup('file', output_file) }}"
|
|
|
|
|
content4: "{{ output_content.content | b64decode }}"
|
|
|
|
|
|
|
|
|
|
- name: assert changed and content is as expected
|
|
|
|
|
assert:
|
|
|
|
@ -111,16 +126,21 @@
|
|
|
|
|
state: absent
|
|
|
|
|
register: result5
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
content5: "{{ lookup('file', output_file) }}"
|
|
|
|
|
content5: "{{ output_content.content | b64decode }}"
|
|
|
|
|
|
|
|
|
|
- name: assert changed and content is empty
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- result5.changed == True
|
|
|
|
|
- result5.msg == 'section removed'
|
|
|
|
|
- content5 == ""
|
|
|
|
|
- content5 == "\n"
|
|
|
|
|
|
|
|
|
|
# allow_no_value
|
|
|
|
|
|
|
|
|
@ -163,10 +183,15 @@
|
|
|
|
|
- { o: "skip-name-resolve", v: null }
|
|
|
|
|
- { o: "max_connections", v: "500" }
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: set expected content and get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
content7: "{{ lookup('file', output_file) }}"
|
|
|
|
|
expected7: |-
|
|
|
|
|
content7: "{{ output_content.content | b64decode }}"
|
|
|
|
|
expected7: |
|
|
|
|
|
|
|
|
|
|
[mysqld]
|
|
|
|
|
skip-name
|
|
|
|
@ -186,10 +211,15 @@
|
|
|
|
|
value: myvalue
|
|
|
|
|
register: result8
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: set expected content and get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
content8: "{{ lookup('file', output_file) }}"
|
|
|
|
|
expected8: |-
|
|
|
|
|
content8: "{{ output_content.content | b64decode }}"
|
|
|
|
|
expected8: |
|
|
|
|
|
|
|
|
|
|
[mysqld]
|
|
|
|
|
skip-name = myvalue
|
|
|
|
@ -211,10 +241,15 @@
|
|
|
|
|
allow_no_value: yes
|
|
|
|
|
register: result9
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: set expected content and get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
content9: "{{ lookup('file', output_file) }}"
|
|
|
|
|
expected9: |-
|
|
|
|
|
content9: "{{ output_content.content | b64decode }}"
|
|
|
|
|
expected9: |
|
|
|
|
|
|
|
|
|
|
[mysqld]
|
|
|
|
|
skip-name
|
|
|
|
@ -236,10 +271,15 @@
|
|
|
|
|
state: absent
|
|
|
|
|
register: result10
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: set expected content and get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
content10: "{{ lookup('file', output_file) }}"
|
|
|
|
|
expected10: |-
|
|
|
|
|
content10: "{{ output_content.content | b64decode }}"
|
|
|
|
|
expected10: |
|
|
|
|
|
|
|
|
|
|
[mysqld]
|
|
|
|
|
skip-name
|
|
|
|
@ -266,10 +306,15 @@
|
|
|
|
|
value: coke
|
|
|
|
|
register: result11
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: set expected content and get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
expected11: "beverage = coke"
|
|
|
|
|
content11: "{{ lookup('file', output_file) }}"
|
|
|
|
|
expected11: "beverage = coke\n\n"
|
|
|
|
|
content11: "{{ output_content.content | b64decode }}"
|
|
|
|
|
|
|
|
|
|
- name: assert 'changed' is true and content is OK (no section)
|
|
|
|
|
assert:
|
|
|
|
@ -286,11 +331,16 @@
|
|
|
|
|
section:
|
|
|
|
|
register: result12
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: set expected content and get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
expected12: "beverage = water"
|
|
|
|
|
expected12: "beverage = water\n\n"
|
|
|
|
|
|
|
|
|
|
content12: "{{ lookup('file', output_file) }}"
|
|
|
|
|
content12: "{{ output_content.content | b64decode }}"
|
|
|
|
|
|
|
|
|
|
- name: assert 'changed' is true and content is OK (no section)
|
|
|
|
|
assert:
|
|
|
|
@ -307,16 +357,21 @@
|
|
|
|
|
state: absent
|
|
|
|
|
register: result13
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
content13: "{{ lookup('file', output_file) }}"
|
|
|
|
|
content13: "{{ output_content.content | b64decode }}"
|
|
|
|
|
|
|
|
|
|
- name: assert changed (no section)
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- result13 is changed
|
|
|
|
|
- result13.msg == 'option changed'
|
|
|
|
|
- content13 == ""
|
|
|
|
|
- content13 == "\n"
|
|
|
|
|
|
|
|
|
|
- name: Check add option without section before existing section
|
|
|
|
|
block:
|
|
|
|
@ -333,14 +388,19 @@
|
|
|
|
|
option: like
|
|
|
|
|
value: tea
|
|
|
|
|
|
|
|
|
|
- name: read content from output file
|
|
|
|
|
slurp:
|
|
|
|
|
src: "{{ output_file }}"
|
|
|
|
|
register: output_content
|
|
|
|
|
|
|
|
|
|
- name: set expected content and get current ini file content
|
|
|
|
|
set_fact:
|
|
|
|
|
expected14: |-
|
|
|
|
|
expected14: |
|
|
|
|
|
like = tea
|
|
|
|
|
|
|
|
|
|
[drinks]
|
|
|
|
|
beverage = water
|
|
|
|
|
content14: "{{ lookup('file', output_file) }}"
|
|
|
|
|
content14: "{{ output_content.content | b64decode }}"
|
|
|
|
|
|
|
|
|
|
- name: Verify content of ini file is as expected
|
|
|
|
|
assert:
|
|
|
|
|