Compare commits

...

23 commits

Author SHA1 Message Date
Mohammed Naser
fad023eea0
Merge b12095af90 into 1b9ae1c77f 2024-11-27 09:24:34 -03:00
softwarefactory-project-zuul[bot]
1b9ae1c77f
Merge pull request #593 from saito-hideki/pr/replace_freebsd
Replace FreeBSD 13.3 with 13.4 and add FreeBSD 14.1 for devel

SUMMARY
Replace FreeBSD 13.3 with 13.4 and add FreeBSD 14.1 for integration test environments for ansible-core devel branch.
ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION

None
2024-11-14 05:45:26 +00:00
Hideki Saito
ae95adcfdc
Replace FreeBSD 13.3 with 13.4 and add FreeBSD 14.1 for devel
It's for integration test environments for ansible-core devel.

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-11-14 14:23:53 +09:00
softwarefactory-project-zuul[bot]
c654bf0b4c
Merge pull request #588 from saito-hideki/pr/enable_test_for_devel
[CI] enabled integration tests for devel branch

SUMMARY
Enabled integration tests for devel branch

Remote tests
Docker tests

ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2024-11-06 02:32:26 +00:00
Hideki Saito
04283b5993
[CI] enable integration tests for devel branch
* Remote tests
* Docker tests

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-11-06 11:07:13 +09:00
softwarefactory-project-zuul[bot]
b0097bd14c
Merge pull request #587 from saito-hideki/issue/587
Update README to cover RH guidelines

SUMMARY
This PR updates README.md to cover Red Hat guidelines
Also, this new content aligns with the community template content guidelines.

Fixes #585

ISSUE TYPE

Docs Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-11-05 14:08:33 +00:00
Hideki Saito
b991f4f9af
Update README to cover RH guidelines
* Fixes #585

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-11-05 21:30:07 +09:00
softwarefactory-project-zuul[bot]
5eacaba86d
Merge pull request #584 from saito-hideki/issue/582
Changed the type of the forward and masquerade options from str to bool

SUMMARY
The forward and masquerade options for the firewall module takes either True or False as a value.
Currently, it is defined as a string, but it should be a boolean.

Fixes #582

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix.firewalld

ADDITIONAL INFORMATION
None

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
2024-10-31 23:26:30 +00:00
Hideki Saito
8b611775d6
Changed the type of forward and masquerade options from str to bool
* Breaking Change
* Fixes #582

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-10-31 16:06:10 +09:00
softwarefactory-project-zuul[bot]
9171b7fcf1
Merge pull request #581 from saito-hideki/pr/selinux_integration_test
[CI] Modify conditions for selinux integratuion tests

SUMMARY
Conditions for selinux integration tests have been modified to be more accurate.
This fix only affects integration tests, so it will not affect module behavior.
ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix.selinux

ADDITIONAL INFORMATION
None
2024-10-15 23:58:44 +00:00
Hideki Saito
2f095566c7
Modify conditions for selinux integratuion tests
Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-10-15 17:15:51 +09:00
softwarefactory-project-zuul[bot]
daca208c0b
Merge pull request #576 from saito-hideki/bump_version_2.0.0
Bump version info to 2.0.0 on main branch

SUMMARY
Bump version 2.0.0 for the next release.

fixes #575

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

galaxy.yml

