mirror of https://github.com/ansible/ansible.git
ini: Add parameter to allow no value (#74806)
ConfigParser allows to read key with no value. Fixes: #50594 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>pull/74373/head
parent
397d3763ea
commit
ae50d05182
@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- ini - added new parameter ``allow_no_value`` to ini lookup plugin (https://github.com/ansible/ansible/issues/50594).
|
||||
@ -0,0 +1,8 @@
|
||||
[mysqld]
|
||||
user = mysql
|
||||
pid-file = /var/run/mysqld/mysqld.pid
|
||||
skip-external-locking
|
||||
old_passwords = 1
|
||||
skip-bdb
|
||||
# we don't need ACID today
|
||||
skip-innodb
|
||||
@ -0,0 +1,23 @@
|
||||
- name: Lookup test
|
||||
hosts: testhost
|
||||
tasks:
|
||||
- name: "Read mysql.ini allow_none=False (default)"
|
||||
set_fact:
|
||||
test1: "{{ lookup('ini', 'user', file='mysql.ini', section='mysqld') }}"
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- name: "Read mysql.ini allow_no_value=True"
|
||||
set_fact:
|
||||
test2: "{{ lookup('ini', 'user', file='mysql.ini', section='mysqld', allow_no_value=True) }}"
|
||||
|
||||
- name: "Read mysql.ini allow_none=True"
|
||||
set_fact:
|
||||
test3: "{{ lookup('ini', 'skip-innodb', file='mysql.ini', section='mysqld', allow_none=True) }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is failed
|
||||
- test2 == 'mysql'
|
||||
- test3 == []
|
||||
- test3|length == 0
|
||||
@ -1,3 +1,4 @@
|
||||
- import_playbook: test_lookup_properties.yml
|
||||
- import_playbook: test_errors.yml
|
||||
- import_playbook: test_case_sensitive.yml
|
||||
- import_playbook: test_allow_no_value.yml
|
||||
|
||||
Loading…
Reference in New Issue