Skip to content

Commit 12996b4

Browse files
committed
Copy tests from ansible-collections#10417.
1 parent cd67a79 commit 12996b4

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) Ansible Project
2+
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
k1="v1"
5+
jail_list="
6+
foo
7+
bar"

tests/integration/targets/sysrc/tasks/main.yml

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,67 @@
369369
- "value_2 == sysrc_equals_sign_2.value"
370370
- "value_2 == conf.spamd_flags"
371371

372+
##
373+
## sysrc - #10004 state=absent when using default settings will report `changed=true`
374+
##
375+
- name: Test that a key from /etc/defaults/rc.conf is not used to mark changed
376+
sysrc:
377+
name: dumpdev
378+
state: absent
379+
path: /tmp/10004.conf
380+
register: sysrc_10004_absent
381+
382+
- name: Ensure that the defaults are not consulted
383+
assert:
384+
that:
385+
- not sysrc_10004_absent.changed
386+
387+
- name: Test that a delimited key from /etc/defaults/rc.conf is not used to mark changed
388+
sysrc:
389+
name: rc_conf_files
390+
state: value_absent
391+
path: /tmp/10004.conf
392+
register: sysrc_10004_value_absent
393+
394+
- name: Ensure that the default is not consulted
395+
assert:
396+
that:
397+
- not sysrc_10004_value_absent.changed
398+
399+
##
400+
## sysrc - #10394 Ensure that files with multi-line values work
401+
##
402+
- name: Copy 10394.conf
403+
copy:
404+
src: 10394.conf
405+
dest: /tmp/10394.conf
406+
407+
- name: Change value for k1
408+
sysrc:
409+
name: k1
410+
value: v2
411+
path: /tmp/10394.conf
412+
register: sysrc_10394_changed
413+
414+
- name: Get file content
415+
shell: "cat /tmp/10394.conf"
416+
register: sysrc_10394_content
417+
418+
- name: Ensure sysrc changed k1 from v1 to v2
419+
assert:
420+
that:
421+
- sysrc_10394_changed.changed
422+
- >
423+
'k1="v2"' in sysrc_10394_content.stdout_lines
424+
372425
always:
373426

374427
- name: Restore /etc/rc.conf
375428
copy:
376-
content: "{{ cached_etc_rcconf_content }}"
429+
content: "{{ cached_etc_rcconf_content.stdout }}"
377430
dest: /etc/rc.conf
378431

379432
- name: Restore /boot/loader.conf
380433
copy:
381-
content: "{{ cached_boot_loaderconf_content }}"
434+
content: "{{ cached_boot_loaderconf_content.stdout }}"
382435
dest: /boot/loader.conf

0 commit comments

Comments
 (0)