ADDITIONAL INFORMATION
None
2024-10-11 07:44:38 +00:00
Hideki Saito
4d928119de
Bump version 2.0.0 for the next release
* main branch

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-10-11 16:20:58 +09:00
Hideki Saito
906bbb88b7
Revert "Revert "Merge pull request #568 from abakanovskii/feature/add_path_option_authorized_key""
This reverts commit 098b5bee70.
2024-10-09 15:41:37 +09:00
Hideki Saito
57be05289c
Revert "Revert "Merge pull request #387 from ansiblejunky/fix-callback-output""
This reverts commit 3a085b0b10.
2024-10-09 15:41:22 +09:00
Hideki Saito
9df5aac2a5
Revert "Revert "Merge pull request #556 from Akasurde/i350""
This reverts commit cd43bd10bb.
2024-10-09 15:36:53 +09:00
Hideki Saito
098b5bee70
Revert "Merge pull request #568 from abakanovskii/feature/add_path_option_authorized_key"
This reverts commit 0821768bcb, reversing
changes made to 5321a9ecb5.
2024-10-09 15:33:16 +09:00
Hideki Saito
3a085b0b10
Revert "Merge pull request #387 from ansiblejunky/fix-callback-output"
This reverts commit f4baa4c6d8, reversing
changes made to 0821768bcb.
2024-10-09 15:32:45 +09:00
Hideki Saito
cd43bd10bb
Revert "Merge pull request #556 from Akasurde/i350"
This reverts commit 9a2ddcd713, reversing
changes made to 7d219a7e05.
2024-10-09 15:32:23 +09:00
softwarefactory-project-zuul[bot]
9cf2d8cc48
Merge pull request #365 from copyrights/last_wins
mount: remove boot exception if defaults in opts

SUMMARY

There is no need for an exception on defaults option when adding noauto. Mount is implemented as last win.
from mount(8):
       If you want to override mount options from /etc/fstab, you have to use the -o option:

          mount device|dir -o options

       and then the mount options from the command line will be appended to the list of options from /etc/fstab. This default behaviour can be changed using the --options-mode command-line option. The usual behavior is that the last
       option wins if there are conflicting ones.


Fixes #364
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME


ansible.posix.mount

ADDITIONAL INFORMATION

Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-10-04 06:21:14 +00:00
copyrights
2041e7f918
mount: remove boot exception if defaults in opts 2024-10-04 14:39:04 +09:00
Abhijeet Kasurde
b12095af90 Add changelog fragment
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-17 15:58:15 -07:00
Mohammed Naser
baea26a137 synchronize: use _find_needle instead 2024-07-17 15:57:04 -07:00
17 changed files with 121 additions and 143 deletions

View file

@ -203,8 +203,10 @@ stages:
targets:
- name: RHEL 9.4
test: rhel/9.4
- name: FreeBSD 13.3
test: freebsd/13.3
- name: FreeBSD 14.1
test: freebsd/14.1
- name: FreeBSD 13.4
test: freebsd/13.4
- stage: Remote_2_18
displayName: Remote devel
dependsOn: []
@ -279,7 +281,7 @@ stages:
- Remote_2_18
- Docker_2_18
- Sanity_devel
# - Remote_devel # Wait for test environment release
# - Docker_devel # Wait for test environment release
- Remote_devel
- Docker_devel
jobs:
- template: templates/coverage.yml

104
README.md
View file

