Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) add no_log option for 'opts' parameter #563

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/563_add_no_log_option.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- mount - add no_log option for opts parameter (https://github.com/ansible-collections/ansible.posix/pull/563).
11 changes: 11 additions & 0 deletions plugins/modules/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
description:
- Mount options (see fstab(5), or vfstab(4) on Solaris).
type: str
opts_no_log:
description:
- Do not log opts.
type: bool
default: false
version_added: 1.6.0
dump:
description:
- Dump (see fstab(5)).
Expand Down Expand Up @@ -209,6 +215,7 @@
src: //192.168.1.200/share
path: /mnt/smb_share
opts: "rw,vers=3,file_mode=0600,dir_mode=0700,dom={{ ad_domain }},username={{ ad_username }},password={{ ad_password }}"
opts_no_log: true
fstype: cifs
state: ephemeral
'''
Expand Down Expand Up @@ -768,6 +775,7 @@ def main():
fstype=dict(type='str'),
path=dict(type='path', required=True, aliases=['name']),
opts=dict(type='str'),
opts_no_log=dict(type='bool', default=False),
passno=dict(type='str', no_log=False, default='0'),
src=dict(type='path'),
backup=dict(type='bool', default=False),
Expand All @@ -781,6 +789,9 @@ def main():
),
)

if module.params['opts_no_log']:
module.no_log_values.add(module.params['opts'])

# solaris args:
# name, src, fstype, opts, boot, passno, state, fstab=/etc/vfstab
# linux args:
Expand Down
50 changes: 50 additions & 0 deletions tests/integration/targets/mount/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -739,3 +739,53 @@
- /tmp/myfs_A.img
- /tmp/myfs_B.img
- /tmp/myfs

- name: Block to test opts_no_log option
when: ansible_system == 'Linux'
block:
- name: Create an empty file
community.general.filesize:
path: /tmp/myfs.img
size: 1M
- name: Format FS
community.general.filesystem:
fstype: ext4
dev: /tmp/myfs.img
- name: Mount the FS with opts_no_log option true
ansible.posix.mount:
path: /tmp/myfs
src: /tmp/myfs.img
fstype: ext4
state: mounted
opts: rw
opts_no_log: true
register: mount_info
- name: Assert opts_no_log option true
ansible.builtin.assert:
that:
- mount_info.opts == 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER'
- name: Remount the FS with opts_no_log option false
ansible.posix.mount:
path: /tmp/myfs
src: /tmp/myfs.img
fstype: ext4
state: remounted
opts: rw,user
opts_no_log: false
register: mount_info
- name: Assert opts_no_log option false
ansible.builtin.assert:
that:
- mount_info.opts == 'rw,user'
always:
- name: Unmount FS
ansible.posix.mount:
path: /tmp/myfs
state: absent
- name: Remove the test FS
ansible.builtin.file:
path: '{{ item }}'
state: absent
loop:
- /tmp/myfs.img
- /tmp/myfs