Commit graph

115 commits

Author SHA1 Message Date
Hideki Saito
90cdaf873d Added loading StrictVersion to helper module
Signed-off-by: Hideki Saito <saito@fgrep.org>
2022-01-07 03:17:32 +00:00
Abhijeet Kasurde
44a23e363b
Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
2022-01-06 20:50:07 +05:30
Hideki Saito
a45448bb26 Replace distutils with included module in ansible-core 2.12
- Fixes #303
- Addresses PEP 632(https://www.python.org/dev/peps/pep-0632/)

Signed-off-by: Hideki Saito <saito@fgrep.org>
2022-01-06 13:53:36 +05:30
Hideki Saito
667ebef95c Refine the handling of exclusive options using mutually_exclusive
- Fixes #255

Signed-off-by: Hideki Saito <saito@fgrep.org>
2021-11-29 18:46:28 +09:00
ansible-zuul[bot]
90385b97d8
Merge pull request #288 from nerrehmit/main
Remove deprecated option from nfs mount example

SUMMARY
This removes the intr option from the documentation example for nfs mounts.
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
mount.py
ADDITIONAL INFORMATION
According to the nfs manpage the intr/ nointr option has been deprecated with Kernel 2.6.25 which was released in April 2008 wiki
Even RHEL 6.10 which is already on Extended life cycle support is using a newer 2.6 Kernel. https://access.redhat.com/articles/3078
This does not change any module functionality. It simply removes the option from the nfs mount example.

Reviewed-by: None <None>
2021-11-12 18:28:25 +00:00
Tim Herren
40a9ff36bb Remove deprecated option from nfs mount example 2021-11-08 16:14:01 +01:00
Hideki Saito
2768c58f90 Add python-firewall to requirements of firewalld
- Fixes #286

Signed-off-by: Hideki Saito <saito@fgrep.org>
2021-11-07 10:20:12 +09:00
Mike Wallis
d1be5519e6 Whitespaces in paths or current working directory path of playbook causes rsync to incorrectly chdir to current source dir,
Example :

cd "/home/a/ansible plays"

task:
  - synchronize:
      src: a
      dest: b

Results in the following error being thrown

fatal: [remote-host]: FAILED! => {"changed": false, "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh='/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path='sudo -u root rsync' --out-format='<<CHANGED>>%i %n%L' /home/a/ansible plays/deployments// remote-user@remote-host:/data/", "msg": "rsync: [sender] link_stat \"/home/a/ansible\" failed: No such file or directory (2)\nrsync: [sender] change_dir \"/home/a/ansible plays/plays/a/\" failed: No such file or directory (2)\nrsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=3.2.3]\n", "rc": 23}
2021-10-25 19:44:43 +01:00
Hideki Saito
5a2b3662cb mount - add a newline at the end of line in fstab
* Fixes #210

Signed-off-by: Hideki Saito <saito@fgrep.org>
2021-09-27 12:19:06 +09:00
ansible-zuul[bot]
595ee76b69
Merge pull request #142 from WOnder93/selinux-disable-kernel
selinux: update kernel boot params when disabling/re-enabling SELinux

SUMMARY
The ability to disable SELinux from userspace based on the configuration
file is being deprecated in favor of the selinux=0 kernel boot
parameter. (Note that this affects only the "full" disable; switching
to/from permissive mode will work the same as before.)
Therefore, enhance the selinux module to try to set/unset the kernel
command-line parameter using grubby when enabling/disabling SELinux.
If the grubby package is not present on the system, the module will only
update the config file and report a warning. Note that even with the
runtime disable functionality removed, setting SELINUX=disabled in the
config file will lead to a system with no SELinux policy loaded, which
will behave in a very similar way as if SELinux was fully disabled, only
there could still be some minor performance impact, since the kernel
hooks will still be active.
More information:
https://lore.kernel.org/selinux/157836784986.560897.13893922675143903084.stgit@chester/
https://fedoraproject.org/wiki/Changes/Remove_Support_For_SELinux_Runtime_Disable
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
selinux module

Reviewed-by: Adam Miller <maxamillion@fedoraproject.org>
Reviewed-by: Ondrej Mosnáček <omosnacek@gmail.com>
Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: quidame <None>
Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: None <None>
2021-09-24 12:20:44 +00:00
ansible-zuul[bot]
96c342fd67
Merge pull request #263 from saito-hideki/issue/83
profile_tasks - Correctly calculate task execution time with serial execution

SUMMARY
Correctly calculate task execution time with serial execution

Fixes #83

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix.profile_tasks

ADDITIONAL INFORMATION
After applying this PR, I can confirm that the task execution time with serial execution is correct:

Test playbook:

---
- hosts: issue_83
  gather_facts: false
  connection: local
  serial: 1

  tasks:
    - name: TASK_A
      shell: sleep 3
    - name: TASK_B
      shell: sleep 5
    - name: TASK_C
      shell: sleep 1

Results:

$ ansible-playbook -i inventory playbook/profile_tasks/issue_83.yml 
[DEPRECATION WARNING]: [defaults]callback_whitelist option, normalizing names 
to new standard, use callback_enabled instead. This feature will be removed 
from ansible-core in version 2.15. Deprecation warnings can be disabled by 
setting deprecation_warnings=False in ansible.cfg.

PLAY [issue_83] ****************************************************************

TASK [TASK_A] ******************************************************************
Friday 10 September 2021  12:40:58 +0900 (0:00:00.008)       0:00:00.008 ****** 
changed: [server100]

TASK [TASK_B] ******************************************************************
Friday 10 September 2021  12:41:02 +0900 (0:00:03.210)       0:00:03.219 ****** 
changed: [server100]

TASK [TASK_C] ******************************************************************
Friday 10 September 2021  12:41:07 +0900 (0:00:05.173)       0:00:08.392 ****** 
changed: [server100]

PLAY [issue_83] ****************************************************************

TASK [TASK_A] ******************************************************************
Friday 10 September 2021  12:41:08 +0900 (0:00:01.146)       0:00:09.539 ****** 
changed: [server101]

TASK [TASK_B] ******************************************************************
Friday 10 September 2021  12:41:11 +0900 (0:00:03.185)       0:00:12.724 ****** 
changed: [server101]

TASK [TASK_C] ******************************************************************
Friday 10 September 2021  12:41:16 +0900 (0:00:05.148)       0:00:17.873 ****** 
changed: [server101]

PLAY [issue_83] ****************************************************************

TASK [TASK_A] ******************************************************************
Friday 10 September 2021  12:41:17 +0900 (0:00:01.176)       0:00:19.050 ****** 
changed: [server102]

TASK [TASK_B] ******************************************************************
Friday 10 September 2021  12:41:21 +0900 (0:00:03.174)       0:00:22.224 ****** 
changed: [server102]

TASK [TASK_C] ******************************************************************
Friday 10 September 2021  12:41:26 +0900 (0:00:05.190)       0:00:27.415 ****** 
changed: [server102]

PLAY RECAP *********************************************************************
server100                  : ok=3    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
server101                  : ok=3    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
server102                  : ok=3    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Friday 10 September 2021  12:41:27 +0900 (0:00:01.173)       0:00:28.588 ****** 
=============================================================================== 
TASK_B ----------------------------------------------------------------- 15.51s
TASK_A ------------------------------------------------------------------ 9.57s
TASK_C ------------------------------------------------------------------ 3.50s

Reviewed-by: Andrew Klychkov <aaklychkov@mail.ru>
Reviewed-by: None <None>
2021-09-21 01:07:49 +00:00
Ondrej Mosnacek
53d47e1763 selinux: update kernel boot params when disabling/re-enabling SELinux
The ability to disable SELinux from userspace based on the configuration
file is being deprecated in favor of the selinux=0 kernel boot
parameter. (Note that this affects only the "full" disable; switching
to/from permissive mode will work the same as before.)

Therefore, add an 'update_kernel_param' module parameter that will cause
it to set/unset the kernel command-line parameter using grubby when
enabling/disabling SELinux. (An explicit parameter was chosen for
backwards compatibility.)

More information:
https://lore.kernel.org/selinux/157836784986.560897.13893922675143903084.stgit@chester/
https://fedoraproject.org/wiki/Changes/Remove_Support_For_SELinux_Runtime_Disable

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2021-09-20 10:09:54 +05:30
Hideki Saito
3d57a17ed6 Correctly calculate task execution time with serial execution
- Fixes #83

Signed-off-by: Hideki Saito <saito@fgrep.org>
2021-09-10 13:21:37 +09:00
Simon Legner
1626c3d5e6 docs(authorized_key): add lookup.url example 2021-09-08 08:00:56 +02:00
Hideki Saito
4a67de7b08 Display warning message if wrong parameter set to masquerade or icmp-block-inversion
* This PR is a part of #249

Signed-off-by: Hideki Saito <saito@fgrep.org>
2021-09-06 09:14:34 +09:00
Abhijeet Kasurde
12941f6d9a firewalld: Correct usage of queryForwardPort
* Correct queryForwardPort API usage
* Enable port_foward_test_cases tests

Fixes: #247

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-08-16 14:12:22 +05:30
Abhijeet Kasurde
a65807edc3
synchronize: Use SSH args from SSH connection plugins (#223)
SSH configuration migrated from Ansible configuration to
SSH connection configuration. Make ``synchronize`` understand
this.

Fixes: #222

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-08-11 10:45:52 +05:30
ansible-zuul[bot]
42d2b9c65a
Merge pull request #233 from piotrtrojanowski-dev/patch-2
Fix requires firewalld version in comments for permanent parameter.

SUMMARY
Version of firewalled seems to be wrong. 3.0.9 version of that package does not exist.
The latest release of firewalled: https://github.com/firewalld/firewalld/releases
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
ansible.posix.firewalld

Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: Andrew Klychkov <aaklychkov@mail.ru>
Reviewed-by: None <None>
2021-08-10 06:42:37 +00:00
Tadej Borovšak
db12a40a4c Synchronize: properly quote shell command components
The synchronize action plugin and module were a bit sloppy when it
came to the command-line parameter quoting and that caused failuer on
some systems (for example, on Fedora 34).

This commit makes sure any argumnts with potentially problematic
characters are quoted before being used.
2021-08-04 13:37:18 +02:00
Sagi Shnaidman
133ffe51fb Complete adding podman connection to synchronize 2021-08-03 15:44:00 +03:00
piotrtrojanowski-dev
2b7a35c346
Fix requires firewalld version in comments for permanent parameter. 2021-07-27 09:37:58 +02:00
Sagi Shnaidman
c5d49b2a91 Allow podman connections in synchronize module 2021-07-23 14:29:02 +03:00
ansible-zuul[bot]
a03e652437
Merge pull request #214 from saito-hideki/pr/add_firewalld_info
Add new firewalld_info module to ansible.posix collection

SUMMARY
Add new firewalld_info module to ansible.posix collection.

Gathering information about firewalld zone settings
fixes #98

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix.firewalld_info

ADDITIONAL INFORMATION
None

Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2021-07-21 05:19:13 +00:00
ansible-zuul[bot]
e815909859
Merge pull request #215 from quasd/main
fix REJECT target name

SUMMARY
Fix setting default target to reject. The target name is %%REJECT%% not REJECT.
https://firewalld.org/documentation/zone/options.html
After this pull request to way to set REJECT would be
  - name: "Set target to REJECT for public"
    ansible.posix.firewalld:
      zone: public
      permanent: yes
      target: '%%REJECT%%'
      state: enabled
    become: true


ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
firewalld
ADDITIONAL INFORMATION



This snippet would fail due to there not being target called REJECT and using %%REJECT%% is not in allowed values for target
  - name: "Set target to REJECT for public"
    ansible.posix.firewalld:
      zone: public
      permanent: yes
      target: 'REJECT'
      state: enabled
    become: true

Ansible error
{
    "msg": "ERROR: Exception caught: org.fedoraproject.FirewallD1.Exception: INVALID_TARGET: REJECT Permanent operation",
    "invocation": {
        "module_args": {
            "zone": "public",
            "permanent": true,
            "target": "REJECT",
            "state": "enabled",
            "immediate": false,
            "timeout": 0,
            "icmp_block": null,
            "icmp_block_inversion": null,
            "service": null,
            "port": null,
            "port_forward": null,
            "rich_rule": null,
            "source": null,
            "interface": null,
            "masquerade": null,
            "offline": null
        }
    },
    "_ansible_no_log": false,
    "changed": false
}

syslog
Jun 29 09:49:39 <hostname retracted> ansible-ansible.posix.firewalld[9015]: Invoked with zone=public permanent=True state=enabled target=REJECT immediate=False timeout=0 icmp_[1850/7279] icmp_block_inversion=None service=None port=None port_forward=None rich_rule=None source=None interface=None masquerade=None offline=None                                                                 
Jun 29 09:49:39 <hostname retracted>  firewalld[915]: ERROR: INVALID_TARGET: REJECT

Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: None <None>
Reviewed-by: Amin Vakil <info@aminvakil.com>
Reviewed-by: quidame <None>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2021-07-14 17:05:30 +00:00
ansible-zuul[bot]
f2601b01da
Merge pull request #213 from ndgit/fix-24-and-190
synchronize: quotes around arguments

fix quoting for specific cmd arguments
Fixes:

#24
#190

ISSUE TYPE:

Bugfix Pull Request

COMPONENT NAME:
module: synchronize

Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: Robert Rettig <None>
Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: Mike Graves <mgraves@redhat.com>
2021-07-14 15:20:20 +00:00
Hideki Saito
27434455e5 Add new firewalld_info module to ansible.posix collection
* fixes #98

Signed-off-by: Hideki Saito <saito@fgrep.org>
2021-07-09 23:47:12 +09:00
ansible-zuul[bot]
f6fa00bfff
Merge pull request #187 from smemsh/fix-synchronize-become-user
synchronize: fix to honor become_user when become_method sudo

SUMMARY

When become_method is sudo, the synchronize module ignores become_user, always running as root.  This means one cannot create files as a target user, when they need to get in via a third user and can only sudo via that one.  In my case, I'm connecting via a special provisioning user that has sudo privs, but I need to create the files as the become_user.  I'm using it to deposit skeleton files, and there should be no reason to run another task with chown; after all, the documentation already describes the desired behavior:

The user and permissions for the synchronize dest are those of the remote_user on the destination host or the become_user if become=yes is active.

This patch takes the running become_user (if it's not None) and adds it to the sudo command with the -u command line option, so the file gets created correctly.  I have tested this and it works.
Other become_methods are ignored, but they already were anyways (the code already has a TODO to add other methods, which we don't attempt in this patch)
Fixes #186

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

synchronize
ADDITIONAL INFORMATION


See reproduction in #186.
This appears to have been in place since ansible/ansible@811a906

Reviewed-by: Amin Vakil <info@aminvakil.com>
Reviewed-by: Sumit Jaiswal <sjaiswal@redhat.com>
2021-07-08 14:16:12 +00:00
Mandar Kulkarni
b740bdaf3a Merge https://github.com/ansible-collections/ansible.posix into issues/126/mount-return-backup-file 2021-06-30 04:11:28 -04:00
quasd
049292669b fix yaml syntax for reject choices 2021-06-29 13:33:35 +03:00
Erkki Hurme
757b544cf3 fix REJECT target name 2021-06-29 10:38:47 +03:00
Robert Rettig
0118bf0cb9 fixes #24 and #190 2021-06-24 23:37:48 +02:00
ansible-zuul[bot]
a994a58b23
Merge pull request #203 from saito-hideki/issue/28_bsd
Modify boot option handling on BSD systems

Reviewed-by: https://github.com/apps/ansible-zuul
2021-06-16 11:30:20 +00:00
ansible-zuul[bot]
e2a316122a
Merge pull request #199 from Akasurde/i179
firewalld: Ensure idempotency

Reviewed-by: https://github.com/apps/ansible-zuul
2021-06-11 11:35:12 +00:00
ansible-zuul[bot]
e068522325
Merge pull request #205 from Akasurde/i204
csh: Define ``ECHO`` and ``COMMAND_SEP``

Reviewed-by: https://github.com/apps/ansible-zuul
2021-06-09 17:28:12 +00:00
Abhijeet Kasurde
51d117285f csh: Define `ECHO and COMMAND_SEP`
Fixes: #204

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-06-09 17:46:09 +05:30
Hideki Saito
c29bbd265b Modify boot option handling on BSD systems
* Fixes #28 for BSD systems
* Porting PR #196 to BSD systems

Signed-off-by: Hideki Saito <saito@fgrep.org>
2021-06-08 20:44:42 +09:00
ansible-zuul[bot]
7417d857f1
Merge pull request #202 from Akasurde/i124
acl: Add new alias

Reviewed-by: https://github.com/apps/ansible-zuul
2021-06-07 07:57:33 +00:00
ansible-zuul[bot]
ceddb849b8
Merge pull request #201 from Akasurde/i175
synchronize: fix misc typo

Reviewed-by: https://github.com/apps/ansible-zuul
2021-06-04 15:49:36 +00:00
ansible-zuul[bot]
f5666924ab
Merge pull request #200 from Akasurde/i193
firewalld: Specify unit for timeout

Reviewed-by: https://github.com/apps/ansible-zuul
2021-06-04 13:36:59 +00:00
Abhijeet Kasurde
7bed8ce79e review requests
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-06-04 18:39:50 +05:30
Abhijeet Kasurde
7d928e6e9d synchronize: fix misc typo
Docs should read ``--delete-after`` instead of ``--delete-excluded``.

Fixes: #175

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-06-04 18:38:01 +05:30
Abhijeet Kasurde
07fe3a91b6 firewalld: Ensure idempotency
Use APIs like ``query*`` instead of ``get*``.

Fixes: #179

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-06-04 16:55:19 +05:30
Abhijeet Kasurde
5cebc90623 firewalld: Specify unit for timeout
Timeout parameter takes value which is specified in seconds.

Fixes: #193

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-06-04 16:53:37 +05:30
Abhijeet Kasurde
6ba8445fb1 acl: Add new alias
Added new alias ``recurse`` for parameter ``recursive``.

Fixes: #124

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-06-04 16:51:15 +05:30
ansible-zuul[bot]
9d4ae8b7e4
Merge pull request #196 from saito-hideki/issue/28
Modify boot option handling on Linux systems

Reviewed-by: https://github.com/apps/ansible-zuul
2021-06-04 06:23:07 +00:00
Adam Miller
41e5b8428f mount return backup_file
Fixes https://github.com/ansible-collections/ansible.posix/issues/126

Signed-off-by: Adam Miller <admiller@redhat.com>
2021-06-04 10:52:38 +05:30
ansible-zuul[bot]
1793cd70c4
Merge pull request #172 from saito-hideki/issue/169
Append line-separator to the end of command line

Reviewed-by: https://github.com/apps/ansible-zuul
2021-06-03 12:02:30 +00:00
Abhijeet Kasurde
5d0c5ae3a6 synchronize: correct typo
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2021-06-02 12:58:56 +05:30
Hideki Saito
cfff8a3806 Modify boot option handling on Linux systems
* Address the issue #28
* Modified behavior to set noauto option if boot is 'no' on Linux system
* Modified integration test to use filesize module instead of dd

Signed-off-by: Hideki Saito <saito@fgrep.org>
2021-06-01 14:21:01 +09:00
ansible-zuul[bot]
7e6adc977f
Merge pull request #167 from aminvakil/rsync_hardcoded_options
synchronize: add delay_updates option

Reviewed-by: https://github.com/apps/ansible-zuul
2021-05-31 12:44:36 +00:00