@ -4,9 +4,6 @@
https://dev.azure.com/ansible/ansible.posix/_apis/build/status/CI?branchName=main)](https://dev.azure.com/ansible/ansible.posix/_build?definitionId=26)
[![Run Status](https://api.shippable.com/projects/5e669aaf8b17a60007e4d18d/badge?branch=main)]() <!--[![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/ansible.posix)](https://codecov.io/gh/ansible-collections/ansible.posix)-->
<!-- Describe the collection and why a user would want to use it. What does the collection do? -->
An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and derivative Operating Systems.
## Communication
* Join the Ansible forum:
@ -14,65 +11,72 @@ An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and de
* [Social Spaces](https://forum.ansible.com/c/chat/4): gather and interact with fellow enthusiasts.
* [News & Announcements](https://forum.ansible.com/c/news/5): track project-wide announcements including social events.
* The Ansible [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn): used to announce releases and important changes.
## Description
For more information about communication, see the [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
<!-- Describe the collection and why a user would want to use it. What does the collection do? -->
An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and derivative Operating Systems.
## Supported Versions of Ansible
<!--start requires_ansible-->
## Ansible version compatibility
## Requirements
This collection has been tested against following Ansible versions: **>=2.15**.
<!--end requires_ansible-->
* Python:
* The Python interpreter version must meet Ansible Core's requirements.
* Ansible Core:
- ansible-core 2.15 or later
## Included content
Check out [Ansible Galaxy](https://galaxy.ansible.com/ui/repo/published/ansible/posix/content/) or [the Ansible documentation](https://docs.ansible.com/ansible/devel/collections/ansible/posix/) for all modules and plugins included in this collection.
## Installation
## Installing this collection
Before using this collection, you need to install it with the Ansible Galaxy command-line tool:
You can install the ``ansible.posix`` collection with the Ansible Galaxy CLI:
```shell
ansible-galaxy collection install ansible.posix
```
ansible-galaxy collection install ansible.posix
You can also include it in a requirements.yml file and install it with ansible-galaxy collection install -r requirements.yml, using the format:
You can also include it in a `requirements.yml` file and install it with `ansible-galaxy collection install -r requirements.yml`, using the format:
```yaml
---
collections:
- name: ansible.posix
```
## Using this collection
Note that if you install any collections from Ansible Galaxy, they will not be upgraded automatically when you upgrade the Ansible package.
To upgrade the collection to the latest available version, run the following command:
<!--Include some quick examples that cover the most common use cases for your collection content. -->
```shell
ansible-galaxy collection install ansible.posix --upgrade
```
See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details.
You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version 1.0.0:
## Contributing to this collection
```shell
ansible-galaxy collection install ansible.posix:==1.0.0
```
<!--Describe how the community can contribute to your collection. At a minimum, include how and where users can create issues to report problems or request features for this collection. List contribution requirements, including preferred workflows and necessary testing, so you can benefit from community PRs. If you are following general Ansible contributor guidelines, you can link to - [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html). -->
See [using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for more details.
We welcome community contributions to this collection. See [Contributing to Ansible-maintained collections](https://docs.ansible.com/ansible/devel/community/contributing_maintained_collections.html#contributing-maintained-collections) for complete details.
* The Ansible [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn): used to announce releases and important changes.
* [Issues](https://github.com/ansible-collections/ansible.posix/issues)
* [Pull Requests](https://github.com/ansible-collections/ansible.posix/pulls)
* [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html)
For more information about communication, see the [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
### Code of Conduct
This collection follows the Ansible project's
[Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html).
Please read and familiarize yourself with this document.
## Use Cases
## Release notes
See [changelog](https://github.com/ansible-collections/ansible.posix/blob/main/CHANGELOG.rst) for more details.
You can see the general use-cases as an example by `ansible-doc` command like below.
## External requirements
For example, ansible.posix.firewalld module:
```shell
ansible-doc ansible.posix.firewalld
```
None
Also, if you want to confirm the plugins descriptions, you can follow the following option with `ansible-doc` command:
## Tested with Ansible
For example, ansible.posix.profile_tasks callback plugin:
```shell
ansible-doc -t callback ansible.posix.profile_tasks
```
<!-- List the versions of Ansible the collection has been tested with. Must match what is in galaxy.yml. -->
## Testing
The following ansible-core versions have been tested with this collection:
- ansible-core 2.19 (devel)
- ansible-core 2.18 (stable) *
@ -80,22 +84,30 @@ None
- ansible-core 2.16 (stable)
- ansible-core 2.15 (stable)
*Note: For ansible-core 2.18, CI only covers sanity tests and no integration tests will be run until the test environment is released.*
## Contributing
## Roadmap
We welcome community contributions to this collection. For more details, see [Contributing to Ansible-maintained collections](https://docs.ansible.com/ansible/devel/community/contributing_maintained_collections.html#contributing-maintained-collections) for complete details.
<!-- Optional. Include the roadmap for this collection, and the proposed release/versioning strategy so users can anticipate the upgrade/update cycle. -->
* [Issues](https://github.com/ansible-collections/ansible.posix/issues)
* [Pull Requests](https://github.com/ansible-collections/ansible.posix/pulls)
* [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html)
## More information
<!-- List out where the user can find additional information, such as working group meeting times, slack/IRC channels, or documentation for the product this collection automates. At a minimum, link to: -->
## Support
- [Ansible Collection overview](https://github.com/ansible-collections/overview)
- [Ansible User guide](https://docs.ansible.com/ansible/latest/user_guide/index.html)
- [Ansible Developer guide](https://docs.ansible.com/ansible/latest/dev_guide/index.html)
- [Ansible Community code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html)
See [Communication](#Communication) section.
## Licensing
## Release Notes and Roadmap
See [changelog](https://github.com/ansible-collections/ansible.posix/blob/main/CHANGELOG.rst) for more details.
## Related Information
This document was written using the following [template](https://access.redhat.com/articles/7068606).
The README has been carefully prepared to cover the [community template](https://github.com/ansible-collections/collection_template/blob/main/README.md), but if you find any problems, please file a [documentation issue](https://github.com/ansible-collections/ansible.posix/issues/new?assignees=&labels=&projects=&template=documentation_report.md).
## License Information
GNU General Public License v3.0 or later.

View file

@ -0,0 +1,3 @@
---
bugfixes:
- mount - Handle ``boot`` option on Linux, NetBSD and OpenBSD correctly (https://github.com/ansible-collections/ansible.posix/issues/364).

View file

@ -0,0 +1,3 @@
---
trivial:
- Bump ansible.posix version to 2.0.0.

View file

@ -0,0 +1,3 @@
---
trivial:
- selinux - conditions for selinux integration tests have been modified to be more accurate.

View file

@ -0,0 +1,3 @@
---
breaking_changes:
- firewalld - Changed the type of forward and masquerade options from str to bool (https://github.com/ansible-collections/ansible.posix/issues/582).

View file

@ -0,0 +1,3 @@
---
trivial:
- README.md - update README to cover RH guidelines (https://github.com/ansible-collections/ansible.posix/issues/585).

View file

@ -0,0 +1,3 @@
---
trivial:
- Enabled remote and docker integration tests for devel branch.

View file

@ -0,0 +1,3 @@
---
trivial:
- Replaced FreeBSD version 13.3 with 13.4 and 14.1 in CI for devel branch.

View file

@ -0,0 +1,3 @@
---
bugfixes:
- synchronize - use _find_needle to find the file in path (https://github.com/ansible-collections/ansible.posix/issues/381).

View file

@ -1,7 +1,7 @@
---
namespace: ansible
name: posix
version: 1.6.1
version: 2.0.0
readme: README.md
authors:
- Ansible (github.com/ansible)

View file

@ -48,10 +48,7 @@ class ActionModule(ActionBase):
if ':' in path or path.startswith('/'):
return path
if self._task._role is not None:
path = self._loader.path_dwim_relative(self._task._role._role_path, 'files', path)
else:
path = self._loader.path_dwim_relative(self._loader.get_basedir(), 'files', path)
path = self._find_needle('files', path)
if original_path and original_path[-1] == '/' and path[-1] != '/':
# make sure the dwim'd path ends in a trailing "/"

View file

@ -112,11 +112,13 @@ options:
description:
- The forward setting you would like to enable/disable to/from zones within firewalld.
- This option only is supported by firewalld v0.9.0 or later.
type: str
- Note that the option type is changed to bool in ansible.posix version 2.0.0 and later.
type: bool
masquerade:
description:
- The masquerade setting you would like to enable/disable to/from zones within firewalld.
type: str
- Note that the option type is changed to bool in ansible.posix version 2.0.0 and later.
type: bool
offline:
description:
- Ignores O(immediate) if O(permanent=true) and firewalld is not running.
@ -875,8 +877,8 @@ def main():
state=dict(type='str', required=True, choices=['absent', 'disabled', 'enabled', 'present']),
timeout=dict(type='int', default=0),
interface=dict(type='str'),
forward=dict(type='str'),
masquerade=dict(type='str'),
forward=dict(type='bool'),
masquerade=dict(type='bool'),
offline=dict(type='bool', default=False),
target=dict(type='str', choices=['default', 'ACCEPT', 'DROP', '%%REJECT%%']),
),
@ -1129,16 +1131,7 @@ def main():
msgs = msgs + transaction_msgs
if forward is not None:
# Type of forward will be changed to boolean in a future release.
forward_status = False
try:
forward_status = boolean(forward, False)
except TypeError:
module.warn('The value of the forward option is "%s". '
'The type of the option will be changed from string to boolean in a future release. '
'To avoid unexpected behavior, please change the value to boolean.' % forward)
expected_state = 'enabled' if (desired_state == 'enabled') == forward_status else 'disabled'
expected_state = 'enabled' if (desired_state == 'enabled') == forward else 'disabled'
transaction = ForwardTransaction(
module,
action_args=(),
@ -1152,16 +1145,7 @@ def main():
msgs = msgs + transaction_msgs
if masquerade is not None:
# Type of masquerade will be changed to boolean in a future release.
masquerade_status = True
try:
masquerade_status = boolean(masquerade, True)
except TypeError:
module.warn('The value of the masquerade option is "%s". '
'The type of the option will be changed from string to boolean in a future release. '
'To avoid unexpected behavior, please change the value to boolean.' % masquerade)
expected_state = 'enabled' if (desired_state == 'enabled') == masquerade_status else 'disabled'
expected_state = 'enabled' if (desired_state == 'enabled') == masquerade else 'disabled'
transaction = MasqueradeTransaction(
module,
action_args=(),

View file

@ -850,11 +850,8 @@ def main():
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")
elif not module.params['boot']:
args['boot'] = 'no'
if 'defaults' in opts:
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'defaults'.")
else:
opts.append('noauto')
args['opts'] = ','.join(opts)
opts.append('noauto')
args['opts'] = ','.join(opts)
# If fstab file does not exist, we first need to create it. This mainly
# happens when fstab option is passed to the module.

View file

@ -114,60 +114,3 @@
ansible.builtin.assert:
that:
- result is not changed
# Validate backwards compatible behavior until masquerade is switched from string to boolean type
- name: Masquerade enabled when masquerade is non-boolean string and state is enabled
block:
- name: Testing enable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: some string
permanent: true
state: enabled
register: result
- name: Assert masquerade is enabled
ansible.builtin.assert:
that:
- result is changed
- name: Testing enable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: some string
permanent: true
state: enabled
register: result
- name: Assert masquerade is enabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: Masquerade disabled when masquerade is non-boolean string and state is disabled
block:
- name: Testing disable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: some string
permanent: true
state: disabled
register: result
- name: Assert masquerade is disabled
ansible.builtin.assert:
that:
- result is changed
- name: Testing disable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: some string
permanent: true
state: disabled
register: result
- name: Assert masquerade is disabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed

View file

@ -472,6 +472,25 @@
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: false
register: mount_info
- name: Assert the mount without noauto was successful
ansible.builtin.assert:
that:
- "'noauto' in mount_info['opts'].split(',')"
- name: Unmount FS
ansible.posix.mount:
path: /tmp/myfs
state: absent
- name: Remove the test FS
ansible.builtin.file:
path: '{{ item }}'

View file

@ -128,8 +128,8 @@
ansible.builtin.assert:
that:
- selinux_config_original | length == selinux_config_after | length
- selinux_config_after[selinux_config_after.index('SELINUX=disabled')] is search("^SELINUX=\w+$")
- selinux_config_after[selinux_config_after.index('SELINUXTYPE=targeted')] is search("^SELINUXTYPE=\w+$")
- (selinux_config_after | select("search", "^SELINUX=disabled\s*$") | list | length) > 0
- (selinux_config_after | select("search", "^SELINUXTYPE=targeted\s*$") | list | length) > 0
- name: TEST 1 | Disable SELinux again, with kernel arguments update
ansible.posix.selinux: