mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-03-10 03:25:22 +01:00
Compare commits
14 commits
b6d30f8b30
...
d249a8752e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d249a8752e | ||
|
|
34f140c22f | ||
|
|
83c4d2abd1 | ||
|
|
e5733c5e49 | ||
|
|
d49bd27fae | ||
|
|
9064ff7eb2 | ||
|
|
a842e5f96a | ||
|
|
97dcdee670 | ||
|
|
55ea4ba1de | ||
|
|
a88f5f8ae0 | ||
|
|
f392e407f9 | ||
|
|
c77c592fc6 | ||
|
|
02006a1e7f | ||
|
|
1512495dd7 |
6 changed files with 63 additions and 7 deletions
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- sysctl - fix sysctl to work properly on symlinks (https://github.com/ansible-collections/ansible.posix/issues/111).
|
||||||
3
changelogs/fragments/346-boot-linux.yml
Normal file
3
changelogs/fragments/346-boot-linux.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
bugfix:
|
||||||
|
- mount - Handle ``boot`` option on Linux, NetBSD and OpenBSD correctly (https://github.com/ansible-collections/ansible.posix/issues/364).
|
||||||
|
|
@ -840,11 +840,8 @@ def main():
|
||||||
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")
|
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")
|
||||||
elif not module.params['boot']:
|
elif not module.params['boot']:
|
||||||
args['boot'] = 'no'
|
args['boot'] = 'no'
|
||||||
if 'defaults' in opts:
|
opts.append('noauto')
|
||||||
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'defaults'.")
|
args['opts'] = ','.join(opts)
|
||||||
else:
|
|
||||||
opts.append('noauto')
|
|
||||||
args['opts'] = ','.join(opts)
|
|
||||||
|
|
||||||
# If fstab file does not exist, we first need to create it. This mainly
|
# If fstab file does not exist, we first need to create it. This mainly
|
||||||
# happens when fstab option is passed to the module.
|
# happens when fstab option is passed to the module.
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,7 @@ class SysctlModule(object):
|
||||||
# Completely rewrite the sysctl file
|
# Completely rewrite the sysctl file
|
||||||
def write_sysctl(self):
|
def write_sysctl(self):
|
||||||
# open a tmp file
|
# open a tmp file
|
||||||
fd, tmp_path = tempfile.mkstemp('.conf', '.ansible_m_sysctl_', os.path.dirname(self.sysctl_file))
|
fd, tmp_path = tempfile.mkstemp('.conf', '.ansible_m_sysctl_', os.path.dirname(os.path.realpath(self.sysctl_file)))
|
||||||
f = open(tmp_path, "w")
|
f = open(tmp_path, "w")
|
||||||
try:
|
try:
|
||||||
for l in self.fixed_lines:
|
for l in self.fixed_lines:
|
||||||
|
|
@ -377,7 +377,7 @@ class SysctlModule(object):
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# replace the real one
|
# replace the real one
|
||||||
self.module.atomic_move(tmp_path, self.sysctl_file)
|
self.module.atomic_move(tmp_path, os.path.realpath(self.sysctl_file))
|
||||||
|
|
||||||
|
|
||||||
# ==============================================================
|
# ==============================================================
|
||||||
|
|
|
||||||
|
|
@ -467,6 +467,25 @@
|
||||||
that:
|
that:
|
||||||
- mount_info['opts'] == 'rw,user,async,noauto'
|
- mount_info['opts'] == 'rw,user,async,noauto'
|
||||||
|
|
||||||
|
- name: Unmount FS
|
||||||
|
ansible.posix.mount:
|
||||||
|
path: /tmp/myfs
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Mount the FS with noauto option and defaults
|
||||||
|
ansible.posix.mount:
|
||||||
|
path: /tmp/myfs
|
||||||
|
src: /tmp/myfs.img
|
||||||
|
fstype: ext3
|
||||||
|
state: mounted
|
||||||
|
boot: no
|
||||||
|
register: mount_info
|
||||||
|
|
||||||
|
- name: Assert the mount without noauto was successful
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- "'noauto' in mount_info['opts'].split(',')"
|
||||||
|
|
||||||
- name: Unmount FS
|
- name: Unmount FS
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
|
|
|
||||||
|
|
@ -332,3 +332,37 @@
|
||||||
that:
|
that:
|
||||||
- sysctl_invalid_set1 is failed
|
- sysctl_invalid_set1 is failed
|
||||||
- "'vm.mmap_rnd_bits' not in sysctl_invalid_conf_content.stdout"
|
- "'vm.mmap_rnd_bits' not in sysctl_invalid_conf_content.stdout"
|
||||||
|
|
||||||
|
# Test sysctl: sysctl_file is symlink
|
||||||
|
- name: Create link source
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: |
|
||||||
|
# Testing Ansible Sysctl module on symlink.
|
||||||
|
dest: /tmp/ansible_sysctl_test.conf
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Create symlink to the conf file
|
||||||
|
ansible.builtin.file:
|
||||||
|
src: /tmp/ansible_sysctl_test.conf
|
||||||
|
dest: /tmp/ansible_sysctl_test_symlink.conf
|
||||||
|
state: link
|
||||||
|
|
||||||
|
- name: Use sysctl module with symlink sysctl file
|
||||||
|
ansible.posix.sysctl:
|
||||||
|
name: 'kernel.randomize_va_space'
|
||||||
|
value: '1'
|
||||||
|
sysctl_file: /tmp/ansible_sysctl_test_symlink.conf
|
||||||
|
state: present
|
||||||
|
sysctl_set: false
|
||||||
|
reload: false
|
||||||
|
|
||||||
|
- name: Stat sysctl file
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /tmp/ansible_sysctl_test_symlink.conf
|
||||||
|
register: stat_result
|
||||||
|
|
||||||
|
- name: Ensure the sysctl file remains a symlink
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- stat_result.stat.islnk is defined and stat_result.stat.islnk
|
||||||
|
- stat_result.stat.lnk_source == '/tmp/ansible_sysctl_test.conf'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue